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:- OIDC: recommended way for both private and public repositories
- Static CodSpeed tokens (legacy)
- Tokenless uploads (public repositories only)
OIDC (Recommended)
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 or job definition at the top-level:.github/workflows/codspeed.yml
CodSpeed token (Legacy)
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
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
