Skip to content

fix(cron): write success marker instead of deleting logs#34

Merged
whoabuddy merged 1 commit intomainfrom
fix/cron-success-marker
Jan 29, 2026
Merged

fix(cron): write success marker instead of deleting logs#34
whoabuddy merged 1 commit intomainfrom
fix/cron-success-marker

Conversation

@whoabuddy
Copy link
Copy Markdown
Contributor

Summary

Write latest-success.log on successful runs so we can distinguish between "tests passed" and "tests didn't run".

Changes

  • On success: write minimal marker file with timestamp and summary line
  • On failure: keep full log (unchanged behavior)

Example output

=== Last Successful Run ===
Timestamp: Thu Jan 29 10:00:01 AM MST 2026
Network: mainnet
  11/12 passed (91.7%)

Test plan

  • Wait for next cron run
  • Verify logs/test-runs/mainnet/latest-success.log exists after passing run

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings January 29, 2026 13:18
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
x402-api-staging 78cf6af Jan 29 2026, 01:18 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
x402-api-production 78cf6af Jan 29 2026, 01:18 PM

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.log with 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.

Comment on lines +115 to +116
# Extract summary line from test output
grep -E "passed \([0-9]+\.[0-9]+%\)" "$TEMP_LOG" | tail -1 >> "$SUCCESS_FILE"
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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"

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@whoabuddy whoabuddy merged commit 2c7b45b into main Jan 29, 2026
8 checks passed
@whoabuddy whoabuddy deleted the fix/cron-success-marker branch January 29, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants