Skip to content

Commit

Permalink
ci(json-schema-check): improve readibility and output helpful debug info
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
M. Fatih Cırıt committed Feb 20, 2024
1 parent 48faad7 commit 9b97c56
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion json-schema-check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@ runs:

- name: Check configuration files
run: |
find -wholename '*/schema/*.schema.json' -printf '%p: ' -execdir bash -c 'check-jsonschema --schemafile "$1" ../config/"${1:2:-12}"*.param.yaml' bash '{}' +
find . -path '*/schema/*.schema.json' -exec bash -c '
schemaFile="${1#./}" # Normalize schema file path to remove leading ./
baseName="${schemaFile##*/}" # Extract just the file name
baseName="${baseName%.schema.json}" # Remove the schema.json extension
# Determine the directory of the schema and switch to corresponding config directory
configDir="${schemaFile%/*}" # Get the directory path for schema, without leading ./
configDir="${configDir/schema/config}" # Switch to config directory
shopt -s nullglob # Enable nullglob to handle no matches as an empty array

Check warning on line 24 in json-schema-check/action.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (shopt)

Check warning on line 24 in json-schema-check/action.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (nullglob)

Check warning on line 24 in json-schema-check/action.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (nullglob)
configFiles=("${configDir}/${baseName}"*.param.yaml) # Pattern match for config files
for configFile in "${configFiles[@]}"; do
echo "Validating $configFile against $schemaFile" # Log validation action
check-jsonschema --schemafile "$schemaFile" "$configFile" # Perform validation
done
' bash {} \;
shell: bash

0 comments on commit 9b97c56

Please sign in to comment.