fix(cron): write success marker instead of deleting logs#34
Conversation
Write latest-success.log on successful runs so we can distinguish between "tests passed" and "tests didn't run". Includes timestamp and summary line. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
x402-api-staging | 78cf6af | Jan 29 2026, 01:18 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
x402-api-production | 78cf6af | Jan 29 2026, 01:18 PM |
There was a problem hiding this comment.
Pull request overview
This PR modifies the cron test script to write a success marker file instead of simply deleting logs when tests pass, enabling operators to distinguish between "tests passed" and "tests didn't run".
Changes:
- Modified success case handling to create
latest-success.logwith timestamp and summary information - Kept failure case behavior unchanged (full log retention with 7-day cleanup)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Extract summary line from test output | ||
| grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 >> "$SUCCESS_FILE" |
There was a problem hiding this comment.
The grep pattern will likely fail to extract the summary line correctly because the test output includes ANSI color codes. The summary line at line 812 of tests/_run_all_tests.ts includes color codes like \x1b[32m, \x1b[1m, etc., which will be written to the log file when stdout is redirected.
The pattern "passed \([0-9]+\.[0-9]+%\)" expects literal parentheses around the percentage, but the actual output will have ANSI escape sequences interspersed, making the pattern fail to match.
Consider stripping ANSI color codes before matching. One approach is to use sed or a similar tool to remove color codes, or pipe through sed 's/\x1b\[[0-9;]*m//g' before grepping. Alternatively, you could use grep --color=never combined with stripping codes from the temp log, or modify the test runner to detect when output is being redirected and disable colors accordingly.
| # Extract summary line from test output | |
| grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 >> "$SUCCESS_FILE" | |
| # Extract summary line from test output (strip ANSI color codes first) | |
| sed 's/\x1b\[[0-9;]*m//g' "$TEMP_LOG" | grep -E "passed \([0-9]+\.[0-9]+%\)" | tail -1 >> "$SUCCESS_FILE" |
| echo "Timestamp: $(date)" >> "$SUCCESS_FILE" | ||
| echo "Network: ${X402_NETWORK}" >> "$SUCCESS_FILE" | ||
| # Extract summary line from test output | ||
| grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 >> "$SUCCESS_FILE" |
There was a problem hiding this comment.
If the grep command fails to find a match (due to pattern mismatch or other issues), nothing will be appended to the success file, but the script will continue without error. This creates a silent failure where the success marker exists but is missing the critical summary information.
Consider adding error handling to detect when the grep fails to find a match, and either append a fallback message or log a warning. For example, you could check if the grep returned any results and append "Summary: (not found)" if it didn't, or use a more robust extraction method.
| grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 >> "$SUCCESS_FILE" | |
| SUMMARY_LINE="$(grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 || true)" | |
| if [ -n "$SUMMARY_LINE" ]; then | |
| echo "$SUMMARY_LINE" >> "$SUCCESS_FILE" | |
| else | |
| echo "Summary: (not found)" >> "$SUCCESS_FILE" | |
| echo "Warning: Summary line not found in test output: $TEMP_LOG" >&2 | |
| fi |
Summary
Write
latest-success.logon successful runs so we can distinguish between "tests passed" and "tests didn't run".Changes
Example output
Test plan
logs/test-runs/mainnet/latest-success.logexists after passing run🤖 Generated with Claude Code