From c8ecf5fd82ed41b5fad3e285e13bf4c6e1c194c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= <mfc@leodrive.ai> Date: Wed, 21 Feb 2024 00:46:41 +0300 Subject: [PATCH] without additional files --- json-schema-check/action.yaml | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/json-schema-check/action.yaml b/json-schema-check/action.yaml index 8bd3ebb2..3cdab4f0 100644 --- a/json-schema-check/action.yaml +++ b/json-schema-check/action.yaml @@ -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 ./ @@ -37,20 +33,24 @@ runs: shopt -s nullglob # Enable nullglob to handle no matches as an empty array 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