-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (40 loc) · 1.32 KB
/
check-json.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
38
39
40
41
42
43
name: JSON check
on:
push:
paths:
- '**.json'
- '**.yml'
- '**.yaml'
env:
PYTHON_VERSION: 3.11.6
jobs:
check-schemata:
name: Check Schemata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install jsonschema pyyaml
- name: Check JSON Syntax
uses: limitusus/json-syntax-check@v2
with:
pattern: "\\.json$"
- name: Check JSON Schemata
run: |
for schema in *.schema.json; do
if [[ -f "${schema%.schema.json}.json" ]]; then
python3 -c 'import json,jsonschema,sys;jsonschema.validate(json.load(open(sys.argv[1])), json.load(open(sys.argv[2])))' "${schema%.schema.json}.json" "$schema";
fi;
done
- name: Check YAML Schemata
run: |
for schema in *.schema.json; do
for ext in "yaml" "yml"; do
if [[ -f "${schema%.schema.json}.$ext" ]]; then
python3 -c 'import yaml,json,jsonschema,sys;jsonschema.validate(yaml.load(open(sys.argv[1]), yaml.Loader), json.load(open(sys.argv[2])))' "${schema%.schema.json}.$ext" "$schema";
fi;
done
done