From 077459aa557903cf8a50c1b52662de824aea68c4 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Fri, 3 Nov 2023 09:25:13 +0100 Subject: [PATCH] workflows:check-json - check schemata dynamically --- .github/workflows/check-json.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-json.yml b/.github/workflows/check-json.yml index ccd8e55..1f966c8 100644 --- a/.github/workflows/check-json.yml +++ b/.github/workflows/check-json.yml @@ -25,5 +25,15 @@ jobs: uses: limitusus/json-syntax-check@v2 with: pattern: "\\.json$" - - name: Check Actions Schema - run: python -c 'import yaml,json,jsonschema,sys;jsonschema.validate(yaml.load(open(sys.argv[1]), yaml.Loader), json.load(open(sys.argv[2])))' fileformats.yml fileformats.schema.json \ No newline at end of file + - name: Check JSON Schemata + run: | + for schema in *.schema.json; do + [[ -f "${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"; + done + - name: Check YAML Schemata + run: | + for schema in *.schema.json; do + for ext in "yaml" "yml"; do + [[ -f "${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"; + done + done \ No newline at end of file