-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from gematik/johannes/lint-jsonschema
Add JSON schema validation into linting workflow
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Lint JSON Schema | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up check-jsonschema | ||
shell: bash | ||
run: | | ||
pip install check-jsonschema | ||
- name: Set up environment | ||
shell: bash | ||
run: | | ||
# Sadly, composite actions currently don't support environment variables so we freestyle a replacement | ||
echo 'SCHEMAS_ROOT=src/schema' >> .gha-env | ||
echo 'EXAMPLES_ROOT=src/schema/examples' >> .gha-env | ||
- name: Verify schemas | ||
shell: bash | ||
run: | | ||
source .gha-env | ||
# We handle the return code ourselves to prevent the action from exiting on the first error | ||
rc=0 | ||
while read -r file; do | ||
echo "Validating $file" | ||
if ! check-jsonschema --check-metaschema "$file"; then | ||
rc=1 | ||
fi | ||
done < <(find "$SCHEMAS_ROOT" -name "*.json" -maxdepth 1) | ||
exit $rc | ||
- name: Verify examples | ||
shell: bash | ||
run: | | ||
source .gha-env | ||
# We handle the return code ourselves to prevent the action from exiting on the first error | ||
rc=0 | ||
while read -r file; do | ||
schema=$(basename "$file") | ||
schema=$SCHEMAS_ROOT/${schema%%.*}.json | ||
echo "Validating $file against $schema" | ||
if ! check-jsonschema --schemafile "$schema" "$file"; then | ||
rc=1 | ||
fi | ||
done < <(find "$EXAMPLES_ROOT" -name "*.json") | ||
exit $rc |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"defaultSetting": "allow all" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"defaultSetting": "block all", | ||
"userException": [{ | ||
"mxid": "@david:hassel.hoff" | ||
}] | ||
} |