Syntax check #523
Workflow file for this run
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
name: Syntax check | |
on: | |
push: | |
paths: | |
- '**.json' | |
- '**.schema' | |
- '**.yaml' | |
pull_request: | |
jobs: | |
syntaxcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: check valid json | |
run: | | |
echo "Checking valid json..." | |
shopt -s globstar | |
# check both json and schema file extensions | |
ls **/*.json >/dev/null && for j in **/*.json; do python -mjson.tool "$j" > /dev/null || (echo "INVALID $j" >&2; 1>foo ); done | |
ls **/*.schema >/dev/null && for j in **/*.schema; do python -mjson.tool "$j" > /dev/null || (echo "INVALID $j" >&2; 1>foo ); done | |
[[ ! -f "foo" ]] | |
- name: check valid yaml | |
run: | | |
echo "Checking valid yaml..." # even if no yaml is currently in repository | |
shopt -s globstar | |
ls **/*.yaml >/dev/null && for j in **/*.yaml; do python -c 'import yaml, sys; print(yaml.safe_load(sys.stdin))' < $j > /dev/null || (echo "INVALID $j" >&2; 1>foo1 ); done | |
[[ ! -f "foo1" ]] |