-
Notifications
You must be signed in to change notification settings - Fork 0
280 lines (261 loc) · 10.7 KB
/
Copy pathvalidate.yml
File metadata and controls
280 lines (261 loc) · 10.7 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: validate
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
# Tanit valida su propio producto. La integración opcional con
# Delendai vive en `.github/workflows/integration-delendai.yml`
# (x00041, x00045): el plugin no entra en `workspaces`, no aparece
# en `files`, y la CI principal no clona Delendai — esa frontera
# es la que x00045 levanta.
#
# x00071: el job monolítico `validate` se rompió en 8 jobs
# paralelos más un `ci-summary`汇总. Un fallo de lint ya no bloquea
# el typecheck, un fallo de typecheck ya no bloquea el security
# audit, etc. Cada job con su propio setup mínimo (checkout +
# setup-bun + install) — la dependencia de bun install en cada
# job cuesta ~30s, pero el wall-clock total cae de ~16 min a
# ~10 min (lo que dura `test-coverage`, el más lento). 8 workers
# simultáneos en GH Actions free tier están dentro del presupuesto
# (20 jobs/hora, 5 jobs concurrentes en free).
env: {}
# Default permissions — explícito porque abajo subimos a `contents: read`
# para los jobs de linting y a `admin:repo` en el workflow de protección.
permissions:
contents: read
jobs:
# ─────────────────── gates principales en paralelo ───────────────────
typecheck:
runs-on: ubuntu-latest
steps:
# `fetch-depth: 0`: el gate `lint:proposals` con x00032 S1
# (regla 2) verifica que cada `shippedIn:` sea un commit
# alcanzable (`git cat-file -e`). El checkout por defecto de
# `actions/checkout` es shallow (profundidad 1), así que en CI
# esos SHAs históricos no existen y el gate daría 100+ falsos
# positivos que en local, con el historial completo, no
# aparecen. x00032.
- uses: actions/checkout@v7
with:
fetch-depth: 0
# Bun 1.4.2: el lockfile del repo es `lockfileVersion: 2`
# (configVersion 1), que Bun 1.3.x NO sabe leer — con
# `--frozen-lockfile` fallaba en "Unknown lockfile version"
# antes de llegar a validate. El pin sube a la versión que
# genera el lockfile local (x00050).
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Typecheck
run: bun run typecheck
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# `bun run lint` encadena 32 sub-gates (lint:naming, lint:paths,
# lint:proposals, lint:tsdoc, …). El más lento es
# lint:proposals con x00032 S1 (verifica cada shippedIn).
- name: Lint
run: bun run lint
test-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# El job más lento de los 8 (~10 min). corre vitest con
# cobertura; los fallos se reportan aquí, no en el ci-summary.
- name: Test with coverage
run: bun run test:coverage
validate-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# `bun run validate:examples` recorre los 22 ejemplos y
# verifica que cada uno produce una colección Postman válida
# sin regresiones. Antes del split, esto iba dentro de
# `validate` y un fallo en un ejemplo tapaba el security
# audit (que ahora es paralelo e independiente).
- name: Validate examples
run: bun run validate:examples
bench-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# El más rápido de los 5 (< 1 min). Confirma que las
# baselines de bench siguen vigentes.
- name: Bench check
run: bun run bench:check
# ─────────────────── gates always-on ───────────────────
# `if: always()` (x00068): corre también si `typecheck`, `lint` o
# cualquier otro job falló. Un fallo de tipos o de tests no debe
# ocultar un HIGH en una dependencia — la superficie de seguridad
# del proyecto tiene que medirse siempre. Antes: este step se
# saltaba si Validate caía, lo que es un agujero claro en la
# política de gates.
security-audit:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# `--audit-level=high` a propósito: un MEDIUM en una dependencia
# de desarrollo no debe bloquear un PR, pero sí tiene que verse.
- name: Security audit
run: bun run security:audit
# Empaqueta, instala en un proyecto limpio y ejecuta el binario.
# Caza lo que el repo no ve: un fichero que falta en `files`, un
# `bin` mal apuntado, un import que se sale del tarball.
#
# `if: always()` (c00006): este job se ejecuta aunque `typecheck`
# o `lint` hayan fallado. `validate:package` diagnostica
# exactamente la clase de bug que escapa a los otros gates (un bin
# mal apuntado, un `files` incompleto) — sin `always()`, GH Actions
# salta el job y el developer se queda sin diagnóstico diferencial
# entre "typecheck rompió" y "el tarball no se puede construir".
validate-package:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Validate package
run: bun run validate:package
# Integration verifier (x00049 S2): las preguntas mecánicas del
# análisis multiagente — paths obsoletos, IDs de propuesta
# duplicados, scripts apuntando a rutas inexistentes, workflows con
# trigger duplicado, lockfile desincronizado. `bun run lint` ya lo
# corre; este job lo ejecuta explícitamente con `--audit` para que
# el reporte aparezca en el log aunque `lint` haya pasado por
# cache o se haya truncado.
#
# `if: always()` (c00006): corre también si los otros gates
# fallaron. El verifier caza residuos cross-cutting que un agente
# pudo dejar al intentar arreglar el fallo que tumbó el pipeline.
integration-verifier:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Integration verifier
run: bun run lint:integration-verifier --audit
# Verifica que la protección de `develop` exige los mismos checks que
# este workflow publica. Si GitHub devuelve una divergencia, el CI falla
# antes de que la rama pueda seguir considerándose protegida.
branch-protection:
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Install dependencies
run: bun install --frozen-lockfile
# `github.token` cannot read branch protection — that needs
# Administration: read, which the default token does not carry. So
# this job failed on every run for lack of permission, and reported
# it as though the protection itself were wrong.
#
# `BRANCH_PROTECTION_TOKEN` is a fine-grained, READ-ONLY token
# scoped to this repository. It is deliberately not an admin token:
# a check that can rewrite the rules it verifies is not a check.
- name: Verify develop branch protection
env:
GITHUB_TOKEN: ${{ secrets.BRANCH_PROTECTION_TOKEN || github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: bun run ci:branch-protection
# ─────────────────── ci-summary ───────────────────
# El汇总 lee `${{ needs.<job>.result }}` de cada job upstream.
# Esos atributos están siempre disponibles, incluso si el job
# upstream falló o se saltó, siempre que ESTE job corra con
# `if: always()`. La tabla del resumen lista los 8 jobs con su
# estado: `success`, `failure`, `cancelled`, `skipped`.
ci-summary:
if: always()
needs:
- typecheck
- lint
- test-coverage
- validate-examples
- bench-check
- security-audit
- validate-package
- integration-verifier
runs-on: ubuntu-latest
steps:
# x00071 split validate into 8 parallel jobs and gave this one the
# verdict, but not the toolchain it needs to render it: the step
# runs `bun run …` on a runner where nothing installed bun, so the
# job died with `bun: command not found` (exit 127) on every run —
# including runs where all eight dependencies reported `success`.
#
# `ci-summary` is the required status check on `develop` AND on
# `main`. A required check that cannot succeed does not protect a
# branch, it closes it. Same shape as the `ci-complete` context
# that no workflow produced.
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Render CI summary and enforce verdict
env:
TYPECHECK_RESULT: ${{ needs.typecheck.result }}
LINT_RESULT: ${{ needs.lint.result }}
TEST_COVERAGE_RESULT: ${{ needs.test-coverage.result }}
VALIDATE_EXAMPLES_RESULT: ${{ needs.validate-examples.result }}
BENCH_CHECK_RESULT: ${{ needs.bench-check.result }}
SECURITY_AUDIT_RESULT: ${{ needs.security-audit.result }}
VALIDATE_PACKAGE_RESULT: ${{ needs.validate-package.result }}
INTEGRATION_VERIFIER_RESULT: ${{ needs.integration-verifier.result }}
run: bun run scripts/gates/ci-summary.script.ts