ci(codebuild): add linux x64/arm64 oidc status checks - #43
Conversation
Greptile SummaryThis change adds GitHub-triggered AWS CodeBuild checks for Linux x64 and arm64, along with the supporting CodeBuild, IAM, cache, setup, and readiness assets. It should not merge until the CodeBuild submission path no longer lets unapproved same-repository pull requests provide commands that run with mutable shared-cache permissions. The restored Rust build cache should also be preserved so the new checks can reuse compilation artifacts. Confidence Score: 3/5The change is not safe to merge because an unapproved same-repository pull request can submit cache-capable CodeBuild commands. Executed checks confirmed the credentialed pull-request buildspec path and independently confirmed that the install cleanup deletes the restored Rust target cache. Files Needing Attention: .github/workflows/codebuild.yml must stop forwarding pull-request-controlled buildspec content to the cache-capable CodeBuild project. deploy/aws/codebuild/buildspec-ci.yml must retain the restored target cache.
|
Wire GitHub Actions to dedicated CodeBuild projects via OIDC so PR/main CI can run the heavy Linux suite on x64 and arm64 without long-lived keys. Existing workflows stay required; Windows CodeBuild is documented as a follow-up only. Co-authored-by: Mathis <echobt@users.noreply.github.com>
Load the buildspec from the PR base, send pull requests to logs-only NO_CACHE projects, and keep Cargo artifacts in CARGO_TARGET_DIR so a source refresh cannot wipe the restored target cache. Co-authored-by: Mathis <echobt@users.noreply.github.com>
StartBuild no longer runs on pull_request (untrusted workflow file). OIDC trusts only main plus this workflow ref. pull_request_target uses the base buildspec and logs-only *-pr projects. Push to main still uses the cached projects. Co-authored-by: Mathis <echobt@users.noreply.github.com>
The wiring job was pinned to the PR base, so pull_request CI ran main and discovered zero tests. Checkout the PR sha on pull_request; keep the base pin only for pull_request_target and StartBuild. Co-authored-by: Mathis <echobt@users.noreply.github.com>
Coverage instrumentation can delay the first turn so cancel arrives as turn_aborted / interrupted instead of a typed Error event. Co-authored-by: Mathis <echobt@users.noreply.github.com>
3881f5a to
0a377ed
Compare
Summary
Add complete, public-safe AWS CodeBuild CI for Cortex CLI / Cortex Code so PR and
mainLinux jobs can run on dedicated x64 and arm64 CodeBuild projects — the same GitHub Actions → CodeBuild status-check pattern as CortexLM/backend (cortex-gha-x64/cortex-gha-arm64), adapted for this Rust CLI.Marker:
CLI_CODEBUILD_CI_READYExisting workflows are unchanged as merge gates:
ci.yml,release.yml,publish-r2.yml,homebrew.yml,winget.yml,version-bump.yml,test-stability.yml. CodeBuild extends them. Staging/prod app deploy is untouched (prod HOLD). Windows CodeBuild is documented as a follow-up only (not a prod gate).No secrets, PATs, AWS keys, or account IDs are committed. The workflow assumes a role via GitHub OIDC. The role ARN is a repository variable.
Security model (current)
pull_request: wiring only. Checks out the PR head to validate the workflow file. Does not assume OIDC and does not StartBuild.pull_request_target/mainpush: trusted workflow frommain. Buildspec from the PR base (or pushedmainSHA). Head SHA isCORTEX_SOURCE_SHA.repo:CortexLM/cli:ref:refs/heads/mainplusjob_workflow_reffor.github/workflows/codebuild.ymlonmain. Notrepo:…:pull_request.cortex-cli-gha-*-pr— logs-only IAM,NO_CACHE. Cached projects are for trustedmainonly.CARGO_TARGET_DIR=/tmp/cortex-cli-target, outside the cloned source tree.Coverage flake (this revision)
a_second_turn_is_refused_while_one_is_running_and_the_budget_is_enforcedundercargo llvm-cov nextestcan emitmethod: turn_aborted/event.reason: interruptedinstead of a typed Error event. The test now accepts those abort frames.What landed
.github/workflows/codebuild.yml— OIDCStartBuild; postscortex-cli-gha-x64/cortex-cli-gha-arm64commit statuses. Skips StartBuild (and does not post a green status) untilAWS_CODEBUILD_ROLE_ARNis set. Fork PRs stay on GitHub-hostedci.yml.deploy/aws/codebuild/— buildspec, cargo cache paths, CloudFormation, IAM JSON.scripts/readiness/test_codebuild.py— public-safety tests (run by thequalityjob).One-time IAM / OIDC (admin)
Do this once in the AWS account that already hosts backend CodeBuild (reuse the GitHub OIDC provider, not the backend projects). Replace
ACCOUNT_ID/REGIONonly in the console or CLI; never commit them.1. GitHub OIDC provider
token.actions.githubusercontent.comsts.amazonaws.comCreateGithubOidcProvider=trueon the stack).2. Deploy the stack
aws cloudformation deploy \ --stack-name cortex-cli-codebuild \ --template-file deploy/aws/codebuild/cloudformation.yaml \ --capabilities CAPABILITY_NAMED_IAM \ --parameter-overrides \ GitHubOrgRepo=CortexLM/cli \ ProjectNameX64=cortex-cli-gha-x64 \ ProjectNameArm64=cortex-cli-gha-arm64 \ ProjectNameX64Pr=cortex-cli-gha-x64-pr \ ProjectNameArm64Pr=cortex-cli-gha-arm64-pr \ GhaRoleName=cortex-cli-codebuild-gha \ CreateGithubOidcProvider=falseTrust subjects:
repo:CortexLM/cli:ref:refs/heads/mainand thejob_workflow_refforcodebuild.ymlonmain. GHA permissions:codebuild:StartBuild,codebuild:BatchGetBuilds,logs:GetLogEventson the four projects.3. CodeBuild project names
mainproject (S3 cache)cortex-cli-gha-x64cortex-cli-gha-x64(LINUX_CONTAINER,standard:7.0)cortex-cli-gha-x64-prcortex-cli-gha-arm64cortex-cli-gha-arm64(ARM_CONTAINER,amazonlinux-aarch64-standard:3.0)cortex-cli-gha-arm64-prSource type
NO_SOURCE. Cached projects: private S3 cargo cache, 90 minute timeout. PR projects:NO_CACHE, service role cannot touch S3. No R2, WorkOS, or staging/prod secrets.Do not reuse backend projects
cortex-gha-x64/cortex-gha-arm64as the CLI source.4. GitHub repository variables (not secrets)
AWS_CODEBUILD_ROLE_ARNGithubActionsRoleArnstack outputAWS_REGIONus-east-1)AWS_CODEBUILD_PROJECT_X64cortex-cli-gha-x64AWS_CODEBUILD_PROJECT_ARM64cortex-cli-gha-arm64AWS_CODEBUILD_PROJECT_X64_PRcortex-cli-gha-x64-prAWS_CODEBUILD_PROJECT_ARM64_PRcortex-cli-gha-arm64-prDo not add
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY.5. Required checks
After a successful StartBuild on a test PR, add required branch-protection checks
cortex-cli-gha-x64andcortex-cli-gha-arm64in addition to existingci.ymljobs. Until the role variable is set, this PR’s CodeBuild workflow only runs CodeBuild wiring.Full runbook:
deploy/aws/codebuild/README.md.Test plan
python3 -B -m unittest discover -s scripts/readiness -p test_codebuild.py -v3881f5a(18 checks, including changed-line coverage)Attestation (required)
I attest that:
mainworkflow runs. Unprivilegedpull_requestcannot assume the role or StartBuild. Unapproved PRs cannot start cache-capable projects or supply the buildspec. No secrets in git.test_codebuild.pycovers trusted buildspec,*-prprojects, OIDC subjects, and cache-path isolation. StartBuild skip does not post a green status. Exec-runtime abort assertion covers llvm-cov interrupt frames..envfiles are included.Risk
vars.*+ OIDC; CloudFormation uses${AWS::AccountId}only at deploy time.ci.ymlremains the gate.