-
Notifications
You must be signed in to change notification settings - Fork 15
37 lines (31 loc) · 1.19 KB
/
syntaxcheck.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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" ]]