Commit 417e0f9
committed
feat(run-environment): support CircleCI for GitHub repositories
The build runs on CircleCI while commits and pull requests live on GitHub, so a
run is reported against the GitHub commit and pull request. Detection is
`CIRCLECI=true`, and the repository comes from `CIRCLE_REPOSITORY_URL`. CircleCI
also builds Bitbucket and GitLab repositories, so the remote's domain is checked
and anything but `github.com` is refused with an error naming the domain found.
That domain is the only signal available at runtime: `pipeline.project.type` is a
pipeline value, interpolated when the config is compiled, so it never reaches the
job as an environment variable.
`runId` is `CIRCLE_WORKFLOW_ID`, shared by every job and every parallel container
of a workflow; the per-job `CIRCLE_WORKFLOW_JOB_ID` would split one workflow into
unrelated runs. `runPartId` is `{CIRCLE_JOB}-{CIRCLE_NODE_INDEX}`, to stay unique
along both fan-out axes. No commit hash override is needed, as CircleCI checks
out the associated commit rather than a synthetic merge ref.
Uploads authenticate with an OIDC token the job mints for itself, so they need no
`CODSPEED_TOKEN` secret. The token CircleCI exposes in `CIRCLE_OIDC_TOKEN` and
`CIRCLE_OIDC_TOKEN_V2` cannot be used: its audience is fixed to the id of the
CircleCI organization, while CodSpeed requires its own. Only the `circleci` CLI
can request a custom audience — CircleCI publishes no endpoint for it, unlike the
`ACTIONS_ID_TOKEN_REQUEST_URL` GitHub Actions provides — so the runner shells out
to `circleci run oidc get`, once per upload, as a token expires an hour after it
is minted.
Whether a job can mint at all is settled by minting a token and throwing it away,
before the benchmarks run: a CLI can be installed and still predate
`run oidc get`, so probing for the binary would pass and the mint would fail once
the benchmarks had run for nothing. A static `CODSPEED_TOKEN` is used as is when
one is set, and stays required for a pull request opened from a fork, whose token
names the fork.
`baseRef` and `sender` are left empty: CircleCI exposes neither a base-branch
variable nor the id the repository provider gives the user who triggered a build.
Closes COD-2995
Closes COD-32571 parent 97a789a commit 417e0f9
9 files changed
Lines changed: 778 additions & 0 deletions
File tree
- src
- run_environment
- circleci
- snapshots
- upload
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments