Repository navigation
179 lines (171 loc) · 6.35 KB
/
Copy pathci.yml
File metadata and controls
179 lines (171 loc) · 6.35 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
name: CI
on:
push:
branches: [main, staging]
pull_request:
workflow_dispatch:
inputs:
update-visual:
description: Regenerate the visual baselines and upload them as an artifact
type: boolean
default: false
concurrency:
group: ci-${{ github.ref }}
# Never cancel a push to main or staging: its release job may be halfway through publishing.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
commits:
name: conventional commits
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- run: bun install --frozen-lockfile
# Every commit lands on staging as is, and a squash merge lands the title instead: both drive the release.
- name: Commits
run: bunx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
- name: PR title
env:
TITLE: ${{ github.event.pull_request.title }}
run: printf '%s\n' "$TITLE" | bunx commitlint --verbose
check:
name: test · typecheck · build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/setup-node@v4
with:
node-version: 24
- run: bun install --frozen-lockfile
- run: bun run test
- run: bun run typecheck
- run: bun run build
- name: CLI smoke (deliver is deterministic)
run: node packages/cli/scripts/smoke.mjs
site:
name: site · test · typecheck · build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/setup-node@v4
with:
node-version: 24
- run: bun install --frozen-lockfile
# build-data needs the viewer template for the delivered-file receipt.
- run: bun run --filter @stackmap/viewer build
- run: bun run --filter @stackmap/site test
- run: bun run --filter @stackmap/site typecheck
- run: bun run --filter @stackmap/site build
- name: Site smoke against the production build
working-directory: site
run: |
bunx playwright install --with-deps chromium
bunx playwright test
- name: Upload site Playwright results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: site-playwright-results
path: site/test-results/
e2e:
name: e2e · visual
runs-on: ubuntu-latest
timeout-minutes: 20
# The same image the visual baselines were generated in, so fonts rasterise identically.
container: mcr.microsoft.com/playwright:v1.63.0-noble
env:
HOME: /root
steps:
- uses: actions/checkout@v4
- run: npm install -g bun@1.3.14
- run: bun install --frozen-lockfile
- run: bun run build
- name: Viewer e2e and visual regression
working-directory: packages/viewer
run: bunx playwright test ${{ inputs.update-visual && '--update-snapshots=all' || '' }}
- name: Delivered-file and live-serve e2e
if: success() || failure()
working-directory: packages/cli
run: bunx playwright test
# Always: a missing baseline is written by Playwright, and this is how it gets back into the repo.
- name: Upload visual snapshots
if: always()
uses: actions/upload-artifact@v4
with:
name: visual-baselines
path: packages/viewer/e2e/visual.spec.ts-snapshots/
- name: Upload Playwright results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-results
path: |
packages/viewer/test-results/
packages/cli/test-results/
release:
name: release
needs: [check, e2e]
# Off until launch: the repository variable RELEASE_ENABLED is set to true once v0.0.0 is tagged and staging exists.
# Without the tag, semantic-release counts every commit and picks 1.0.0.
if: github.event_name == 'push' && vars.RELEASE_ENABLED == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write # tags and the GitHub release
issues: write # release comments on issues
pull-requests: write # and on pull requests
id-token: write # npm trusted publishing (OIDC) and provenance
steps:
# The deploy key pushes the release commit and the back-merge past branch protection.
- uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
# Trusted publishing needs npm 11.5.1+, newer than some Node 24 images bundle.
- run: npm install -g npm@^11.5.1
- run: bun install --frozen-lockfile
# The CLI's prepack bundles the viewer template, which this fresh checkout hasn't built yet.
- run: bun run build
- run: npx --no-install semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
# A release commits its version to main; staging takes it back so the next staging → main merge is clean.
- name: Merge main back into staging
if: github.ref_name == 'main'
run: |
git config user.name "github-actions[bot]"
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git fetch origin main staging
git checkout -B staging origin/staging
git merge --no-ff origin/main -m "chore(release): merge main into staging [skip ci]"
git push origin staging