From bf7ab002e13c86ca035b8bc809f3d23ce1f47f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Wed, 21 Feb 2024 00:04:38 +0300 Subject: [PATCH] test colors --- json-schema-check/action.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/json-schema-check/action.yaml b/json-schema-check/action.yaml index e1334fb4..2e9b5cc0 100644 --- a/json-schema-check/action.yaml +++ b/json-schema-check/action.yaml @@ -14,6 +14,14 @@ runs: # 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' + NO_COLOR='\033[0m' + find . -path '*/schema/*.schema.json' -exec bash -c ' schemaFile="${1#./}" # Normalize schema file path to remove leading ./ @@ -28,18 +36,19 @@ runs: configFiles=("${configDir}/${baseName}"*.param.yaml) # Pattern match for config files for configFile in "${configFiles[@]}"; do - echo -n "🔍 Validating: $configFile 🆚 $schemaFile ➡️ " + echo -ne "🔍 Validating: $configFile 🆚 $schemaFile ▶️ " if ! check-jsonschema --schemafile "$schemaFile" "$configFile"; then # If validation fails, print failure message and record the failure - echo "❌ Failed" + echo -e "${RED}❌ Failed${NO_COLOR}" echo "1" > check_failures fi done ' bash {} \; if [ "$(cat check_failures)" = "1" ]; then - echo "❗ Validation failed for one or more files." + echo -e "${RED}❗ Validation failed for one or more files.${NO_COLOR}" rm check_failures # Clean up exit 1 fi + echo -e "${GREEN}✔️ All validations passed successfully.${NO_COLOR}" rm check_failures # Clean up shell: bash