Repository navigation
401 lines (385 loc) · 15.9 KB
/
Copy pathci.yml
File metadata and controls
401 lines (385 loc) · 15.9 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# The branch ruleset requires one check, `build & check`, which is the
# aggregator job at the bottom. No other job may take that name.
jobs:
lint:
name: lint & typecheck
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- name: Lint
run: pnpm lint
- name: Contrast check (packages/docs-theme)
run: pnpm --filter @coder/docs-theme contrast:check
- name: Typecheck
run: pnpm typecheck
build:
name: build & export checks
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- name: Build
run: pnpm build
- name: CSP check (apps/offlinedocs)
run: pnpm --filter @coder/offlinedocs csp:check
- name: Annotations check (apps/offlinedocs)
run: pnpm --filter @coder/offlinedocs annotations:check
- name: Analytics check (apps/offlinedocs)
run: pnpm --filter @coder/offlinedocs analytics:check
- name: CSP check (apps/docs)
run: pnpm --filter @coder/docs-site csp:check
- name: No zod in first-load JavaScript (apps/docs)
run: pnpm --filter @coder/docs-site first-load:check
- name: No API playground code (apps/offlinedocs)
run: pnpm --filter @coder/offlinedocs playground:check
- name: No API playground code (apps/docs)
run: pnpm --filter @coder/docs-site playground:check
- name: URL and anchor parity (apps/docs)
run: pnpm --filter @coder/docs-site parity:urls
e2e-stitch:
name: stitch parity e2e
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
# The e2e runs its own app builds but imports the packages' dist/.
- name: Build packages
run: pnpm turbo run build --filter=@coder/docs-site^...
- name: Stitch parity e2e (apps/docs)
run: pnpm --filter @coder/docs-site test:e2e:stitch
e2e-single:
name: single-version e2e
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
# The e2e runs its own app builds but imports the packages' dist/.
- name: Build packages
run: pnpm turbo run build --filter=@coder/docs-site^...
- name: Single-version e2e (apps/docs)
env:
# Read-only: the release schedule is public, and the job's own token
# only lifts the anonymous rate limit the sync's GitHub fetch shares
# with every other runner.
DOCS_GITHUB_TOKEN: ${{ github.token }}
run: pnpm --filter @coder/docs-site test:e2e:single
a11y:
name: axe accessibility pass
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- name: Build the docs site on the fixture corpus
env:
# The code-server fixture, so the pass scans the product switcher.
DOCS_CODE_SERVER_ROOT: ${{ github.workspace }}/apps/docs/fixtures/code-server
run: pnpm turbo run build --filter=@coder/docs-site
- name: Install Chromium and Firefox
run: pnpm --filter @coder/docs-site exec playwright install --with-deps chromium firefox
- name: axe pass (apps/docs)
run: pnpm --filter @coder/docs-site a11y:axe
- name: Keyboard and focus checks (apps/docs)
if: ${{ !cancelled() }}
run: pnpm --filter @coder/docs-site a11y:keyboard
- name: Raw-anchor fragments in a browser (apps/docs)
if: ${{ !cancelled() }}
run: pnpm --filter @coder/docs-site test:e2e:anchors
# One runner per package. Running the tsx-loaded suites side by side on one
# machine starves them of CPU and they fail whole-file, which is why the
# root `pnpm test` keeps --concurrency=1; separate runners don't contend.
# test-matrix-guard fails if a package with a `test` script is missing here.
test:
name: test (${{ matrix.package }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
package:
- "@coder/dist-release"
- "@coder/docs-build"
- "@coder/docs-config"
- "@coder/docs-manifest"
- "@coder/docs-next"
- "@coder/docs-router"
- "@coder/docs-site"
- "@coder/docs-sources"
- "@coder/docs-theme"
- "@coder/docs-transforms"
- "@coder/docs-ui"
- "@coder/offlinedocs"
env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
# Pinned like actionlint below; with CI set, the secret-scan tests fail without it.
- name: Install gitleaks
if: matrix.package == '@coder/dist-release'
run: |
set -euo pipefail
base="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}"
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
cd "$RUNNER_TEMP"
curl -fsSLO "$base/$tarball"
echo "$GITLEAKS_SHA256 $tarball" | sha256sum -c -
mkdir -p gitleaks-bin
tar -xzf "$tarball" -C gitleaks-bin gitleaks
echo "$RUNNER_TEMP/gitleaks-bin" >> "$GITHUB_PATH"
- name: Test
run: pnpm turbo run test --filter=${{ matrix.package }}
test-matrix-guard:
name: test matrix covers every package
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- name: Compare the matrix with the workspace
run: |
# The root package.json's own `test` runs every package, so skip it.
pnpm ls -r --depth -1 --json | jq -r --arg root "$PWD" '.[].path | select(. != $root)' | while read -r dir; do
jq -r 'select(.scripts.test) | .name' "$dir/package.json"
done | LC_ALL=C sort > with-tests.txt
yq '.jobs.test.strategy.matrix.package[]' .github/workflows/ci.yml | LC_ALL=C sort > in-matrix.txt
if ! diff -u with-tests.txt in-matrix.txt; then
echo "::error file=.github/workflows/ci.yml::The test matrix doesn't match the packages that have a test script (- missing from the matrix, + no longer has tests)."
exit 1
fi
# The version below is coder/coder's toolchain pin; bump it when that moves.
node-22:
name: packages on node 22
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
with:
node-version: 22.23.4
- name: Confirm the job runs on Node 22.23.4
run: test "$(node --version)" = v22.23.4
- name: Build packages
run: pnpm turbo run build --filter='./packages/*'
- name: Test packages
run: pnpm turbo run test --filter='./packages/*' --concurrency=1
- name: Build the offline export on the fixture corpus (apps/offlinedocs)
run: pnpm turbo run build --filter=@coder/offlinedocs
- name: Test the offline export
run: pnpm turbo run test --filter=@coder/offlinedocs
# A pinned release binary rather than a marketplace action or the Docker
# image: the tarball's sha256 is hard-coded here, so a re-pushed tag can't
# change what runs, and actionlint picks up the runner's own shellcheck for
# the run: scripts. Bump the version and the hash together.
actionlint:
name: actionlint
runs-on: ubuntu-latest
timeout-minutes: 5
env:
ACTIONLINT_VERSION: 1.7.12
ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install actionlint
run: |
set -euo pipefail
base="https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}"
tarball="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
cd "$RUNNER_TEMP"
curl -fsSLO "$base/$tarball"
curl -fsSLO "$base/actionlint_${ACTIONLINT_VERSION}_checksums.txt"
grep -qx "$ACTIONLINT_SHA256 $tarball" "actionlint_${ACTIONLINT_VERSION}_checksums.txt"
echo "$ACTIONLINT_SHA256 $tarball" | sha256sum -c -
mkdir -p actionlint-bin
tar -xzf "$tarball" -C actionlint-bin actionlint
- name: Add actionlint to PATH
run: echo "$RUNNER_TEMP/actionlint-bin" >> "$GITHUB_PATH"
- name: Lint the workflows
run: |
set -euo pipefail
# Without shellcheck on PATH, actionlint silently skips the run: scripts.
shellcheck --version
actionlint -color
# Every API code sample must already be what its language's formatter writes.
code-samples-format:
name: code samples format
runs-on: ubuntu-latest
timeout-minutes: 15
env:
RUFF_VERSION: 0.17.2
SHFMT_VERSION: 3.14.1
SHFMT_SHA256: 76e77641faa025814b77f153b29796b8e6fa2fca03e0c76a691608b86c7ea7bf
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: 1.25.x
cache: false
- name: Install ruff
run: pipx install "ruff==${RUFF_VERSION}"
- name: Install shfmt
run: |
set -euo pipefail
binary="shfmt_v${SHFMT_VERSION}_linux_amd64"
mkdir -p "$RUNNER_TEMP/shfmt-bin"
cd "$RUNNER_TEMP/shfmt-bin"
curl -fsSL -o "$binary" "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/$binary"
echo "$SHFMT_SHA256 $binary" | sha256sum -c -
mv "$binary" shfmt
chmod +x shfmt
echo "$RUNNER_TEMP/shfmt-bin" >> "$GITHUB_PATH"
- name: Build the packages
run: pnpm turbo run build --filter='./packages/*'
- name: Check the samples
run: |
set -euo pipefail
go version
ruff --version
shfmt --version
shellcheck --version
pnpm --filter @coder/docs-site samples:format
# The CLI smoke-builds the kit from the packed files alone before packing it.
dist-dry-run:
name: public release dry run
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- name: Install gitleaks
run: |
set -euo pipefail
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
cd "$RUNNER_TEMP"
curl -fsSLO "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/$tarball"
echo "$GITLEAKS_SHA256 $tarball" | sha256sum -c -
tar -xzf "$tarball" gitleaks
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
- name: gitleaks catches a planted secret
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/leak"
printf 'AWS_ACCESS_KEY_ID=%s%s\n' AKIA ABCDEFGHIJKLMNOP > "$RUNNER_TEMP/leak/config.env"
if gitleaks dir --no-banner "$RUNNER_TEMP/leak"; then
echo "::error::gitleaks did not flag the planted secret"
exit 1
fi
- name: Pack, assemble and smoke-test the kit
run: node apps/dist-release/src/cli.mjs build --tag v0.0.0 --out "$RUNNER_TEMP/dist-out"
- name: Scan the unpacked assets
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/unpacked"
for f in "$RUNNER_TEMP"/dist-out/*.tgz; do
d="$RUNNER_TEMP/unpacked/$(basename "$f" .tgz)"
mkdir -p "$d" && tar -xzf "$f" -C "$d"
done
gitleaks dir --no-banner --redact "$RUNNER_TEMP/unpacked"
gitleaks dir --no-banner --redact "$RUNNER_TEMP/dist-out"
# A pin bump fails here rather than in the mainline publish after merge.
# The Coder side is the fixture corpus, so coder/coder's state can't turn this red.
code-server-pin:
name: code-server pin
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup
- name: Read the code-server pin
id: pin
working-directory: apps/docs
run: node scripts/publish/code-server-pin.mjs
# The same inputs as publish-version.yml's checkout of the pin.
- name: Check out the code-server docs at the pinned commit
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: ${{ steps.pin.outputs.repository }}
ref: ${{ steps.pin.outputs.ref }}
path: code-server
sparse-checkout: docs
sparse-checkout-cone-mode: true
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Require the pinned commit on code-server's main
working-directory: apps/docs
env:
CHECKOUT: ${{ github.workspace }}/code-server
run: |
set -euo pipefail
git -C "$CHECKOUT" fetch -q --filter=blob:none origin +refs/heads/main:refs/remotes/origin/main
node scripts/publish/code-server-pin.mjs --check-on-main "$CHECKOUT"
- name: Build packages
run: pnpm turbo run build --filter=@coder/docs-site^...
- name: Sync the pinned docs strictly as the mainline's
working-directory: apps/docs
env:
DOCS_ROOT: ${{ github.workspace }}/apps/docs/fixtures/docs
DOCS_SOURCE_REPO: https://github.com/coder/coder
DOCS_VERSION_ID: "0.2"
DOCS_VERSION_REF: release/0.2
DOCS_VERSION_CHANNEL: mainline
DOCS_VERSION_ROOT: "1"
DOCS_RELEASE_SCHEDULE_FILE: ${{ github.workspace }}/apps/docs/fixtures/release-schedule.json
DOCS_CODE_SERVER_ROOT: ${{ github.workspace }}/code-server/docs
DOCS_CODE_SERVER_REF: ${{ steps.pin.outputs.ref }}
DOCS_CODE_SERVER_REPO: ${{ steps.pin.outputs.repo_url }}
run: pnpm run sync
- name: Test the pinned docs' SEO titles
working-directory: apps/docs
env:
DOCS_CODE_SERVER_ROOT: ${{ github.workspace }}/code-server/docs
run: node --import tsx --test scripts/code-server-seo-titles.test.mjs
check:
name: build & check
if: always()
needs:
[
lint,
build,
e2e-stitch,
e2e-single,
a11y,
test,
test-matrix-guard,
node-22,
actionlint,
dist-dry-run,
code-samples-format,
code-server-pin,
]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# A skipped job passes, so a job can later skip itself when its paths
# didn't change; a failed or cancelled job fails the check.
- name: Require no job to fail or be cancelled
env:
NEEDS: ${{ toJSON(needs) }}
run: |
echo "$NEEDS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
if ! echo "$NEEDS" | jq -e 'all(.[]; .result == "success" or .result == "skipped")' > /dev/null; then
echo "::error::A job this check needs failed or was cancelled."
exit 1
fi