This file provides guidance to AI coding agents when working with code in this repository.
CodSpeed Runner is a Rust CLI application for gathering performance data and uploading reports to CodSpeed. The binary is named codspeed and supports local and CI environments including GitHub Actions, GitLab CI, and Buildkite.
# Build the project
cargo build
# Build in release mode
cargo build --release
# Run tests (prefer nextest if available)
cargo nextest run # preferred if installed
cargo test # fallback if nextest is not available
# Run specific test
cargo nextest run <test_name> # with nextest
cargo test <test_name> # with cargo test
# Run tests with output
cargo nextest run --nocapture # with nextest
cargo test -- --nocapture # with cargo testNote: Always check if cargo nextest is available first (with cargo nextest --version or which cargo-nextest). If available, use it instead of cargo test as it provides faster and more reliable test execution.
# Build and run
cargo run -- <subcommand> <args>
# Examples:
cargo run -- auth login
cargo run -- run "cargo bench"
cargo run -- setup# Check code without building
cargo check
# Format code
cargo fmt
# Run linter
cargo clippyThe application follows a modular structure:
main.rs: Entry point with error handling and logging setupapp.rs: CLI definition using clap with subcommands (Run, Auth, Setup)api_client.rs: CodSpeed GraphQL API clientauth.rs: Authentication managementconfig.rs: Configuration loading and management
The core functionality for running benchmarks:
run_environment/: CI provider implementations (GitHub Actions, GitLab CI, Buildkite, local)runner/: Execution modes:valgrind/: Instrumentation mode using custom Valgrindwall_time/perf/: Walltime mode with perf integration
uploader/: Results upload to CodSpeed
clap: CLI framework with derive macrostokio: Async runtime (current_thread flavor)reqwest: HTTP client with middleware/retryserde/serde_json: Serializationgql_client: Custom GraphQL clienttabled: Table formatting for CLI output (https://docs.rs/tabled/latest/tabled/index.html)- Platform-specific:
procfs(Linux),linux-perf-data
CODSPEED_LOG: Set logging level (debug, info, warn, error)CODSPEED_API_URL: Override API endpoint (default: https://gql.codspeed.io/)CODSPEED_OAUTH_TOKEN: Authentication token
The project uses:
cargo nextest(preferred) or standard Rustcargo testinstafor snapshot testingrstestfor parameterized teststemp-envfor environment variable testing
Test files include snapshots in snapshots/ directories for various run environment providers.
Important:
- Always prefer
cargo nextest runovercargo testwhen running tests, as it provides better performance and reliability. - Some walltime executor tests require
sudoaccess and will fail in non-interactive environments (e.g.,test_walltime_executor::*). These failures are expected if sudo is not available.