fix(tests): add network flag and per-network log dirs to cron script#29
fix(tests): add network flag and per-network log dirs to cron script#29
Conversation
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>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
x402-api-staging | df37250 | Jan 27 2026, 01:26 PM |
There was a problem hiding this comment.
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|mainnetCLI 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 | ||
|
|
There was a problem hiding this comment.
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.
| # 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 |
| # 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 |
There was a problem hiding this comment.
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.
| # Log directory | ||
| LOG_DIR="logs/test-runs" | ||
| # Log directory (separate subdirs per network) | ||
| LOG_DIR="logs/test-runs/${X402_NETWORK}" |
There was a problem hiding this comment.
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.
Summary
--network=testnet|mainnetCLI argument to the test cron scriptlogs/test-runs/testnet/,logs/test-runs/mainnet/)Test plan
./scripts/run-tests-cron.sh(defaults to testnet)./scripts/run-tests-cron.sh --network=mainnet(explicit mainnet)logs/test-runs/{network}/🤖 Generated with Claude Code