Skip to content

Commit

Permalink
without additional files
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Fatih Cırıt committed Feb 20, 2024
1 parent 97ea7be commit c8ecf5f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions json-schema-check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ runs:

- name: Check configuration files
run: |
# Use a file to track failures
touch check_failures
# Ensure output supports color
export TERM=xterm-color
# ANSI color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m' # Cyan
LIGHT_CYAN='\033[1;36m' # Bright Cyan for a cyan-like blue
NO_COLOR='\033[0m'
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export NO_COLOR='\033[0m'
export CYAN='\033[0;36m'
export LIGHT_CYAN='\033[1;36m'
validation_failed=0 # Initialize as false
find . -path '*/schema/*.schema.json' -exec bash -c '
schemaFile="${1#./}" # Normalize schema file path to remove leading ./
Expand All @@ -37,20 +33,24 @@ runs:
shopt -s nullglob # Enable nullglob to handle no matches as an empty array

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (shopt)

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (nullglob)

Check warning on line 33 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
local_failed=0 # Track failures for this schema
for configFile in "${configFiles[@]}"; do
echo -ne "🔍 Validating: ${CYAN}$configFile 🆚 ${LIGHT_CYAN}$schemaFile${NO_COLOR} ▶️ "
echo -ne "🔍 Validating: ${CYAN}${configFile}${NO_COLOR} 🆚 ${LIGHT_CYAN}${schemaFile}${NO_COLOR} ▶️ "
if ! check-jsonschema --schemafile "$schemaFile" "$configFile"; then
# If validation fails, print failure message and record the failure
# If validation fails, print failure message
echo -e "${RED}❌ Failed${NO_COLOR}"
echo "1" > check_failures
local_failed=1 # Mark as failed
fi
done
' bash {} \;
if [ "$(cat check_failures)" = "1" ]; then
exit $local_failed # Exit with the local failure status
' bash {} \; || validation_failed=1 # Catch any failure and mark validation as failed
if [ "$validation_failed" -eq 1 ]; then
echo -e "${RED}❗ Validation failed for one or more files.${NO_COLOR}"
rm check_failures # Clean up
exit 1
else
echo -e "${GREEN}✔️ All validations passed successfully.${NO_COLOR}"
fi
echo -e "${GREEN}✔️ All validations passed successfully.${NO_COLOR}"
rm check_failures # Clean up
shell: bash

0 comments on commit c8ecf5f

Please sign in to comment.