CI/CD Strategy
The Go backend (qubital-backend) runs its checks on GitHub Actions in tiers: cheap checks on every branch push, the full suite on a ready pull request, and a build and deploy on every merge to main. Prod is released by hand through the promote. How the deploy itself works is on the Deployment page.
Pipeline
| When | Workflow | What runs |
|---|---|---|
| Push to a branch, until it has a ready PR | branch-check.yaml | Blocking lint and the short unit tests (-short skips every testcontainers-backed test). About a minute. Docs-only pushes skip it |
| Push to a ready PR | pr-quality-gate.yaml → go-suite.yaml | The Go suite: generated files up to date, vet of the end-to-end tier, blocking lint, every test with -race. This is the merge gate |
PR that changes docker/, the binary build script or go.mod/go.sum | api-image-check.yaml | Builds the api image (not published) and runs an advisory Trivy scan |
PR that changes .github/scripts/, contract/ or the spec | script-tests.yaml | The deploy scripts' tests and the API contract generator |
PR that changes centrifugo/ | centrifugo-image.yaml | A smoke build of the broker image |
Merge to main | build-push-staging.yaml | Re-runs the Go suite unless the merged tree is one the gate passed, builds and pushes the images, deploys staging, publishes the staging API contract when the spec changed |
| By hand | promote-staging-to-prod.yaml | Releases a staging commit to prod (Deployment) |
| Nightly, 04:00 UTC | e2e-staging-nightly.yaml | End-to-end journeys against staging |
| Nightly, 03:00 UTC | ghcr-cleanup.yaml | Keeps the last 15 staging images; never prunes prod or broker images |
go.mod changes on main, weekly | go-cache.yaml | Warms main's Go cache, which branch and PR runs restore |
A draft PR gets the branch check only; marking it ready starts the gate.
Merge to main
- Merged-tree check. A squash merge lands the tested tree only when the branch was up to date with
main. The Go suite runs again on the merged tree before anything is built when the trees differ, when the gate's suite didn't pass on the PR head, or when the push didn't come from a merged PR. A merge that changed only docs since the last successful run is neither re-tested nor deployed. - Build. The api and worker binaries are compiled on the runner (
CGO_ENABLED=0); the Dockerfile only packages them. The broker image is content-addressed (src-<key>overcentrifugo/'s build inputs) and built only when GHCR doesn't have that tag yet. - Deploy staging through
qubital-infra: the broker's digest first when it changed, then the api's, each waiting for verify; then/health.
Why checks sit where they do
- Fast feedback on branches, the full suite once per PR push. The branch check catches broken code within a minute; the expensive suite runs only when a PR is ready.
- Nothing is re-tested after merge when the gate already passed that exact tree. Re-running tests on identical bytes can't give a different answer.
- The prod release re-scans but doesn't re-test. The CVE database changes daily; the tested bytes don't. The promote scans the exact digest it ships, with a fresh database, and blocks on fixable HIGH or CRITICAL findings.
- Images are built once. Prod gets staging's image by digest, never a rebuild.