Setup
1. Create the benchmarks workflow
Create a new workflow to run the benchmarks for your repository. You can do this by creating thecodspeed.yml file in the .github/workflows
directory with the following content:
.github/workflows/codspeed.yml
CodSpeedHQ/action. This action will
configure the CodSpeed environment and upload the benchmarks results.
Make sure to include
pull_request in the on section of the workflow. This is
required to have reports on pull requests correctly working.Learn more about
baseline report selection.Sample configurations
- Python (with
pytest-codspeed) - Rust (with
cargo-codspeed) - Node.js (with
codspeed-nodeand TypeScript)
2. Check the results
Once the workflow is created, your pull requests will receive a performance report comment and will also receive some additional checks:

3. Next Steps
Now that everything is up and running (and hopefully green π), you can start enhancing your workflow to get the most out of CodSpeed.Explore the Performance Metrics
Understand the performance metrics generated by CodSpeed
Enforce Performance Checks
Make sure you or team members never merge unexpected performance regressions
Dive in Trace Generation
Get detailed performance traces for your benchmarks
Shard the execution of your benchmarks
Run your benchmarks in parallel to speed up your CI
Authentication
CodSpeed needs to validate the authenticity of the benchmark results being uploaded. In order to upload benchmark results to CodSpeed, the GitHub Actions workflow needs to authenticate with CodSpeed. There are three supported methods for authentication:- OpenID Connect (OIDC): recommended way for both private and public repositories
- Static CodSpeed tokens
- Tokenless uploads (public repositories only)
OpenID Connect (OIDC) Authentication
CodSpeed recommends using OpenID Connect (OIDC) for authentication. Using this method, a token is generated on-the-fly during the workflow run. This token is then used to authenticate securely with CodSpeed without needing to store long-lived credentials, but grants no additional permissions to the workflow. To enable OIDC, add the following section to your workflow definition:CodSpeed token (Classic)
While we recommend using OpenID Connect (OIDC) for improved security, you can use a static CodSpeed token for authentication. Retrieve your CodSpeed token from your repository settings page:
Token Scope: Be mindful that a token is scoped to a specific repository.
Make sure that you are on the correct repository settings page when copying the
token.
CODSPEED_TOKEN and the value of your token.
Then pass the token explicitly to the action using the with key:
Tokenless upload (public repositories only)
CodSpeed allows tokenless uploads for public repositories, allowing runs to be triggered from public forks directly. However, we still recommend using OIDC for improved security. To use tokenless uploads on public repositories, you can simply omit thetoken
input and the whole permissions section when
creating the benchmarks workflow.
Advanced
Defining environment variables
You can define environment variables for your benchmarks by using theenv key
in the section of the action:
Running benchmarks in parallel CI jobs
With Github Actions, you can leverage matrix jobs to improve the performance of your benchmarks. For example, usingpytest:
.github/workflows/codspeed.yml
Using container images
When running benchmarks in a container (such asubuntu:latest or other base
images), git is typically not installed by default. Without git in the path,
actions/checkout falls back to downloading a tarball of your code, which does
not setup a local git repository.
CodSpeed relies on git to determine the current commit hash and other metadata,
so itβs important to have git installed and the repository checked out.
The
git config --global --add safe.directory command is required to prevent
git from triggering file system permission errors when accessing the repository.
More details can be found in this
GitHub IssueCompatibility
For now, only the following OS and versions are supported on the runners:- Ubuntu 22.04 and later
- Debian 12 and later
