-
-
Notifications
You must be signed in to change notification settings - Fork 17
463 lines (386 loc) · 15.5 KB
/
Copy pathci.yml
File metadata and controls
463 lines (386 loc) · 15.5 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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install dependencies
run: bun install --frozen-lockfile
# After the install: the bunfig preload resolves @stacksjs/env, so
# anything invoking `bun` before node_modules exists dies with
# `preload not found`. Only bites a project resolving the framework from
# npm rather than a vendored storage/framework/core, but the ordering is
# wrong either way.
- name: Check lockfile version
run: bun .github/scripts/check-lockfile-version.ts
- name: Check dependency state
env:
DEPENDENCY_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
DEPENDENCY_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: bun .github/scripts/check-dependency-commits.ts
- name: Lint
run: bun buddy lint
typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Typecheck
run: bun run typecheck
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- 3306:3306
dynamodb:
image: amazon/dynamodb-local
ports:
- 8000:8000
redis:
image: redis:8
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
id: install
run: bun install --frozen-lockfile
- name: Test Suite
env:
AWS_DYNAMODB_ENDPOINT: http://localhost:8000
run: bun run test
# `bun run test` shells out to `buddy test`, which only globs
# <project>/tests/**, so nothing under storage/framework/core/**/tests
# has ever run in CI. The database bootstrap gates every `buddy migrate`
# on every server-backed project, so its suite runs explicitly here.
# Scoped to one file on purpose: wiring up the core suites wholesale
# needs the pre-existing failures in them triaged first.
# `bun run test` shells out to `buddy test`, which only globs
# <project>/tests/**, so nothing under storage/framework/core/**/tests has
# ever run in CI. These five suites are green and cover ~945 tests.
#
# One suite per step, not one command: `bun test` over all 81 core suites
# at once crashes the runtime, and separate steps also mean a failure
# names the package instead of one opaque red block.
#
# `actions` and `queue` each still have one pre-existing failure, so they
# are deliberately not wired yet rather than being left red.
# The whole database and router directories are NOT wired. Both pass on
# macOS and fail on Linux, which is exactly why this coverage was worth
# adding, but neither is a quick fix:
# database: 425 pass / 4 fail, sqlite-pragmas hits
# `RangeError: Cannot use a closed database`. A cross-file isolation
# bug that macOS file ordering hides; it does not reproduce locally
# when those two files are paired.
# router: 114 pass / 143 fail, every failure at exactly 10000.01ms,
# so the suite hangs on Linux rather than failing. Needs its own look.
# The database files below are the ones this work added or verified.
- name: Core tests (database bootstrap)
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: |
bun test storage/framework/core/database/tests/ensure-database.test.ts
bun test storage/framework/core/database/tests/committed-migrations-dialect.test.ts
bun test storage/framework/core/database/tests/model-sources.test.ts
bun test storage/framework/core/database/tests/emitted-migration-execution.test.ts
- name: Core tests (buddy)
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun test storage/framework/core/buddy/tests
- name: Core tests (cli)
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun test storage/framework/core/cli/tests
- name: Core tests (api)
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun test storage/framework/core/api/tests
- name: Core tests (release pre-flight)
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun test storage/framework/core/actions/tests/release-preflight.test.ts
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install --frozen-lockfile
# The release job resolves through `pantry/`, not `node_modules`, and the
# two lockfiles pin different versions — the first attempt at this check
# passed here while the release still failed on a package `pantry.lock`
# held back. So this installs the same tree the release does.
- name: Install the pantry tree
run: pantry install
# The binaries are built only by the release job, on a tag, after npm
# publish. So a dependency that grows a top-level await — which
# `bun build --compile` refuses to bundle through a `require()` — took
# three releases to notice: the packages published, the compile failed,
# and nobody looked. One target here is enough to catch that, and it is
# the cheap half of `compile:all`.
- name: Compile the buddy binary
run: |
cd storage/framework/core/buddy
bun run compile:linux-x64
protocol-conformance:
runs-on: ubuntu-latest
services:
redis:
image: redis:8
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
id: install
run: bun install --frozen-lockfile
# One step per check, rather than one `run:` block running all ten.
#
# Two things were wrong with the block. Under `bash -e` the first failure
# ended it, so a red `docs:artifacts:check` (ninth) meant
# `docs:links:check` (tenth) never executed at all — it has never run on
# main. And a failure surfaced only as "Verify pinned protocol suite",
# so finding out WHICH check failed meant grepping the raw log.
#
# `!cancelled()` is what actually fixes the masking: without it Actions
# skips every later step once one fails, which is the same bug in a new
# costume. The install guard keeps the ten from all failing noisily when
# the real problem is that dependencies did not install.
- name: protocol:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:check
- name: protocol:manifest:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:manifest:check
- name: protocol:release:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:release:check
- name: protocol:drivers:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:drivers:check
- name: protocol:desktop:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:desktop:check
- name: protocol:pantry:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:pantry:check
- name: protocol:craft:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run protocol:craft:check
- name: docs:buddy:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run docs:buddy:check
- name: docs:artifacts:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run docs:artifacts:check
- name: docs:links:check
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
run: bun run docs:links:check
- name: Run protocol adapter
env:
PROTOCOL_REPORT_DIR: .github/protocol/reports
run: |
bun test ./storage/framework/core/buddy/src/commands/protocol/run-conformance.test.ts
bun test ./storage/framework/core/buddy/src/commands/protocol/craft-evidence.test.ts ./storage/framework/core/buddy/src/commands/protocol/desktop-lifecycle-report.test.ts
bun test ./.github/scripts/deploy/resolve-target.test.ts
bun run protocol:drivers:test
bun run protocol:conformance
cat .github/protocol/reports/driver-matrix.md >> "$GITHUB_STEP_SUMMARY"
cat .github/protocol/reports/stacks-conformance.md >> "$GITHUB_STEP_SUMMARY"
- name: Retain attributable conformance report
uses: actions/upload-artifact@v7
with:
name: stacks-protocol-conformance-${{ github.sha }}
path: .github/protocol/reports/
if-no-files-found: error
deployment-target:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.target.outputs.environment }}
flag: ${{ steps.target.outputs.flag }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Resolve provisioned deployment target
id: target
run: bun .github/scripts/deploy/resolve-target.ts --ref "$GITHUB_REF" --github-output "$GITHUB_OUTPUT"
deploy:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: [lint, typecheck, test, compile, protocol-conformance, deployment-target]
runs-on: ubuntu-latest
timeout-minutes: 30
environment:
name: ${{ needs.deployment-target.outputs.environment }}
permissions:
contents: read
deployments: write
id-token: write
env:
DEPLOY_ENVIRONMENT: ${{ needs.deployment-target.outputs.environment }}
DEPLOY_FLAG: ${{ needs.deployment-target.outputs.flag }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Prepare Deploy SSH Key
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
if [ -z "$DEPLOY_SSH_KEY" ]; then
echo "No deploy SSH key configured; continuing without one."
exit 0
fi
mkdir -p ~/.ssh
chmod 700 ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub
chmod 644 ~/.ssh/id_ed25519.pub
- name: Deploy ${{ env.DEPLOY_ENVIRONMENT }}
run: ./buddy deploy "$DEPLOY_FLAG" --yes
env:
APP_ENV: ${{ env.DEPLOY_ENVIRONMENT }}
DOTENV_PRIVATE_KEY_PRODUCTION: ${{ secrets.DOTENV_PRIVATE_KEY_PRODUCTION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COPYFILE_DISABLE: '1'
publish-commit:
if: github.event_name == 'pull_request'
needs: [lint, typecheck, test, compile, protocol-conformance]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Pantry
uses: pantry-pm/pantry/packages/action@8826c8e3a511995aa0e70a6f0c8b4289f751fa96 # v0.10.50
with:
version: '0.10.50'
install: 'false'
- name: Use cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build
- name: Publish Commit
run: ./storage/framework/scripts/publish-commit