forked from yc-software/qm
-
Notifications
You must be signed in to change notification settings - Fork 0
259 lines (246 loc) · 8.15 KB
/
Copy pathcicd.yml
File metadata and controls
259 lines (246 loc) · 8.15 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
name: CI/CD
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: cicd-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
core-typecheck:
name: Core typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json
- name: Install and typecheck
run: |
npm ci
npm run typecheck
core-tests:
name: Core tests (${{ matrix.shard }}/5)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json
- name: Install
run: npm ci
- name: Verify root test shard plan
if: matrix.shard == 1
run: npm run test:root:shard:check
- name: Root tests
env:
CORE_TEST_SHARD: ${{ matrix.shard }}/5
run: npm run test:root:shard
core:
name: Core
runs-on: ubuntu-latest
needs:
- core-typecheck
- core-tests
steps:
- name: Core checks passed
run: echo "Core typecheck and root test shards passed."
cli:
name: CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
cli/package-lock.json
package-lock.json
- name: Install, typecheck, unit + packaged-artifact + e2e tests
working-directory: cli
run: |
npm ci
npm run typecheck
npm test
npm run test:e2e
- name: Install root dependencies
run: npm ci
- name: Build the CLI package
working-directory: cli
run: npm run build
- name: Deployment stack contracts
run: |
npm run typecheck:contract
node --test "deploy/stacks/*/test/*.test.ts"
cli-version:
name: CLI version bump
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
fetch-depth: 0
persist-credentials: false
- name: Require a version bump when the published package changes
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
base=$(git merge-base "$BASE_SHA" "$HEAD_SHA")
changed=$(git diff --name-only "$base" "$HEAD_SHA" -- \
cli/bin cli/src cli/templates cli/manifest.json cli/package.json \
cli/package-lock.json cli/README.md cli/LICENSE cli/tsconfig.json cli/tsconfig.build.json)
[ -n "$changed" ] || exit 0
base_version=$(git show "${base}:cli/package.json" | jq -r .version)
head_version=$(git show "${HEAD_SHA}:cli/package.json" | jq -r .version)
highest=$(printf '%s\n%s\n' "$base_version" "$head_version" | sort -V | tail -1)
if [ "$base_version" = "$head_version" ] || [ "$highest" != "$head_version" ]; then
printf '%s\n' "$changed" >&2
echo "these files ship in @yc-software/qm; bump cli/package.json past $base_version" >&2
exit 1
fi
case "$head_version" in
[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "cli/package.json version must be semver, got $head_version" >&2; exit 1 ;;
esac
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
plugins/web-ui/package-lock.json
- name: Install
run: |
npm ci
npm ci --prefix plugins/web-ui
- name: Formatting
run: npm run format:check
- name: Lint whole repo, incl. plugins
run: npm run lint
- name: Dead code (knip)
run: npm run lint:knip
- name: Oxlint
run: npm run lint:ox
core-postgres:
name: Core Postgres tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: qm
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json
- name: Install
run: npm ci
- name: Postgres-backed tests (durability + cross-process)
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/qm
run: npm run test:pg
admin-plugin:
name: Admin plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: plugins/admin/package-lock.json
- name: Install, typecheck, test
working-directory: plugins/admin
run: |
npm ci
npm run typecheck
npm test
- name: Build and boot production image
run: bash scripts/smoke-surface-image.sh admin
web-ui-plugin:
name: Web UI plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
plugins/web-ui/package-lock.json
- name: Install core dependencies
run: npm ci
- name: Install, typecheck, test, build
working-directory: plugins/web-ui
run: |
npm ci
npm run typecheck
npm test
npm run build
- name: Build and boot production image
run: bash scripts/smoke-surface-image.sh web-ui
auth-plugin:
name: Auth plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: plugins/auth/package-lock.json
- name: Install, typecheck, test
working-directory: plugins/auth
run: |
npm ci
npm run typecheck
npm test
- name: Build and boot production image
run: bash scripts/smoke-surface-image.sh auth
portal-plugin:
name: Portal plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: plugins/portal/package-lock.json
- name: Install, typecheck, test
working-directory: plugins/portal
run: |
npm ci
npm run typecheck
npm test
- name: Build and boot production image
run: bash scripts/smoke-surface-image.sh portal