chore: streamline meta.json validation process by removing debug output and optimizing entry checks

This commit is contained in:
Mauricio Siu 2025-04-03 00:40:08 -06:00
parent 076c82490c
commit 8069689a73

View File

@ -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."