Repository navigation
366 lines (346 loc) · 12.6 KB
/
Copy pathhub-ci.yml
File metadata and controls
366 lines (346 loc) · 12.6 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
name: Hub CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
defaults:
run:
working-directory: hub
jobs:
changes:
uses: ./.github/workflows/ci-changes.yml
rails_test:
name: Rails tests${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: |
hub/package-lock.json
actions/build/package-lock.json
- run: npm ci --engine-strict
- run: npm ci --ignore-scripts --omit=dev --engine-strict
working-directory: actions/build
- run: ../actions/build/node_modules/.bin/playwright install --with-deps chromium
- run: bundle exec vite build
env:
RAILS_ENV: test
- run: bin/rails db:prepare
env:
RAILS_ENV: test
- run: bin/rails test
env:
RAILS_ENV: test
development_queue:
name: Development queue
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/rails db:prepare
- run: bin/check-development-queue
ruby_lint:
name: Ruby lint
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
env:
RUBOCOP_CACHE_ROOT: tmp/rubocop
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/rubocop -f github
zeitwerk:
name: Zeitwerk
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/rails db:prepare
- run: bin/rails zeitwerk:check
annotations:
name: Annotations
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/rails db:prepare
- run: bin/check-annotations
bundler_audit:
name: Bundler audit
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/bundler-audit check --update
typecheck:
name: TypeScript types${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
- run: npm run typecheck
frontend_lint:
name: Frontend lint${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
- run: npm run lint
frontend_test_shard:
name: Frontend tests shard ${{ matrix.shard }}/4${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ always() }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
shard: [1, 2, 3, 4]
steps:
- name: Require valid suite selection
working-directory: .
env:
SELECTION_RESULT: ${{ needs.changes.result }}
SELECTED: ${{ needs.changes.outputs.hub }}
run: |
test "$SELECTION_RESULT" = success
case "$SELECTED" in
true|false) ;;
*) echo "Invalid Hub suite selection" >&2; exit 1 ;;
esac
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: ${{ needs.changes.outputs.hub == 'true' }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
if: ${{ needs.changes.outputs.hub == 'true' }}
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
if: ${{ needs.changes.outputs.hub == 'true' }}
- run: npm test -- --shard=${{ matrix.shard }}/4
if: ${{ needs.changes.outputs.hub == 'true' }}
frontend_integration_test:
name: Controls and extension tests${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
- run: npm ci --ignore-scripts --omit=dev --engine-strict
working-directory: actions/build
- run: ../actions/build/node_modules/.bin/playwright install --with-deps chromium
- run: npm run controls:test
- name: Test extension with pinned Chromium
run: |
REPLICA_CHROMIUM_PATH="$(node -p 'require("../actions/build/node_modules/playwright").chromium.executablePath()')"
export REPLICA_CHROMIUM_PATH
npm run extension:test
frontend_test:
name: Frontend tests
needs: [changes, frontend_test_shard, frontend_integration_test]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Require all frontend suites to pass
working-directory: .
env:
SELECTION_RESULT: ${{ needs.changes.result }}
SELECTED: ${{ needs.changes.outputs.hub }}
SHARD_RESULT: ${{ needs.frontend_test_shard.result }}
INTEGRATION_RESULT: ${{ needs.frontend_integration_test.result }}
run: |
test "$SELECTION_RESULT" = success
case "$SELECTED" in
true) test "$SHARD_RESULT" = success && test "$INTEGRATION_RESULT" = success ;;
false) test "$SHARD_RESULT" = success && test "$INTEGRATION_RESULT" = skipped ;;
*) echo "Invalid Hub suite selection" >&2; exit 1 ;;
esac
frontend_build:
name: Frontend build${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
- run: npm run build
- run: npm run controls:assets:check
- run: npm run extension:assets:check
storybook_build:
name: Storybook build${{ matrix.node == 26 && ' (Node 26)' || '' }}
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
- run: npm ci --engine-strict
- run: npm run storybook:build
production_database:
name: Production database
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
with:
bundler-cache: true
working-directory: hub
- run: bin/rails db:prepare
env:
RAILS_ENV: production
SECRET_KEY_BASE_DUMMY: "1"
production_image_platform:
name: Production image (${{ matrix.architecture }})
needs: changes
if: ${{ needs.changes.outputs.hub == 'true' }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- architecture: amd64
runner: ubuntu-latest
- architecture: arm64
runner: ubuntu-24.04-arm
env:
IMAGE_PLATFORM: linux/${{ matrix.architecture }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
- run: docker buildx build --platform "$IMAGE_PLATFORM" --build-context learning=../packages/learning --tag replica-hub:ci --load .
- name: Check build-time secret cleanup
run: docker run --platform "$IMAGE_PLATFORM" --rm --entrypoint /bin/sh replica-hub:ci -c 'test ! -e /rails/tmp/local_secret.txt'
- name: Check deployment configuration
run: |
umask 077
docker run --platform "$IMAGE_PLATFORM" --rm replica-hub:ci \
bin/replica-deployment-config generate \
--host hub.example.com \
--format dotenv > deploy/.env
docker compose --file deploy/compose.yml --project-directory deploy config --quiet
- name: Check production startup
timeout-minutes: 3
run: |
docker run --platform "$IMAGE_PLATFORM" --detach --name replica-hub-ci --network none --env-file deploy/.env replica-hub:ci
docker exec replica-hub-ci curl \
--fail --silent --show-error \
--retry 60 --retry-connrefused --retry-delay 2 --retry-max-time 120 --max-time 5 \
http://localhost/up
- name: Clean up production startup check
if: ${{ always() }}
run: |
if docker container inspect replica-hub-ci >/dev/null 2>&1; then
docker logs replica-hub-ci
docker rm --force replica-hub-ci
fi
rm -f deploy/.env
production_image:
name: Production image
needs: [changes, production_image_platform]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Require both production images to pass
working-directory: .
env:
SELECTION_RESULT: ${{ needs.changes.result }}
SELECTED: ${{ needs.changes.outputs.hub }}
IMAGE_RESULT: ${{ needs.production_image_platform.result }}
run: |
test "$SELECTION_RESULT" = success
case "$SELECTED" in
true) test "$IMAGE_RESULT" = success ;;
false) test "$IMAGE_RESULT" = skipped ;;
*) echo "Invalid Hub suite selection" >&2; exit 1 ;;
esac