CI Pipeline Implementation Spec¶
Objective¶
Translate policy/checklist into an implementable CI pipeline.
Platform Strategy¶
Use one canonical gate model with two platform variants:
- GitHub Actions: governance/ci_workflow_github_actions.yaml
- GitLab CI: governance/ci_workflow_gitlab_ci.yaml
Select one based on repository host; keep gate logic identical.
Reusable Execution Scripts (Portability Requirement)¶
- Keep executable job logic in
scripts/ci/*.sh. - CI workflow files (
.gitlab-ci.ymlor GitHub Actions YAML) should only orchestrate stages/jobs and call these scripts. - When moving between GitLab and GitHub, reuse the same
scripts/cicommands and only adapt runner syntax and secret wiring.
Required Tools¶
- OpenAPI validator + Spectral
- AsyncAPI validator
- API diff checker for breaking changes
- ReviewGuard
- Policy check runner for
governance/production_enforcement_policy.yaml - Test runner(s)
- Security scanners (SAST/dependency/secret/container)
Pipeline Jobs¶
contracts_validatecontracts_breaking_changebuild_and_unit_testintegration_and_contract_testssecurity_scanssdk_codegen_smokemigration_validationpackage_and_attestdeploy_stagingpromote_prod(manual approval)
Migration Validation Requirements¶
migration_validation must verify both schema creation and deploy-safe forward application:
- fresh apply:
- start a disposable PostgreSQL instance
- apply current
doc/architecture/db_schema_v1.sql - fail on any DDL error
- incremental apply:
- materialize the previous committed
doc/architecture/db_schema_v1.sql - apply that previous schema to a disposable PostgreSQL instance
- apply the current schema on top
- fail on any forward-only ordering or additive-compatibility error
This gate exists to catch deploy regressions that a clean reset cannot see, such as: - creating an index before the referenced column exists on older environments - adding a foreign key before the referenced table/column exists - assuming a fresh-table definition when deploys actually run against an older live table
The reusable implementation lives in scripts/ci/migration_validation.sh, with the local operator entrypoint exposed as make db-migration-smoke.
Execution Tier Model¶
The implementation must expose three execution tiers:
fast- default for ordinary pushes
- always-on baseline:
- contract validation
- build/unit tests
- codegen smoke
-
baseline security scans
-
medium - automatically selected for workflow-sensitive file changes
- typical triggers:
packages/web/**doc/operations/local-dev/**- browser/auth/runtime smoke scripts
- adds:
- browser e2e
- local-dev parity checks
-
targeted integration smokes
-
heavy - schedule-driven or explicit deploy intent
- adds:
- image publish
- environment deploy
- remote validation
- rollback-capable checks
Selection must be automatic:
- use rules:changes to map file changes to medium-tier jobs
- use branch/source rules to map scheduled or deployment pipelines to heavy-tier jobs
- do not require developers to remember which validation tier to invoke manually
Blocking Rules¶
- Jobs 1-8 must pass before staging deploy.
- Promotion to prod requires manual approval + security signoff for high-risk changes.
- Heavy-tier deploy jobs must not block ordinary push pipelines unless the pipeline source or file changes explicitly require them.
Contract Job Requirements¶
- Validate
doc/api/openapi.draft.yaml - Lint
doc/api/openapi.draft.yamlwithdoc/governance/openapi.spectral.yaml - Validate
doc/api/asyncapi.draft.yaml - Enforce contract invariants in
doc/governance/Contract_Invariant_Gates.md - Enforce applicable controls from
doc/governance/production_enforcement_policy.yaml - Fail on undeclared breaking change
PR Gate Requirements¶
- ReviewGuard policy pass
- Compatibility note for contract changes
- ADR reference for architecture-impacting changes
Minimum Artifacts Per Run¶
- Test reports
- Contract validation reports
- Security scan reports
- SBOM + provenance attestation