Skip to content

fix(tests): add network flag and per-network log dirs to cron script#29

Merged
whoabuddy merged 1 commit intomainfrom
fix/test-cron-network-flag
Jan 27, 2026
Merged

fix(tests): add network flag and per-network log dirs to cron script#29
whoabuddy merged 1 commit intomainfrom
fix/test-cron-network-flag

Conversation

@whoabuddy
Copy link
Copy Markdown
Contributor

Summary

  • Add --network=testnet|mainnet CLI argument to the test cron script
  • Organize test run logs into per-network subdirectories (logs/test-runs/testnet/, logs/test-runs/mainnet/)
  • Update cron schedule examples in comments

Test plan

  • Run ./scripts/run-tests-cron.sh (defaults to testnet)
  • Run ./scripts/run-tests-cron.sh --network=mainnet (explicit mainnet)
  • Verify logs land in logs/test-runs/{network}/

🤖 Generated with Claude Code

Support --network=testnet|mainnet CLI argument for running tests against
different environments. Organize log output into per-network subdirectories.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 27, 2026 13:25
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Jan 27, 2026

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 df37250 Jan 27 2026, 01:26 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 enhances the test cron script to support network-specific test execution and log organization. It adds a --network CLI flag allowing users to specify whether tests should run against testnet or mainnet, and organizes logs into per-network subdirectories for better separation.

Changes:

  • Added --network=testnet|mainnet CLI argument parsing with priority over environment variables
  • Updated log directory structure to use network-specific subdirectories (logs/test-runs/{network}/)
  • Updated cron schedule examples in comments from hourly to three times daily

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

--network=*) CLI_NETWORK="${arg#*=}" ;;
esac
done

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The script accepts arbitrary network values via the --network flag without validation. According to the test suite code (tests/_run_all_tests.ts:612-613), X402_NETWORK must be either "mainnet" or "testnet". If an invalid value like --network=prodnet is passed, it will create an incorrect log directory path and cause the test suite to fail with an error. Add validation after parsing CLI_NETWORK to ensure only "mainnet" or "testnet" are accepted.

Suggested change
# Validate CLI network value if provided
if [ -n "$CLI_NETWORK" ]; then
case "$CLI_NETWORK" in
mainnet|testnet)
;;
*)
echo "Error: Invalid network '$CLI_NETWORK'. Allowed values are 'mainnet' or 'testnet'." >&2
exit 1
;;
esac
fi

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +5
# Usage: ./scripts/run-tests-cron.sh [--network=testnet|mainnet]
# Cron: 0 4,12,20 * * * /path/to/run-tests-cron.sh
# 0 10 * * * /path/to/run-tests-cron.sh --network=mainnet
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The README.md still shows the old cron schedule pattern "0 * * * *" (hourly) which differs from the updated examples in this script's comments showing "0 4,12,20 * * *" (three times daily at 4am, 12pm, 8pm). Additionally, the README doesn't mention the new --network flag that allows users to specify mainnet or testnet. The documentation should be updated to reflect these new capabilities.

Copilot uses AI. Check for mistakes.
# Log directory
LOG_DIR="logs/test-runs"
# Log directory (separate subdirs per network)
LOG_DIR="logs/test-runs/${X402_NETWORK}"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The .gitignore file currently has "logs/test-runs/" which will no longer match the new nested structure "logs/test-runs/testnet/" and "logs/test-runs/mainnet/". While the parent "logs/" entry will still exclude these files, the more specific entry should be updated to "logs/test-runs/*/" to accurately reflect the new directory structure.

Copilot uses AI. Check for mistakes.
@whoabuddy whoabuddy merged commit 16c99c6 into main Jan 27, 2026
8 checks passed
@whoabuddy whoabuddy deleted the fix/test-cron-network-flag branch January 27, 2026 21:21
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