Skip to content

Commit

Permalink
workflows/check-json - use check-jsonschema to check schemata and files
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Jun 20, 2024
1 parent 0014a96 commit 0d0dde8
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/check-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install jsonschema pyyaml
run: python -m pip install check-jsonschema
- name: Check JSON Syntax
uses: limitusus/json-syntax-check@v2
with:
Expand All @@ -34,20 +34,11 @@ jobs:
rules:
line-length: disable
- name: Check JSON Schemata
run: check-jsonschema --verbose --check-metaschema *.schema.json
- name: Check Files
run: |
for schema in *.schema.json; do
if [[ -f "${schema%.schema.json}.json" ]]; then
echo "${schema%.schema.json}.json";
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
echo "${schema%.schema.json}.$ext";
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;
for ext in "yaml" "yml" "json"; do
[[ -f "${schema%.schema.json}.$ext" ]] && check-jsonschema --verbose --schemafile "$schema" "${schema%.schema.json}.$ext"
done
done

0 comments on commit 0d0dde8

Please sign in to comment.