diff --git a/.github/scripts/check-test-regression.py b/.github/scripts/check-test-regression.py index 6dd0e979921cd..10cc78de59cb1 100644 --- a/.github/scripts/check-test-regression.py +++ b/.github/scripts/check-test-regression.py @@ -14,8 +14,22 @@ def parse_forge_json(json_file): print(f"Parsing test results from {json_file}...") + # Check for empty file + if json_file.stat().st_size == 0: + print(f"WARNING: {json_file} is empty (forge may have failed to compile or run)") + return {} + with open(json_file, 'r', encoding='utf-8') as f: - data = json.load(f) + content = f.read().strip() + if not content: + print(f"WARNING: {json_file} contains only whitespace") + return {} + try: + data = json.loads(content) + except json.JSONDecodeError as e: + print(f"WARNING: {json_file} contains invalid JSON: {e}") + print(f"File content (first 500 chars): {content[:500]}") + return {} for contract_key, contract_data in data.items(): contract_name = contract_key.split(':')[-1] if ':' in contract_key else contract_key diff --git a/.github/scripts/test-external-projects.sh b/.github/scripts/test-external-projects.sh index a22fe708299ba..cbc5da3582974 100755 --- a/.github/scripts/test-external-projects.sh +++ b/.github/scripts/test-external-projects.sh @@ -37,7 +37,8 @@ echo "$PROJECTS" | jq -c '.[]' | while read -r project; do echo "Testing in: $dir" cd "$dir" TEMP_JSON=$(mktemp) - forge test --polkadot --json > "$TEMP_JSON" 2>&1 || true + # stdout goes to JSON file, stderr goes to console for debugging + forge test --polkadot --json > "$TEMP_JSON" || true # Merge JSON outputs using jq if [ -s "$TEMP_JSON" ] && jq empty "$TEMP_JSON" 2>/dev/null; then jq -s '.[0] * .[1]' "$OUTPUT_FILE" "$TEMP_JSON" > "${OUTPUT_FILE}.tmp" && mv "${OUTPUT_FILE}.tmp" "$OUTPUT_FILE" @@ -50,7 +51,8 @@ echo "$PROJECTS" | jq -c '.[]' | while read -r project; do if [ -n "$WORKING_DIR" ]; then cd "$WORKING_DIR" fi - forge test --polkadot $EXTRA_ARGS --json > "$OUTPUT_FILE" 2>&1 || true + # stdout goes to JSON file, stderr goes to console for debugging + forge test --polkadot $EXTRA_ARGS --json > "$OUTPUT_FILE" || true fi cd "$GITHUB_WORKSPACE"