Skip to content

Be more specific about expected schema validation failures #39

Be more specific about expected schema validation failures

Be more specific about expected schema validation failures #39

Workflow file for this run

# 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: JSON Validations
on: pull_request_target
permissions:
pull-requests: write
jobs:
JSON-Actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the PR JSON
uses: actions/checkout@v4
with:
ref: "refs/pull/${{ github.event.number }}/merge"
path: "pull-request"
sparse-checkout: "related_website_sets.JSON"
- uses: actions/setup-python@v5
with:
check-latest: true
- name: Validate JSON
run: |
pip3 install -r requirements.txt
python3 check_sites.py -i pull-request/related_website_sets.JSON --with_diff --strict_formatting > results.txt
- name: Read the Validation Results
id: read_results
uses: andstor/file-reader-action@v1
with:
path: "results.txt"
- name: Read the Changed Files
id: read_files
uses: tj-actions/changed-files@v45
- name: Failure Comment
if: steps.read_results.outputs.contents != 'success'
run: |
echo "The RWS JSON was not successfully validated. Here are your results:" > message.txt
cat results.txt >> message.txt
- name: Success Comment
if: steps.read_results.outputs.contents == 'success'
run: echo "The RWS JSON was successfully validated!" > message.txt
- name: System Comment
if: steps.read_files.outputs.all_changed_and_modified_files != 'related_website_sets.JSON'
run: |
echo "<br/>***THIS PR CONTAINS SYSTEM CHANGES PLEASE REVIEW WITH CARE!***" >> message.txt
- name: Write Comment
uses: mshick/add-pr-comment@v2
with:
message-path: "message.txt"
refresh-message-position: true
- name: Write Summary
run: cat message.txt >> $GITHUB_STEP_SUMMARY
- name: Record Failure
if: steps.read_results.outputs.contents != 'success'
uses: actions/github-script@v3
with:
script: core.setFailed('This run has failed.')