Repository navigation
183 lines (172 loc) · 6.67 KB
/
Copy pathci.yml
File metadata and controls
183 lines (172 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# CI orchestrator (structured like a pipeline graph, not a monolith):
#
# changes ─┬─ security (_security.yml) always on
# ├─ backend (_backend.yml) gated by path filter
# ├─ frontend (_frontend.yml) gated by path filter
# ├─ contract (_contract.yml) gated by path filter
# └─ docker (_docker.yml) gated by path filter
# └────── ci-ok ── single stable required context
#
# Extension rules:
# - A new gate is a new `_name.yml` reusable workflow plus one calling job
# here and one entry in `ci-ok.needs`. Branch protection never changes:
# it only ever requires `ci-ok`.
# - Path filters live only in this file; reusable workflows stay unconditioned.
# - Skipped stages count as green in `ci-ok` (docs/CI-only PRs must not wedge
# merges), but the `changes` job itself must succeed outright.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
# --- Which areas changed? Each heavier gate keys off these outputs. ---
changes:
name: Detect Changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
backend: ${{ steps.filter.outputs.backend }}
console: ${{ steps.filter.outputs.console }}
management: ${{ steps.filter.outputs.management }}
docker: ${{ steps.filter.outputs.docker }}
contract: ${{ steps.filter.outputs.contract }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4
with:
filters: |
backend:
- 'services/**'
- 'init-db/**'
- 'scripts/**'
- 'docker/redis/**'
# Docker topology and observability changes must also exercise
# the backend workflow's dynamic infrastructure contracts.
- 'docker/docker-compose*.yml'
- 'infrastructure/observability/**'
- 'infrastructure/nginx/**'
- '.github/workflows/ci.yml'
- '.github/workflows/_backend.yml'
- '.github/services-matrix.json'
console:
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'apps/console/**'
- 'packages/**'
- 'shared/**'
- '.github/workflows/ci.yml'
- '.github/workflows/_frontend.yml'
management:
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'apps/management/**'
- 'packages/**'
- 'shared/**'
- '.github/workflows/ci.yml'
- '.github/workflows/_frontend.yml'
contract:
- 'services/api/**'
- 'services/pom.xml'
- 'services/docs/CONTRACT_COMPAT_GATE.md'
- 'scripts/test/api-contract-boundary-contract.sh'
- 'scripts/test/dubbo-provider-reference-contract.sh'
- 'scripts/test/submission-compatibility-retirement-contract.sh'
- '.github/workflows/ci.yml'
- '.github/workflows/_contract.yml'
docker:
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'services/**'
- 'apps/console/Dockerfile'
- 'apps/management/Dockerfile'
- 'docker/docker-compose*.yml'
- 'infrastructure/observability/**'
- 'docker/prometheus/**'
- 'services/docs/OBSERVABILITY_RUNBOOK.md'
- '.github/actions/**'
- '.github/workflows/docker-publish.yml'
- '.github/workflows/cd-deploy.yml'
- '.github/workflows/cd-rollback.yml'
- 'scripts/runbooks/image-reference-policy.sh'
- 'scripts/test/supply-chain-contract.sh'
- 'scripts/runbooks/deployment-integrity.sh'
- 'scripts/test/deployment-integrity-contract.sh'
- '.dockerignore'
- 'apps/console/nginx.conf'
- 'apps/management/nginx.conf'
- 'infrastructure/nginx/**'
- '.github/workflows/ci.yml'
- '.github/workflows/_docker.yml'
- '.github/services-matrix.json'
# --- Security: runs on every change set, independent of area gates. ---
security:
name: Security Gate
needs: changes
if: ${{ !cancelled() && needs.changes.result == 'success' }}
uses: ./.github/workflows/_security.yml
secrets: inherit
# --- Backend gates ---
backend:
name: Backend
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.backend == 'true' }}
uses: ./.github/workflows/_backend.yml
secrets: inherit
# --- Frontend gates (either app or shared packages) ---
frontend:
name: Frontend
needs: changes
if: ${{ !cancelled() && (needs.changes.outputs.console == 'true' || needs.changes.outputs.management == 'true') }}
uses: ./.github/workflows/_frontend.yml
with:
console_changed: ${{ needs.changes.outputs.console == 'true' }}
management_changed: ${{ needs.changes.outputs.management == 'true' }}
secrets: inherit
# --- Contract compatibility gate ---
contract:
name: Contract Compatibility
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.contract == 'true' }}
uses: ./.github/workflows/_contract.yml
secrets: inherit
# --- Docker build verification ---
docker:
name: Docker Verify
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.docker == 'true' }}
uses: ./.github/workflows/_docker.yml
secrets: inherit
# --- The one summary context for branch protection. Fails unless every
# stage succeeded; `skipped` is fine because stages are path-gated. ---
ci-ok:
name: ci-ok
needs: [changes, security, backend, frontend, contract, docker]
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: All CI stages must have succeeded (or been skipped)
env:
RESULTS: ${{ toJSON(needs) }}
run: |
echo "$RESULTS" | jq .
jq -e '
.changes.result == "success"
and ([to_entries[] | select(.key != "changes") | .value.result]
| all(. == "success" or . == "skipped"))
' <<< "$RESULTS" > /dev/null