From 8069689a7388cd67f32179c9e20bad6e268c8b48 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 3 Apr 2025 00:40:08 -0600 Subject: [PATCH] chore: streamline meta.json validation process by removing debug output and optimizing entry checks --- .github/workflows/validate.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 12a3545..48cfaa8 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -51,9 +51,6 @@ jobs: - name: Validate meta.json structure and required fields run: | - set -x # Enable debug mode to see all commands - exec 2>&1 # Redirect stderr to stdout to see all output - echo "🔍 Validating meta.json structure and required fields..." # First check if meta.json exists and is valid JSON @@ -74,9 +71,13 @@ jobs: TOTAL_ENTRIES=$(jq '. | length' meta.json) echo "📊 Total entries in meta.json: $TOTAL_ENTRIES" - # Validate JSON structure and required fields - while IFS= read -r entry; do - ((INDEX++)) + # Get all entries at once and process them + TOTAL_INDEX=$(($TOTAL_ENTRIES - 1)) + + for i in $(seq 0 $TOTAL_INDEX); do + entry=$(jq -c ".[$i]" meta.json) + INDEX=$((i + 1)) + echo "-------------------------------------------" echo "🔍 Checking entry #$INDEX..." @@ -89,7 +90,7 @@ jobs: if [ "$(echo "$entry" | jq "has(\"$field\")")" != "true" ]; then ERROR_MSG="❌ Entry #$INDEX (ID: $ID) is missing required field: $field" echo "$ERROR_MSG" - ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" + ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n" ERROR=1 fi done @@ -100,7 +101,7 @@ jobs: if [ "$(echo "$entry" | jq ".links | has(\"$link_field\")")" != "true" ]; then ERROR_MSG="❌ Entry #$INDEX (ID: $ID): links object is missing required field: $link_field" echo "$ERROR_MSG" - ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" + ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n" ERROR=1 fi done @@ -110,15 +111,15 @@ jobs: if [ "$(echo "$entry" | jq '.tags | length')" -eq 0 ]; then ERROR_MSG="❌ Entry #$INDEX (ID: $ID): tags array cannot be empty" echo "$ERROR_MSG" - ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" + ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n" ERROR=1 fi - done < <(jq -c '.[]' meta.json) + done echo "-------------------------------------------" if [ $ERROR -eq 1 ]; then echo "❌ meta.json structure validation failed." - echo -e "Summary of all errors found:$ERRORS_FOUND" + echo -e "Summary of all errors found:${ERRORS_FOUND}" exit 1 else echo "✅ meta.json structure validated successfully."