Skip to content
refs

feat(ci): run CI in the main Worker, with secrets, pull request runs and a job limit

Aman Kumarcommitted Dec 3, 20260a88f14parent 43f8252

- The refs Worker now holds RunHub, JobRunner, JobSlots, the RunPipeline Workflow and the job container. workers/ci and the operator API are removed. - Jobs get the secrets they name under `secrets:`. Organization secrets are new (ci_namespace_secrets). Job output is masked with the values. - Environments use their stored rules: allowed branches, approval, wait timer. - Pull requests start runs when they open and when their head branch moves. - A namespace runs at most 4 jobs at once. - ci_jobs rows follow each job's state. - New python, go, rust and android images. Custom images are refused.

3 decisions

A decision record here could not be read. Line 8: expected "name: value" under rejected.

A decision record here could not be read. Line 7: expected "name: value" under rejected.

A job gets only the secrets it names. An environment secret wins over a repository secret, and a repository secret wins over an organization secret.

Why

  • A job that does not need a secret cannot leak it
  • The nearest owner of a secret is the most specific one

Assumes

  • Runs that agents start or push get no secrets
  • Environment secrets need a person's approval of the job, or a push by a person to a protected branch

Touches

  • job-secrets.ts
  • run-hub.ts
  • parse-pipeline.ts

A manual run gets every secret only on a protected branch. On other branches it gets organization and repository secrets.

Why

  • An agent can write the pipeline file on any branch, and a person who starts that branch must not give it every secret

Touches

  • trust.ts

Each namespace runs at most 4 jobs at the same time. Other jobs wait for a free slot, for at most 2 hours.

Why

  • One namespace must not use all the containers

Assumes

  • One limit fits every namespace until plans differ

Touches

  • job-slots.ts
  • run-pipeline.ts
39 files changed · +590 −320
apps/backend/pushes.ts+5 −6
apps/backend/test/pushes.test.ts+11 −7
apps/ci/config/parse-pipeline.ts+14 −5
apps/ci/config/pipeline.ts+4 −4
apps/ci/index.ts+3 −1
apps/ci/package.json+1 −0
apps/ci/runs/trust.ts+12 −5
apps/ci/runtime/ci-env.ts+4 −1
apps/ci/runtime/ci-service.ts+0 −31
apps/ci/runtime/control.ts+4 −0
apps/ci/runtime/hooks.ts+83 −0
apps/ci/runtime/index.ts+2 −3
apps/ci/runtime/job-runner.ts+7 −4
apps/ci/runtime/job-slots.ts+35 −0
apps/ci/runtime/job-spec.ts+6 −1
apps/ci/runtime/routes.ts+0 −111
apps/ci/runtime/run-hub.ts+110 −36
apps/ci/runtime/run-id.ts+9 −4
apps/ci/runtime/run-pipeline.ts+29 −9
apps/ci/runtime/start-run.ts+58 −27
apps/ci/secrets/job-secrets.ts+64 −0
apps/ci/secrets/secret-box.ts+3 −2
apps/ci/test/pipeline-config.test.ts+9 −3
apps/ci/test/run-lifecycle.test.ts+6 −5
apps/ci/test/secrets.test.ts+29 −2
migrations/0035_ci_secrets_and_pulls.sql+14 −0
worker-configuration.d.ts+0 −0

File too large to display

workers/ci/images/base/Dockerfile+0 −5
workers/ci/images/node/Dockerfile+0 −5
workers/ci/main.ts+0 −8
workers/ci/wrangler.jsonc+0 −32
workers/images/android/Dockerfile+17 −0
workers/images/base/Dockerfile+5 −0
workers/images/go/Dockerfile+5 −0
workers/images/node/Dockerfile+5 −0
workers/images/python/Dockerfile+6 −0
workers/images/rust/Dockerfile+6 −0
workers/main.ts+1 −0
wrangler.jsonc+23 −3