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 - name: Validate meta.json structure and required fields
run: | 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..." echo "🔍 Validating meta.json structure and required fields..."
# First check if meta.json exists and is valid JSON # First check if meta.json exists and is valid JSON
@@ -74,9 +71,13 @@ jobs:
TOTAL_ENTRIES=$(jq '. | length' meta.json) TOTAL_ENTRIES=$(jq '. | length' meta.json)
echo "📊 Total entries in meta.json: $TOTAL_ENTRIES" echo "📊 Total entries in meta.json: $TOTAL_ENTRIES"
# Validate JSON structure and required fields # Get all entries at once and process them
while IFS= read -r entry; do TOTAL_INDEX=$(($TOTAL_ENTRIES - 1))
((INDEX++))
for i in $(seq 0 $TOTAL_INDEX); do
entry=$(jq -c ".[$i]" meta.json)
INDEX=$((i + 1))
echo "-------------------------------------------" echo "-------------------------------------------"
echo "🔍 Checking entry #$INDEX..." echo "🔍 Checking entry #$INDEX..."
@@ -89,7 +90,7 @@ jobs:
if [ "$(echo "$entry" | jq "has(\"$field\")")" != "true" ]; then if [ "$(echo "$entry" | jq "has(\"$field\")")" != "true" ]; then
ERROR_MSG="❌ Entry #$INDEX (ID: $ID) is missing required field: $field" ERROR_MSG="❌ Entry #$INDEX (ID: $ID) is missing required field: $field"
echo "$ERROR_MSG" echo "$ERROR_MSG"
ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n"
ERROR=1 ERROR=1
fi fi
done done
@@ -100,7 +101,7 @@ jobs:
if [ "$(echo "$entry" | jq ".links | has(\"$link_field\")")" != "true" ]; then if [ "$(echo "$entry" | jq ".links | has(\"$link_field\")")" != "true" ]; then
ERROR_MSG="❌ Entry #$INDEX (ID: $ID): links object is missing required field: $link_field" ERROR_MSG="❌ Entry #$INDEX (ID: $ID): links object is missing required field: $link_field"
echo "$ERROR_MSG" echo "$ERROR_MSG"
ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n"
ERROR=1 ERROR=1
fi fi
done done
@@ -110,15 +111,15 @@ jobs:
if [ "$(echo "$entry" | jq '.tags | length')" -eq 0 ]; then if [ "$(echo "$entry" | jq '.tags | length')" -eq 0 ]; then
ERROR_MSG="❌ Entry #$INDEX (ID: $ID): tags array cannot be empty" ERROR_MSG="❌ Entry #$INDEX (ID: $ID): tags array cannot be empty"
echo "$ERROR_MSG" echo "$ERROR_MSG"
ERRORS_FOUND="$ERRORS_FOUND\n$ERROR_MSG" ERRORS_FOUND="${ERRORS_FOUND}${ERROR_MSG}\n"
ERROR=1 ERROR=1
fi fi
done < <(jq -c '.[]' meta.json) done
echo "-------------------------------------------" echo "-------------------------------------------"
if [ $ERROR -eq 1 ]; then if [ $ERROR -eq 1 ]; then
echo "❌ meta.json structure validation failed." 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 exit 1
else else
echo "✅ meta.json structure validated successfully." echo "✅ meta.json structure validated successfully."