forked from zitadel/typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
284 lines (268 loc) · 10.7 KB
/
Copy pathci.yml
File metadata and controls
284 lines (268 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
281
282
283
284
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
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
id: cache-deps
with:
path: |
${{ env.BUN_CACHE }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- if: steps.cache-deps.outputs.cache-hit != 'true'
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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- 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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- 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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- 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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
# 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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- name: Dependency audit (blocking)
# All ignored advisories are dev/build-only — they never ship (the Dockerfile
# installs --production). Runtime advisories (js-yaml, @opentelemetry/core) were
# fixed via dependency bumps, so none are ignored here.
# GHSA-hmw2-7cc7-3qxx form-data <- cypress, start-server-and-test (dev)
# GHSA-gv7w-rqvm-qjhr esbuild <- @lingui/cli, vite (build)
# GHSA-g7r4-m6w7-qqqr esbuild <- @lingui/cli, vite (build)
run: >-
bun audit
--ignore=GHSA-hmw2-7cc7-3qxx
--ignore=GHSA-gv7w-rqvm-qjhr
--ignore=GHSA-g7r4-m6w7-qqqr
- 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]
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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- 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
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 }}
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock', '**/package.json') }}
- 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: [unit-tests, e2e]
runs-on: ubuntu-latest
if: 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