Pull MinIO from the Gitea-mirrored pgsty image after upstream Hub/Quay removal.
CI / changes (push) Successful in 47s
CI / frontend (push) Skipped
CI / backend (push) Successful in 43m10s

This commit is contained in:
2026-09-30 23:09:01 +08:00
parent 01e1724d6a
commit 1c1065938f
27 changed files with 3533 additions and 3 deletions
+87
View File
@@ -0,0 +1,87 @@
# CICD
Reusable CI/CD practice for every project in this monorepo and the standalone repos
(.NET 8, Node, Vue 3, React, Nuxt, React Native, Python). Platform is Gitea Actions on a
self-hosted runner, images in the Gitea registry, Compose on one VM per environment.
## Start here
**[`platform/observed-state.md`](platform/observed-state.md)** — what this Gitea instance and
runner *actually* do, measured. Every rule in the playbooks below is written against it, and
several rules were wrong until it existed. Re-measure after any Gitea or runner upgrade.
**Adding a project?** → [`onboarding-a-project.md`](onboarding-a-project.md).
**Wondering why something is the way it is?** → [`platform/change-log.md`](platform/change-log.md).
## Which document
| You are… | Read |
| --- | --- |
| Wondering what the runner supports, or whether a rule still holds | [`platform/observed-state.md`](platform/observed-state.md) |
| Reproducing the runner config on a new VM | [`platform/config/runner.yaml`](platform/config/runner.yaml) |
| Fixing slow builds or slow CI | [`ci-cd-build-cache.md`](ci-cd-build-cache.md) |
| Wiring a deploy host, Tailscale deps, or connection strings | [`hybrid-gcp-tailscale-cicd.md`](hybrid-gcp-tailscale-cicd.md) |
| Putting another project on this CI/CD | [`onboarding-a-project.md`](onboarding-a-project.md) |
| Starting CD from scratch, or copying the bake | [`templates/`](templates/) — placeholders only, no product names |
| Asking why a rule exists, or what the platform looked like before | [`platform/change-log.md`](platform/change-log.md) |
| Editing a shared pipeline | [`infra/`](infra/) — staged source for `infra/ci-workflows` |
| Gitea is 504 / the VM is wedged during CD | [Host budget → If Gitea returns 504](platform/observed-state.md#if-gitea-returns-504-during-cd), then [`scripts/runner-host.sh`](scripts/runner-host.sh) |
| Capping the bake so it cannot starve Gitea | [`scripts/cap-buildx-builder.sh`](scripts/cap-buildx-builder.sh) |
| Needing a broker (RabbitMQ) in CI — `services:` will not work | [`scripts/start-job-sidecars.sh`](scripts/start-job-sidecars.sh) + `infra/ci-workflows/.../node-service-ci.yml` |
| Asking which toolchain image built a past release | [Toolchain image log](platform/observed-state.md#toolchain-image-log) |
| Capping BuildKit so CD cannot freeze Gitea | [`scripts/cap-buildx-builder.sh`](scripts/cap-buildx-builder.sh) |
| Reclaiming a wedged runner host (after GCP **Reset** if 504) | [`scripts/runner-host.sh`](scripts/runner-host.sh) |
## Rules that depend on the runner, not on your repo
These changed on 2026-09-28 / 2026-09-29 and will change again. Never copy them from a plan
document — check `platform/observed-state.md`:
| Behaviour | Governed by |
| --- | --- |
| Whether `Host=postgres` resolves in CI | `container.network` |
| Whether jobs run concurrently | `runner.capacity` |
| Whether `actions/cache` does anything | `cache.*` reachability from job containers |
| Whether `--shm-size` reaches a service container | runner version + `container.privileged` |
| Which expressions work (`failure()`, `always()`) | runner version — **not** what the docs say |
| Which toolchain a job gets | `runner.labels` (the label *is* the image) — mirrored and digest-pinned; see the [toolchain log](platform/observed-state.md#toolchain-image-log) |
| Whether a `container.options` flag has any effect | the runner's parser subset — `--memory` was silently ignored on v0.6.1; retest on 4.x |
| Whether a job can write to this Gitea | `GITEA_TOKEN` is injected; the instance is reachable from job containers |
| How many cores a job may use | Host is **e2-standard-2** (2 vCPU / 8 GB); Gitea shares the box — cap **every** test/eval step |
| Whether CD bake leaves Gitea alive | buildkitd cgroup (`cap-buildx-builder.sh`) + one bake target at a time; parallelism=1 alone is not enough |
| Whether CI Postgres is ready | `pg_isready` can pass in crash recovery (`57P03`); tests wait for queries |
| Whether migrate extract works after bake | scratch `migrate-bundle` needs `CMD` + `docker create IMAGE /out/migrate-api` |
## Verifying
[`.gitea/workflows/probe.yml`](../.gitea/workflows/probe.yml) measures the expression, cache, shm, and service-DNS rows. It is
`workflow_dispatch`-only. Run it after any runner or Gitea upgrade and update
`platform/observed-state.md` §5. The `expressions` job fails by design — that is the measurement.
## Standardization status
| Step | State |
| --- | --- |
| Measure the platform | ✅ done — `platform/observed-state.md` |
| Runner config version-controlled | ✅ done — `platform/config/runner.yaml` |
| `ci.yml` uses service DNS, no published DB ports | ✅ done |
| Testhost cap on **every** test/eval step (`DOTNET_PROCESSOR_COUNT=1`) | ✅ done — GrowthOS backend 2026-09-28: build 10m12s (was 20–30 min), unit 4m34s, integration 6m0s green |
| Integration tests wait for Postgres queries (`57P03`) | ✅ done |
| CD bake capped (buildkitd cgroup + one target at a time) | ✅ done — GrowthOS CD 2026-09-29: bake 14m29s, Gitea stayed up; `cap-buildx-builder.sh` |
| Scratch `migrate-bundle` extract (`CMD` + `docker create … /path`) | ✅ done — bare `docker create` failed with `no command specified` after green bake |
| Copy-paste templates carry placeholders, not product names | ✅ done 2026-09-30 — `templates/` replaced `.gitea_example/`, which had `fleet-telemetry` baked into 10+ places |
| `runner.capacity` > 1 | ⬜ blocked — host is e2-standard-2; needs a bigger VM or a second runner |
| Mirror + digest-pin the label image, then `force_pull: false` | ✅ done 2026-09-29 — needs a monthly re-mirror owner |
| Runner → `gitea/runner:4.x` | ✅ done 2026-09-29 — 4.0.0; probe, CI and CD green |
| Artifact actions on `@v4` (both ends together) | ✅ done 2026-09-29 — round trip verified; the v3 pin retired |
| `builtin:checkout` (no Node, no github.com) | ✅ CI + CD green — only the `changes` job stays on `actions/checkout@v4`, pending a `fetch-depth: 0` result |
| Reusable workflows (`workflow_call`) | ✅ done 2026-09-30 — `infra/ci-workflows@v1`; GrowthOS `ci.yml` 267 → 145 lines |
| Onboarding guide for other projects | ✅ done — [`onboarding-a-project.md`](onboarding-a-project.md) |
| Platform change log (initial → current state) | ✅ done — [`platform/change-log.md`](platform/change-log.md) |
| Onboard further projects | ✅ three done 2026-09-30 (fleet-telemetry, pos, inline-inspection). `dotnet8-ci.yml` needed **no new inputs** across all three — the interface generalizes. `node-ci.yml` needed one (`post_build_command`). |
| Fold project-kit improvements back | ✅ done 2026-09-30 — see [`platform/change-log.md`](platform/change-log.md) |
| Shared composite actions (`infra/ci-actions`: capped bake, bundle extract, deploy, smoke) | ⬜ after project two |
| Golden CI base images per stack + label taxonomy | ⬜ |
| Scoped workflows for enforced invariants (Gitea 1.27+) | ⬜ |
| Per-stack templates (Node, Vue, React, Nuxt, RN, Python) | ⬜ |
| Promote ephemeral git VM IP to regional static | ⬜ — avoids DNS redo if Stop is ever used |