Skip to content

feat(run-environment): add CircleCI provider for GitHub repositories - #473

Open
fargito wants to merge 1 commit into
mainfrom
feat/circleci-run-environment
Open

feat(run-environment): add CircleCI provider for GitHub repositories#473
fargito wants to merge 1 commit into
mainfrom
feat/circleci-run-environment

Conversation

@fargito

@fargito fargito commented Jul 27, 2026

Copy link
Copy Markdown
Member

Add a CircleCI run environment, for repositories hosted on GitHub.

The build runs on CircleCI while commits and pull requests live on GitHub, so the 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 rejected 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.

Two things worth a look:

  • No commit hash override. CircleCI checks out the associated commit rather than a synthetic
    merge ref, so reading git HEAD already yields CIRCLE_SHA1.
  • 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.

baseRef is left empty, as CircleCI exposes no base-branch variable. Pull request uploads need a
server-side change that is not released yet; push events are unaffected.

Uploads authenticate with a static CODSPEED_TOKEN. Minting OIDC tokens instead is #482, stacked
on top.

Refs COD-2995
Refs COD-3262

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

Adds CircleCI support for GitHub-hosted repositories.

  • Detects CircleCI jobs and derives repository, ref, event, workflow, job, and parallel-node metadata from CircleCI environment variables.
  • Adds CircleCI-specific logging and static-token authentication guidance.
  • Registers CircleCI in provider selection and upload-error handling.

Confidence Score: 5/5

The PR appears safe to merge with respect to the eligible follow-up findings.

No blocking failure remains from the previous logger thread, because direct stdout output is required inside the logging sink and matches the repository's other logger backends.

Important Files Changed

Filename Overview
src/run_environment/circleci/provider.rs Implements CircleCI detection, GitHub repository validation, event metadata, static-token enforcement, and workflow run-part identity.
src/run_environment/circleci/logger.rs Adds a CircleCI logging sink with colored headings and level-aware output consistent with the repository's logger implementations.
src/run_environment/mod.rs Registers CircleCI in provider detection before the local fallback.
src/run_environment/interfaces.rs Adds the serialized CircleCI run-environment variant.
src/upload/uploader.rs Provides CircleCI users the static-token authentication hint for unauthorized uploads.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Env["CircleCI environment variables"] --> Detect["Detect CIRCLECI=true"]
  Detect --> Validate["Parse and validate GitHub repository"]
  Validate --> Metadata["Build run-environment metadata"]
  Validate --> Part["Build workflow/job/node run-part identity"]
  Metadata --> Upload["Upload benchmark profile"]
  Part --> Upload
  Token["CODSPEED_TOKEN"] --> Upload
Loading

Reviews (4): Last reviewed commit: "feat(run-environment): add CircleCI prov..." | Re-trigger Greptile

Comment thread src/run_environment/circleci/logger.rs
@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing feat/circleci-run-environment (4e52cfa) with main (97a789a)

Open in CodSpeed

@fargito fargito changed the title [COD-2995] feat(run-environment): add CircleCI provider for GitHub repositories feat(run-environment): add CircleCI provider for GitHub repositories Jul 27, 2026
@fargito
fargito force-pushed the feat/circleci-run-environment branch from f002a69 to bc6db31 Compare July 27, 2026 16:04
Support running benchmarks from CircleCI on GitHub-hosted repositories.
The build runs on CircleCI while commits and pull requests live on GitHub,
so the run reports against the GitHub commit and PR.

Unlike GitHub Actions, CircleCI checks out the associated commit itself
rather than a synthetic merge ref, so the default git HEAD read already
yields CIRCLE_SHA1 and no commit hash override is needed. CircleCI exposes
no base branch variable either: baseRef is left empty and CodSpeed resolves
the base branch from the pull request.

CircleCI also builds Bitbucket and GitLab repositories, so the domain of
CIRCLE_REPOSITORY_URL is validated and anything but github.com is rejected
with an explicit error. That domain is the only signal available at runtime:
the explicit pipeline.project.type is a pipeline value, interpolated when
the config is compiled, so it never reaches the job as a variable.

Uploads authenticate with a static CODSPEED_TOKEN. Run part data is already
reported, so runs group correctly once multi-part upload support lands:
CIRCLE_WORKFLOW_ID is shared by every job and every parallel container of a
workflow, while CIRCLE_JOB and CIRCLE_NODE_INDEX identify a single part.

Refs COD-2977
Refs COD-2995
Refs COD-3262
@fargito
fargito force-pushed the feat/circleci-run-environment branch from bc6db31 to 4e52cfa Compare July 27, 2026 16:12
@fargito
fargito marked this pull request as ready for review July 27, 2026 16:51
@fargito
fargito requested a review from adriencaccia July 27, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant