Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/scripts/check-test-regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions .github/scripts/test-external-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Loading