Add associated warning #524
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: RWS submission checks | |
on: | |
schedule: | |
- cron: '0 14 * * 2' # 2pm UTC each Tuesday | |
pull_request_target: | |
jobs: | |
PR-Actions: | |
runs-on: ubuntu-latest | |
outputs: | |
output1: ${{ steps.read_results.outputs.contents }} | |
steps: | |
- name: Get the PR version of the files | |
uses: actions/checkout@v2 | |
with: | |
ref: "refs/pull/${{ github.event.number }}/merge" | |
path: "pull-request" | |
- name: Get the version at main | |
uses: actions/checkout@v2 | |
with: | |
path: "main" | |
- name: Get necessary libraries | |
run: pip install publicsuffix2 | |
- name: Content check | |
id: check | |
run: python3 main/check_sites.py -i pull-request/related_website_sets.JSON --data_directory=main --with_diff > results.txt | |
- name: Read the result | |
id: read_results | |
uses: andstor/file-reader-action@v1 | |
with: | |
path: "results.txt" | |
- name: File contents | |
env: | |
CONTENTS: ${{ steps.read_results.outputs.contents }} | |
run: echo "$CONTENTS" | |
- name: Create Comment | |
if: steps.read_results.outputs.contents != 'success' && ${{ !startsWith(steps.read_results.outputs.contents, 'Warning')}} | |
run: | | |
echo "It appears you have failed some tests. Here are your results:" > message.txt | |
cat results.txt >> message.txt | |
- name: Comment if success | |
if: steps.read_results.outputs.contents == 'success' | |
run: echo "Looks like you've passed all of the checks!" >> message.txt | |
- name: Comment if warning | |
if: startsWith(steps.read_results.outputs.contents, 'Warning') | |
run: | | |
echo "You have passed all of the checks, but there are one or more warnings associated with your submission." > message.txt | |
cat results.txt >> message.txt | |
- name: Write Comment on PR | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message-path: "message.txt" | |
refresh-message-position: true | |
- name: Fail or Succeed | |
if: startsWith(steps.read_results.outputs.contents, 'It appears you have failed') | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
core.setFailed('This run has failed. Check `File Contents` to see why.') |