Skip to content
refs

feat(ci): run CI pipelines on Cloudflare containers, started by pushes

Amancommitted Dec 3, 202643f8252parent 6dfeede

Add CI/CD as a refs feature. A repo puts its pipeline in .refs/ci.yml. A push to a branch that the pipeline names starts a run. Each job runs in its own container. RunHub holds the run state and the masked logs. Jobs in an environment wait for a person to approve them. - apps/ci: the config parser, the job graph, the run state machine, trust, environment gates, the secret box and the log masker (pure, tested). - apps/ci/runtime and workers/ci: the refs-ci Worker. It has the RunPipeline Workflow, the RunHub and JobRunner Durable Objects, the base and node images, an operator API, and the CiService entry for pushes. - The main Worker calls CiService after it processes a push. - Migration 0034 adds the ci_* tables. RunHub copies the run state to ci_runs. Not done yet: secrets in jobs, pull request runs, the per-namespace job limit, custom and Android images, ci_jobs rows, and the UI.

1 decision

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

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

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

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

RunHub.advance also returns approved jobs that are queued, and Run.advance does not.

Why

  • Only the Workflow calls RunHub.advance, and only when no job is in flight
  • Run.advance keeps its rule that it never returns a queued job twice

Paths considered

  1. Chosen
  2. Return every queued job from Run.advance
  3. Run.advanceIt breaks the tested rule for callers that call it while jobs run.

Touches

  • run-hub.ts
38 files changed · +2207 −1
apps/backend/package.json+1 −0
apps/backend/pushes.ts+13 −0
apps/backend/test/pushes.test.ts+18 −1
apps/ci/config/branch-pattern.ts+27 −0
apps/ci/config/job-graph.ts+64 −0
apps/ci/config/parse-pipeline.ts+201 −0
apps/ci/config/pipeline.ts+59 −0
apps/ci/index.ts+10 −0
apps/ci/logs/log-masker.ts+55 −0
apps/ci/package.json+12 −0
apps/ci/runs/environment-gate.ts+30 −0
apps/ci/runs/run.ts+154 −0
apps/ci/runs/states.ts+56 −0
apps/ci/runs/trust.ts+46 −0
apps/ci/runtime/ci-env.ts+12 −0
apps/ci/runtime/ci-service.ts+31 −0
apps/ci/runtime/index.ts+6 −0
apps/ci/runtime/job-runner.ts+122 −0
apps/ci/runtime/job-spec.ts+23 −0
apps/ci/runtime/log-batcher.ts+43 −0
apps/ci/runtime/routes.ts+111 −0
apps/ci/runtime/run-hub.ts+255 −0
apps/ci/runtime/run-id.ts+21 −0
apps/ci/runtime/run-pipeline.ts+69 −0
apps/ci/runtime/start-run.ts+89 −0
apps/ci/secrets/secret-box.ts+100 −0
apps/ci/test/pipeline-config.test.ts+144 −0
apps/ci/test/run-lifecycle.test.ts+153 −0
apps/ci/test/runtime-helpers.test.ts+55 −0
apps/ci/test/secrets.test.ts+71 −0
migrations/0034_ci.sql+79 −0
package-lock.json+26 −0
worker-configuration.d.ts+0 −0

File too large to display

workers/ci/images/base/Dockerfile+5 −0
workers/ci/images/node/Dockerfile+5 −0
workers/ci/main.ts+8 −0
workers/ci/wrangler.jsonc+32 −0
wrangler.jsonc+1 −0