forked from zitadel/typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
287 lines (270 loc) · 11.8 KB
/
Copy pathci.yml
File metadata and controls
287 lines (270 loc) · 11.8 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
281
282
283
284
285
286
287
name: CI
on:
pull_request: {}
push:
branches: [refactor/auth-ui-rebuild, main]
paths-ignore:
- 'docs/**'
- 'README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
BUN_CACHE: ~/.bun/install/cache
CYPRESS_CACHE_FOLDER: ~/.cache/Cypress
# Each job is self-sufficient: it restores the persistent bun *store* cache
# (~/.bun/install/cache, which survives across runs) and runs its own
# `bun install --frozen-lockfile`. We deliberately do NOT share node_modules
# across jobs — a cache saved by the `install` job is not reliably visible to
# needs-dependent jobs within the SAME run (GitHub Actions same-run cross-job
# cache propagation gap), which previously left every downstream job with no
# deps. With a warm store the per-job install is a few seconds; on a cold miss
# it still produces a correct node_modules (just slower). The `install` job
# warms the store once before the fan-out.
jobs:
install:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
lint:
name: Lint
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- run: bun run lint:ci
typecheck:
name: Type Check
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- run: bun run typecheck
unit-tests:
name: Unit Tests
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- run: bun run test:unit
i18n-check:
name: i18n Catalogs Fresh
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
# Catches commits made with --no-verify that bypass the lefthook i18n hook.
- run: bun run i18n:extract && bun run i18n:compile
env:
CI: '1'
- run: git diff --exit-code -- app/modules/i18n/locales
supply-chain:
name: Supply Chain (audit + SBOM)
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- name: Dependency audit (blocking)
# No advisories are ignored: all known transitive vulns are REMEDIATED via
# package.json `overrides` (each parent's declared range accepts the patched version):
# undici ^7.28.0 jsdom accepts ^7.25.0 fixes 5 undici advisories (2 high)
# form-data ^4.0.6 cypress/axios accept ^4.0.x fixes GHSA-hmw2-7cc7-3qxx (high)
# dompurify ^3.4.11 isomorphic-dompurify accepts ^3.4.8 fixes GHSA-cmwh-pvxp-8882
# esbuild ^0.28.1 vite accepts ^0.28; build + i18n extract verified fixes GHSA-g7r4-m6w7-qqqr / GHSA-gv7w-rqvm-qjhr
# If a NEW transitive advisory appears with no override-compatible fix, add a
# documented `--ignore=<GHSA>` here as a temporary measure and open a remediation follow-up.
run: bun audit
- name: Generate SBOM (CycloneDX)
run: bunx @cyclonedx/cdxgen@11.10.0 -t js -o sbom.cdx.json --spec-version 1.5
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: sbom-cyclonedx
path: sbom.cdx.json
retention-days: 90
build:
name: Build
needs: [lint, typecheck, unit-tests, e2e, i18n-check, supply-chain]
runs-on: ubuntu-latest
if: ${{ !failure() && !cancelled() }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- run: bun run build
- run: bun run size
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: build
key: build-${{ github.sha }}
e2e:
name: E2E (fast, fake provider)
needs: install
runs-on: ubuntu-latest
timeout-minutes: 10
# The dev server validates env at boot; the fake provider only requires a
# SESSION_SECRET (>= 32 chars). This is a throwaway CI value for the in-memory
# fake auth provider — NOT a real secret.
env:
SESSION_SECRET: ci-e2e-fake-provider-dummy-session-secret
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with: { bun-version: 1.3.14 } # renovate: datasource=docker depName=oven/bun
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.BUN_CACHE }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }}
- run: bun install --frozen-lockfile
- run: bunx cypress install
- run: bun run test:e2e:fast
- if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: e2e-artifacts-${{ github.run_id }}
path: |
cypress/videos
cypress/screenshots
retention-days: 7
if-no-files-found: warn
status-check:
name: Final Status Check
needs: [install, lint, typecheck, unit-tests, i18n-check, supply-chain, build, e2e]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check Workflow Status
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
echo "❌ One or more jobs failed"
exit 1
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "⚠️ One or more jobs were cancelled"
exit 1
else
echo "✅ All jobs passed"
fi
publish-container-image:
name: Publish Container Image
needs: [status-check]
if: ${{ github.event_name == 'push' && !failure() && !cancelled() }}
permissions:
id-token: write
contents: read
packages: write
attestations: write
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@545f34cd6f35e9688c9a04a7e890281bcdbaefd2 # v1.14.0
with:
image-name: auth-ui
# NOTE: `secrets: inherit` is required because the upstream workflow
# references `secrets.SENTRY_AUTH_TOKEN` without declaring it under
# `workflow_call.secrets`. Once upstream declares it, switch to an
# explicit `secrets:` block passing only SENTRY_AUTH_TOKEN.
secrets: inherit
publish-kustomize-bundle:
name: Publish Kustomize Bundle
needs: [publish-container-image]
if: ${{ github.event_name == 'push' && !failure() && !cancelled() }}
permissions:
id-token: write
contents: read
packages: write
uses: datum-cloud/actions/.github/workflows/publish-kustomize-bundle.yaml@545f34cd6f35e9688c9a04a7e890281bcdbaefd2 # v1.14.0
with:
bundle-name: ghcr.io/datum-cloud/auth-ui-kustomize
bundle-path: config
image-overlays: config/base
image-name: ghcr.io/datum-cloud/auth-ui
pr-comment:
name: PR Test Summary
needs: [status-check]
runs-on: ubuntu-latest
# Run after the final gate, and even when it fails, so the summary still posts.
if: ${{ always() && github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: write
actions: read
steps:
- name: Build test summary
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const runId = context.runId;
const fs = require('fs');
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
const { data: jobs } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId,
});
const testJobs = jobs.jobs.filter(j =>
j.name === 'Unit Tests' || j.name.startsWith('E2E')
);
const statusEmoji = (c) => {
if (!c || c === 'skipped') return '⏭️';
if (c === 'success') return '✅';
if (c === 'failure') return '❌';
if (c === 'cancelled') return '🚫';
return '❓';
};
let table = '| Job | Status |\n|-----|--------|\n';
for (const job of testJobs.sort((a, b) => a.name.localeCompare(b.name))) {
table += `| ${job.name} | ${statusEmoji(job.conclusion)} ${job.conclusion || 'pending'} |\n`;
}
let body = `## 🧪 Test Summary\n\n${table}\n\n[View workflow run](${runUrl})`;
fs.writeFileSync('pr-summary.md', body);
- uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: pr-summary.md
edit-mode: replace