Repository navigation
819 lines (801 loc) · 37.4 KB
/
Copy pathci.yml
File metadata and controls
819 lines (801 loc) · 37.4 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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
name: ci
# Parallel CI pipeline for Alpha:
# - Precomputes root Quint simulations across 4 LPT-balanced shards at t=0.
# - Warms the pinned Eliza checkout once (`prepare-eliza`), then fans out
# build/typecheck/non-app unit tests, 4x sharded @repo/app unit tests,
# 2x sharded @repo/app browser tests, and lint/analyze/docs concurrently.
# - Consumes sharded simulation and test receipts in `verify` (`check --only`).
# - Gates embedded vibestack tool/example selftests via in-workflow `changes` job
# (never top-level pull_request.paths, keeping required checks safe).
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [main, develop]
push:
branches: [main, develop]
concurrency:
group: ci-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_attempt == '1' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
TURBO_TELEMETRY_DISABLED: "1"
permissions:
contents: read
jobs:
changes:
if: (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
outputs:
selftests: ${{ steps.selftests.outputs.run }}
vibestack: ${{ steps.selftests.outputs.vibestack }}
steps:
- if: github.event_name == 'pull_request' && github.repository != 'lalalune/vibestack'
uses: actions/checkout@v7
with:
fetch-depth: 2
filter: blob:none
sparse-checkout: .github
persist-credentials: false
- id: selftests
env:
DIFF: ${{ github.event_name == 'pull_request' && github.repository != 'lalalune/vibestack' }}
run: |
run=true
vibestack=true
if [[ $DIFF == true ]] && changed=$(git -c core.quotePath=false diff --no-renames --name-only HEAD^1 HEAD); then
if ! awk '
/^"/ || /^(vibestack|\.agents|packages|patches|spec|src|test)\// || /^apps\/[^\/]+\/(package\.json$|spec\/)/ ||
/^\.(codex|cursor)\/hooks\.json$/ || /^\.github\/(workflows\/ci\.yml|actions\/setup\/)/ ||
(/^[^\/]+$/ && (!/\.md$/ || /^(AGENTS|SPEC|README)\.md$/)) { found = 1 }
END { exit !found }' <<< "$changed"; then
run=false
fi
if ! awk '
/^"/ || /^(vibestack|\.agents|patches)\// ||
/^\.github\/(workflows\/ci\.yml|actions\/setup\/)/ ||
/^(package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|turbo\.json|tsconfig.*\.json|\.nvmrc)$/ { found = 1 }
END { exit !found }' <<< "$changed"; then
vibestack=false
fi
fi
echo "run=$run" >> "$GITHUB_OUTPUT"
echo "vibestack=$vibestack" >> "$GITHUB_OUTPUT"
vibestack-precompute-simulations:
if: github.repository != 'lalalune/vibestack' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
name: simulate-${{ matrix.shard }}
permissions:
actions: read
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: simulate-${{ matrix.shard }}
- id: simulation-cache
env:
LOCK_HASH: ${{ hashFiles('.nvmrc', 'pnpm-lock.yaml') }}
SHARD_LAYOUT: ${{ strategy.job-total }}-${{ matrix.shard }}
run: echo "prefix=simulation-shard-v1-$RUNNER_OS-$RUNNER_ARCH-$LOCK_HASH-$SHARD_LAYOUT-" >> "$GITHUB_OUTPUT"
- id: restore-simulation-cache
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: ${{ runner.temp }}/cached-simulation-receipts
key: ${{ steps.simulation-cache.outputs.prefix }}restore
restore-keys: ${{ steps.simulation-cache.outputs.prefix }}
- name: Import receipts from a previous run
if: steps.restore-simulation-cache.outputs.cache-matched-key != ''
continue-on-error: true
env:
SIMULATION_RECEIPTS: ${{ runner.temp }}/cached-simulation-receipts
run: &import-simulation-receipts |
node --input-type=module <<'JS'
import fs from "node:fs";
import path from "node:path";
const source = process.env.SIMULATION_RECEIPTS;
const cache = ".spec-cache";
const candidates = fs.globSync(["*", "simulations-*/*"], { cwd: source })
.filter((file) => /^(?:simulations-\d+\/)?(?:action|simulate)-[a-f0-9]{24}\.json\.(?:zst|gz)$/.test(file) && fs.lstatSync(path.join(source, file)).isFile());
fs.mkdirSync(cache, { recursive: true });
let imported = 0;
for (const [key, files] of Map.groupBy(candidates, (file) => path.basename(file, path.extname(file)))) {
if (["zst", "gz"].some((codec) => fs.lstatSync(path.join(cache, `${key}.${codec}`), { throwIfNoEntry: false }))) continue;
const name = path.basename(files[0]);
const bytes = fs.readFileSync(path.join(source, files[0]));
if (files.slice(1).some((file) => path.basename(file) !== name || !bytes.equals(fs.readFileSync(path.join(source, file))))) {
console.log(`::warning::Shards disagree on ${key}; the ordinary check will recompute it.`);
continue;
}
fs.writeFileSync(path.join(cache, name), bytes, { flag: "wx" });
imported++;
}
console.log(`Imported ${imported} simulation and typecheck receipts.`);
JS
- name: Simulate the specs whose files hash to this shard
id: precompute
env:
SHARD: ${{ matrix.shard }}
SHARDS: ${{ strategy.job-total }}
CACHE_PREFIX: ${{ steps.simulation-cache.outputs.prefix }}
RESTORED_KEY: ${{ steps.restore-simulation-cache.outputs.cache-matched-key }}
GH_TOKEN: ${{ github.token }}
run: |
if [[ $GITHUB_EVENT_NAME == pull_request && -n $GH_TOKEN ]]; then
python3 - <<'PYTHON' &
from collections import defaultdict
from hashlib import sha256
from pathlib import Path
from tempfile import TemporaryDirectory, TemporaryFile
from urllib.error import HTTPError
from urllib.parse import urlencode, urlsplit
from urllib.request import HTTPRedirectHandler, Request, build_opener
from zipfile import BadZipFile, ZipFile
import json
import os
import re
import shutil
import time
class HttpsRedirect(HTTPRedirectHandler):
def redirect_request(self, request, stream, status, message, headers, url):
if urlsplit(url).scheme != "https":
raise ValueError("expected an HTTPS artifact redirect")
return super().redirect_request(request, stream, status, message, headers, url)
def receive():
base = json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text())["pull_request"]["base"]
repository = int(os.environ["GITHUB_REPOSITORY_ID"])
if base["repo"]["id"] != repository:
return
api = f'{os.environ["GITHUB_API_URL"]}/repos/{os.environ["GITHUB_REPOSITORY"]}/actions/'
opener = build_opener(HttpsRedirect())
def get(path, etag=None):
request = Request(api + path, headers={"Accept": "application/vnd.github+json"})
request.add_unredirected_header("Authorization", "Bearer " + os.environ["GH_TOKEN"])
if etag:
request.add_header("If-None-Match", etag)
return opener.open(request, timeout=6)
deadline = time.monotonic() + 3600
traces = Path("gen/traces")
while time.monotonic() < deadline:
time.sleep(30)
if any(child.is_dir() and not child.name.endswith(".ordinary") for child in traces.glob("*")):
break
else:
return
query = urlencode({"branch": base["ref"], "head_sha": base["sha"], "event": "push", "per_page": 1})
with get("workflows/ci.yml/runs?" + query) as response:
runs = json.load(response)["workflow_runs"]
if not runs:
return
run = runs[0]
if (run["event"] != "push" or run["path"] != ".github/workflows/ci.yml" or
run["head_branch"] != base["ref"] or run["head_sha"] != base["sha"] or
run["head_repository"]["id"] != repository or run["repository"]["id"] != repository):
return
source = {"id": run["id"], "repository_id": repository, "head_repository_id": repository,
"head_branch": base["ref"], "head_sha": base["sha"]}
name = "simulations-" + os.environ["SHARD"]
listing = f'runs/{run["id"]}/artifacts?' + urlencode({"name": name, "per_page": 2})
delay = 90
etag = None
run_etag = None
while time.monotonic() < deadline:
try:
with get(listing, etag) as response:
etag = response.headers.get("etag")
delay = max(delay, int(response.headers.get("x-poll-interval", "0")))
artifacts = [item for item in json.load(response)["artifacts"]
if item["name"] == name and not item["expired"] and item["workflow_run"] == source]
except HTTPError as error:
if error.code != 304:
raise
artifacts = []
if len(artifacts) == 1:
break
if not artifacts and run["status"] != "completed":
try:
with get(f'runs/{run["id"]}', run_etag) as response:
run_etag = response.headers.get("etag")
run = json.load(response)
except HTTPError as error:
if error.code != 304:
raise
if artifacts or run["status"] == "completed":
return
time.sleep(delay)
else:
return
artifact = artifacts[0]
with TemporaryFile() as archive:
with get(f'artifacts/{artifact["id"]}/zip') as response:
shutil.copyfileobj(response, archive)
if archive.tell() != artifact["size_in_bytes"]:
return
archive.seek(0)
digest = sha256()
while chunk := archive.read(256 * 1024):
digest.update(chunk)
if "sha256:" + digest.hexdigest() != artifact["digest"]:
return
cache = Path(".spec-cache")
cache.mkdir(exist_ok=True)
with ZipFile(archive) as packed, TemporaryDirectory(dir=cache.parent) as staging:
keys = defaultdict(list)
for member in packed.infolist():
if re.fullmatch(r"(?:action|simulate)-[0-9a-f]{24}\.json\.(?:gz|zst)", member.filename):
keys[member.filename.rsplit(".", 1)[0]].append(member)
count = 0
for key, members in keys.items():
if len(members) != 1 or any(os.path.lexists(cache / (key + suffix)) for suffix in (".gz", ".zst")):
continue
member = members[0]
temporary = Path(staging) / member.filename
with packed.open(member) as src, temporary.open("xb") as dest:
shutil.copyfileobj(src, dest)
try:
os.link(temporary, cache / member.filename)
count += 1
except FileExistsError:
pass
if count:
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
output.write("base-receipts=true\n")
print(f'Imported {count} published receipts from base run {run["id"]}, artifact {artifact["id"]}.', flush=True)
try:
receive()
except (OSError, ValueError, KeyError, TypeError, BadZipFile) as error:
print("Optional base receipt transfer ended:", type(error).__name__, flush=True)
PYTHON
receiver=$!
trap 'kill "$receiver" 2>/dev/null || true; wait "$receiver" 2>/dev/null || true' EXIT
fi
unset GH_TOKEN
node vibestack/spec.ts ci precompute-simulations --shard "$SHARD" --shards "$SHARDS" --out "$RUNNER_TEMP" --github-output "$GITHUB_OUTPUT"
- id: published-simulation-cache
if: ${{ !cancelled() && steps.precompute.outputs.cache-key != '' && steps.precompute.outputs.base-receipts == 'true' }}
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: ${{ runner.temp }}/cached-simulation-receipts
key: ${{ steps.precompute.outputs.cache-key }}
restore-keys: ${{ steps.precompute.outputs.cache-prefix }}
lookup-only: true
- if: ${{ !cancelled() && steps.precompute.outputs.cache-key != '' && steps.published-simulation-cache.outputs.cache-matched-key == '' }}
continue-on-error: true
uses: actions/cache/save@v6
with:
key: ${{ steps.precompute.outputs.cache-key }}
path: ${{ runner.temp }}/cached-simulation-receipts
- if: always() && steps.precompute.outputs.directory != ''
uses: actions/upload-artifact@v7
with:
name: simulations-${{ matrix.shard }}
path: ${{ steps.precompute.outputs.directory }}
compression-level: 0
if-no-files-found: ignore
include-hidden-files: true
retention-days: 1
prepare-eliza:
if: (github.event_name != 'pull_request' || !github.event.pull_request.draft)
name: prepare-eliza
runs-on: ubuntu-latest
environment: &cache-environment ${{ github.event_name == 'push' && 'turbo-cache-publish' || 'turbo-cache-read' }}
env: &cache-env
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_CACHE: ${{ secrets.TURBO_TOKEN != '' && (github.event_name == 'push' && 'local:rw,remote:rw' || 'local:rw,remote:r') || 'local:rw' }}
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: prepare-eliza
verification: "false"
eliza: "true"
skip-prepare: "true"
- run: pnpm eliza
build-and-unit:
name: build-and-unit
needs: [changes, prepare-eliza]
runs-on: ubuntu-latest
environment: *cache-environment
env: *cache-env
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: build-and-unit
verification: "false"
eliza: "true"
playwright: "true"
chromium-mode: shell
- run: pnpm eliza
- name: Build, typecheck, and run non-app unit tests
env:
INCLUDE_VIBESTACK: ${{ needs.changes.outputs.vibestack != 'false' }}
run: |
tasks=(//#no-bun build typecheck @repo/agent#test @repo/cloud#test @repo/deployment#test @repo/eliza-harness#test @repo/site#test @repo/cli#test @repo/ui#test @repo/ui#test:browser)
if [[ $INCLUDE_VIBESTACK == true ]]; then
tasks+=(//#test vibestack-studio#test vibestack-studio#test:browser)
fi
node vibestack/spec.ts tasks "${tasks[@]}" --continue=dependencies-successful --summarize --log-order=stream --concurrency=4
- name: Upload unit test receipts and built workspace outputs for check
if: always()
uses: actions/upload-artifact@v7
with:
name: test-receipts-unit
path: |
.cache/test-result-*.json
apps/*/.cache/test-result-*.json
packages/*/.cache/test-result-*.json
vibestack/studio/.cache/test-result-*.json
apps/*/dist
packages/*/dist
packages/design-system/generated
packages/ui/generated
if-no-files-found: ignore
include-hidden-files: true
retention-days: 1
app-test:
name: app-test-${{ matrix.shard }}
needs: prepare-eliza
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
environment: *cache-environment
env: *cache-env
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: app-test-${{ matrix.shard }}
verification: "false"
eliza: "true"
- run: pnpm eliza
- name: Materialize app test dependencies
run: node vibestack/spec.ts tasks //#gen @repo/agent#build @repo/deployment#build @repo/design-system#build @repo/eliza-harness#build @repo/cloud#build --concurrency=4 --log-order=stream
- name: Run @repo/app node test shard ${{ matrix.shard }}/4
run: pnpm --filter @repo/app exec vitest run --project node --shard=${{ matrix.shard }}/4
- name: Upload shard test receipt
if: success()
uses: actions/upload-artifact@v7
with:
name: test-receipts-app-${{ matrix.shard }}
path: apps/app/.cache/test-result-normal-shard-${{ matrix.shard }}-of-4.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 1
app-test-browser:
name: app-test-browser-${{ matrix.shard }}
needs: prepare-eliza
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2]
environment: *cache-environment
env: *cache-env
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: app-test-browser
verification: "false"
eliza: "true"
playwright: "true"
chromium-mode: shell
- run: pnpm eliza
- name: Materialize app browser test dependencies
run: node vibestack/spec.ts tasks //#gen @repo/deployment#build @repo/design-system#build @repo/eliza-harness#build @repo/ui#gen --concurrency=4 --log-order=stream
- name: Run @repo/app browser test shard ${{ matrix.shard }}/2
run: pnpm --filter @repo/app exec vitest run --project browser --shard=${{ matrix.shard }}/2
lint-and-analyze:
name: lint-and-analyze
needs: prepare-eliza
runs-on: ubuntu-latest
environment: *cache-environment
env: *cache-env
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
with:
job: lint-and-analyze
verification: "false"
eliza: "true"
- run: pnpm eliza
- name: Run lint, static analysis, and docs selftest
run: node vibestack/spec.ts tasks //#lint:js //#lint:css //#analyze //#selftest:docs --continue=dependencies-successful --summarize --log-order=stream --concurrency=4
verify:
name: ${{ matrix.name }}
needs: [changes, vibestack-precompute-simulations, build-and-unit, app-test, app-test-browser, lint-and-analyze]
if: >-
!cancelled() &&
needs.build-and-unit.result == 'success' &&
needs.app-test.result == 'success' &&
needs.app-test-browser.result == 'success' &&
needs.lint-and-analyze.result == 'success'
permissions:
actions: read
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: verify
tasks: //#no-bun build typecheck test test:browser check //#lint:js //#lint:css //#analyze //#selftest:docs
environment: *cache-environment
env: *cache-env
steps: &verification-steps
- uses: actions/checkout@v7
- id: setup
uses: ./.github/actions/setup
with:
job: ${{ matrix.name }}
eliza: ${{ matrix.name == 'verify' && 'true' || 'false' }}
chromium-mode: ${{ matrix.name == 'verify' && 'both' || 'auto' }}
- if: matrix.name == 'verify'
run: pnpm eliza
- id: tool-selftest-cache
if: startsWith(matrix.name, 'selftest-') && (env.TURBO_CACHE == 'local:rw' || github.event_name == 'push')
continue-on-error: true
shell: bash
env:
TASK: ${{ matrix.tasks }}
JOB: ${{ matrix.name }}
run: |
hash=$(node vibestack/spec.ts tasks "$TASK" --only --dry=json --cache=local:w | jq -er --arg task "$TASK" '
.tasks | select(length == 1) | .[0]
| select(.taskId == $task and .resolvedTaskDefinition.cache == true and .resolvedTaskDefinition.outputs == [])
| .hash
')
[[ $hash =~ ^[0-9a-f]{16}$ ]] || exit 0
archive=".turbo/cache/$hash.tar.zst"
meta=".turbo/cache/$hash-meta.json"
if [[ -f $archive && ! -L $archive && -s $archive && -f $meta && ! -L $meta && -s $meta ]] &&
jq -e --arg hash "$hash" '.hash == $hash and (.duration | type == "number" and . >= 0 and floor == .)' "$meta" >/dev/null; then
[[ $GITHUB_EVENT_NAME == push ]] || exit 0
echo 'lookup=true' >> "$GITHUB_OUTPUT"
fi
printf 'hash=%s\nkey=turbo-tool-selftest-v1-%s-%s-%s-%s\n' "$hash" "$RUNNER_OS" "$RUNNER_ARCH" "$JOB" "$hash" >> "$GITHUB_OUTPUT"
- id: restore-tool-selftest
if: steps.tool-selftest-cache.outputs.key != ''
continue-on-error: true
uses: actions/cache/restore@v6
with:
key: ${{ steps.tool-selftest-cache.outputs.key }}
path: |
.turbo/tool-selftest-cache/${{ steps.tool-selftest-cache.outputs.hash }}.tar.zst
.turbo/tool-selftest-cache/${{ steps.tool-selftest-cache.outputs.hash }}-meta.json
lookup-only: ${{ steps.tool-selftest-cache.outputs.lookup == 'true' }}
- if: steps.restore-tool-selftest.outputs.cache-hit == 'true' && steps.tool-selftest-cache.outputs.lookup != 'true'
continue-on-error: true
shell: bash
env:
HASH: ${{ steps.tool-selftest-cache.outputs.hash }}
run: |
archive=".turbo/tool-selftest-cache/$HASH.tar.zst"
meta=".turbo/tool-selftest-cache/$HASH-meta.json"
[[ -f $archive && ! -L $archive && -s $archive && -f $meta && ! -L $meta && -s $meta ]] || exit 0
jq -e --arg hash "$HASH" '.hash == $hash and (.duration | type == "number" and . >= 0 and floor == .)' "$meta" >/dev/null || exit 0
mkdir -p .turbo/cache
rm -f ".turbo/cache/$HASH-manifest.json"
mv "$archive" "$meta" .turbo/cache/
- id: simulations
if: matrix.name == 'verify' && github.repository != 'lalalune/vibestack'
continue-on-error: true
uses: actions/download-artifact@v8
with:
pattern: simulations-*
path: ${{ runner.temp }}/simulation-receipts
- id: import-simulations
if: steps.simulations.outcome == 'success'
continue-on-error: true
env:
SIMULATION_RECEIPTS: ${{ runner.temp }}/simulation-receipts
run: *import-simulation-receipts
- if: steps.simulations.outcome == 'failure' || steps.import-simulations.outcome == 'failure'
run: echo "::warning::The shard receipts were not fully imported; the ordinary check will compute missing results."
- id: unit-receipts
if: matrix.name == 'verify'
continue-on-error: true
uses: actions/download-artifact@v8
with:
name: test-receipts-unit
path: .
- id: app-shard-receipts
if: matrix.name == 'verify'
continue-on-error: true
uses: actions/download-artifact@v8
with:
pattern: test-receipts-app-*
path: apps/app/.cache
merge-multiple: true
- id: verify-tasks
env:
JOB: ${{ matrix.name }}
TASKS: ${{ matrix.tasks }}
INCLUDE_VIBESTACK: ${{ needs.changes.outputs.vibestack != 'false' }}
run: |
if [[ $JOB == verify ]]; then
check_tasks=(//#check)
if [[ $INCLUDE_VIBESTACK == true ]]; then
check_tasks+=(vibestack-studio#check)
fi
node vibestack/spec.ts tasks "${check_tasks[@]}" --only --continue=dependencies-successful --summarize --log-order=stream --concurrency=4
else
read -ra tasks <<< "$TASKS"
options=()
if [[ $JOB == selftest-* ]]; then
options+=(--only)
fi
node vibestack/spec.ts tasks "${tasks[@]}" --continue=dependencies-successful --summarize "${options[@]}"
fi
- id: publish-tool-selftest
if: >-
github.event_name == 'push' && steps.tool-selftest-cache.outputs.key != '' &&
steps.restore-tool-selftest.outputs.cache-hit != 'true'
continue-on-error: true
shell: bash
env:
TASK: ${{ matrix.tasks }}
HASH: ${{ steps.tool-selftest-cache.outputs.hash }}
run: |
jq -e -s --arg task "$TASK" --arg hash "$HASH" '
map(select(.version == "1" and .execution.exitCode == 0 and (.tasks | length == 1)))
| map(.tasks[0] | select(.taskId == $task and .hash == $hash and .execution.exitCode == 0))
| length == 1
' .turbo/runs/*.json >/dev/null || exit 0
archive=".turbo/cache/$HASH.tar.zst"
meta=".turbo/cache/$HASH-meta.json"
[[ -f $archive && ! -L $archive && -s $archive && -f $meta && ! -L $meta && -s $meta ]] || exit 0
jq -e --arg hash "$HASH" '.hash == $hash and (.duration | type == "number" and . >= 0 and floor == .)' "$meta" >/dev/null || exit 0
mkdir -p .turbo/tool-selftest-cache
cp "$archive" "$meta" .turbo/tool-selftest-cache/
echo 'ready=true' >> "$GITHUB_OUTPUT"
- if: steps.publish-tool-selftest.outputs.ready == 'true'
continue-on-error: true
uses: actions/cache/save@v6
with:
key: ${{ steps.tool-selftest-cache.outputs.key }}
path: |
.turbo/tool-selftest-cache/${{ steps.tool-selftest-cache.outputs.hash }}.tar.zst
.turbo/tool-selftest-cache/${{ steps.tool-selftest-cache.outputs.hash }}-meta.json
- name: Report Turbo task timings
id: task-timings
if: ${{ !cancelled() }}
env:
RESTORED_FIXTURE_EVALUATOR: ${{ steps.setup.outputs.spec-evaluator-restored == 'true' && steps.verify-tasks.outcome == 'success' }}
SPEC_INVENTORY: ${{ steps.setup.outputs.spec-cache-inventory }}
TASK: ${{ matrix.tasks }}
run: |
for report in .turbo/runs/*.json; do
[[ -f "$report" ]] || continue
jq -r '
select(.version == "1" and (.tasks | type == "array"))
| .execution as $run
| select([$run.startTime, $run.endTime, $run.cached, $run.attempted] | all(type == "number"))
| "### Turbo task timings", "",
"Wall time \(($run.endTime - $run.startTime) / 1000) s. Cache hits \($run.cached) of \($run.attempted) attempted tasks.",
"",
"| Task | Wall time (s) | Cache | Exit code |",
"| --- | ---: | --- | ---: |",
([.tasks[]
| select([.execution.startTime, .execution.endTime] | all(type == "number"))
| {id: .taskId, elapsed: ((.execution.endTime - .execution.startTime) / 1000), cache: .cache.status, exit: .execution.exitCode}]
| sort_by(-.elapsed) | .[]
| "| \(.id) | \(.elapsed) | \(.cache // "-") | \(.exit // "-") |"),
""
' "$report" >> "$GITHUB_STEP_SUMMARY" || echo "::warning::Could not read the Turbo run summary"
done
if [[ -n $SPEC_INVENTORY && -f $SPEC_INVENTORY ]]; then
after=$(mktemp)
find .spec-cache apps packages vibestack/studio vibestack/examples .cache/selftest \
-path '*/.spec-cache/*.json.*' -type f -printf '%p %s\n' 2>/dev/null | LC_ALL=C sort > "$after" || true
if cmp -s "$SPEC_INVENTORY" "$after"; then
echo 'skip-spec-cache=true' >> "$GITHUB_OUTPUT"
echo 'Skipping unchanged spec cache upload.'
rm -f "$after"
exit 0
fi
rm -f "$after"
fi
[[ $RESTORED_FIXTURE_EVALUATOR == true ]] || exit 0
shopt -s nullglob
reports=(.turbo/runs/*.json)
(( ${#reports[@]} )) || exit 0
jq -es --arg task "$TASK" '
map(select(.version == "1" and any(.tasks[]?; .taskId == $task)))
| length == 1 and
(.[0] | .execution.exitCode == 0 and .execution.attempted == 1 and .execution.cached == 1 and
(.tasks | length == 1 and (.[0] | .taskId == $task and .cache.status == "HIT" and
.execution.exitCode == 0 and .resolvedTaskDefinition.outputs == [])))
' "${reports[@]}" >/dev/null || exit 0
echo 'skip-spec-cache=true' >> "$GITHUB_OUTPUT"
echo 'Skipping the spec cache upload after a full fixture replay.'
- id: superseded-spec-cache
if: >-
cancelled() && matrix.name == 'verify' &&
steps.verify-tasks.conclusion == 'cancelled' &&
steps.setup.outputs.spec-cache-key != '' &&
github.event_name == 'push' && github.run_attempt == '1' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
shell: bash
run: |
current=$(GIT_TERMINAL_PROMPT=0 timeout 4s git ls-remote --refs --exit-code origin "$GITHUB_REF") || exit 0
[[ $current != *$'\n'* ]] || exit 0
IFS=$'\t' read -r tip ref <<< "$current"
[[ $tip =~ ^[0-9a-f]{40}$ && $ref == "$GITHUB_REF" && $tip != "$GITHUB_SHA" ]] || exit 0
echo 'skip=true' >> "$GITHUB_OUTPUT"
echo "Skipping the spec cache upload for superseded commit $GITHUB_SHA."
- id: closed-pr-cache
if: >-
always() && github.event_name == 'pull_request' && github.run_attempt == '1' &&
(steps.setup.outputs.spec-cache-key != '' || steps.setup.outputs.turbo-cache-key != '')
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
[[ -n $GH_TOKEN && $GITHUB_REF =~ ^refs/pull/([1-9][0-9]*)/merge$ ]] || exit 0
number=${BASH_REMATCH[1]}
pull=$(curl --fail --silent --max-time 4 -H "Authorization: Bearer $GH_TOKEN" \
-H 'Accept: application/vnd.github+json' "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/$number") || exit 0
jq -e --argjson number "$number" '
.number == $number and .state == "closed" and (.closed_at | type == "string")
' <<< "$pull" >/dev/null 2>&1 || exit 0
echo 'skip=true' >> "$GITHUB_OUTPUT"
echo "Skipping verification cache uploads for closed PR #$number."
- if: >-
always() && steps.setup.outputs.spec-cache-key != '' &&
steps.superseded-spec-cache.outputs.skip != 'true' && steps.task-timings.outputs.skip-spec-cache != 'true' &&
steps.closed-pr-cache.outputs.skip != 'true'
uses: actions/cache/save@v6
with:
path: ${{ steps.setup.outputs.spec-cache-path }}
key: ${{ steps.setup.outputs.spec-cache-key }}
- id: prune-turbo-cache
if: always() && steps.setup.outputs.turbo-cache-key != '' && steps.closed-pr-cache.outputs.skip != 'true'
shell: bash
env:
FIXTURE_INVENTORY: ${{ steps.setup.outputs.fixture-turbo-inventory }}
FULL_REPLAY: ${{ steps.task-timings.outputs.skip-spec-cache == 'true' }}
run: |
[[ -d .turbo/cache ]] || exit 0
if [[ $FULL_REPLAY == true && -s $FIXTURE_INVENTORY ]] &&
find .turbo/cache -regextype posix-extended \
\( -type f -regex '\.turbo/cache/[0-9a-f]{16}-manifest\.json' \) -prune -o \
\( -type d -printf '%p %y:%m\0' -o -printf '%p %y:%m:%D:%i:%s:%C@\0' \) |
LC_ALL=C sort -z | cmp -s "$FIXTURE_INVENTORY" - &&
expired=$(find .turbo/cache -type f -mtime +7 -print -quit) && [[ -z $expired ]]; then
echo 'Reusing the unchanged pull request Turbo archive after a full fixture replay.'
exit 0
fi
shopt -s nullglob
summaries=(.turbo/runs/*.json)
if (( ${#summaries[@]} )); then
set +o pipefail
jq -r '
.tasks[] | select(.cache.status == "HIT")
| .hash | select(type == "string" and test("^[a-f0-9]{16}$"))
| ".turbo/cache/\(.)" as $entry
| $entry + (".tar.zst", "-meta.json", "-manifest.json")
' "${summaries[@]}" | xargs -r touch -c --
fi
find .turbo/cache -type f -mtime +7 -delete
for archive in .turbo/cache/*.tar.zst; do
metadata="${archive%.tar.zst}-meta.json"
[[ -f "$archive" && -s "$archive" && -f "$metadata" && -s "$metadata" ]] || continue
echo "populated=true" >> "$GITHUB_OUTPUT"
break
done
- if: always() && steps.prune-turbo-cache.outputs.populated == 'true'
uses: actions/cache/save@v6
with:
path: .turbo/cache
key: ${{ steps.setup.outputs.turbo-cache-key }}
- if: always()
uses: actions/upload-artifact@v7
with:
name: proof-${{ matrix.name }}
path: |
gen/proof/
vibestack/studio/gen/proof/
if-no-files-found: ignore
- if: failure()
uses: actions/upload-artifact@v7
with:
name: failures-${{ matrix.name }}
path: |
test/counterexamples/
test/__traces__/
apps/*/test/counterexamples/
apps/*/test/__traces__/
packages/*/test/counterexamples/
packages/*/test/__traces__/
apps/*/.cache/vitest/attachments/
packages/*/.cache/vitest/attachments/
vibestack/studio/test/counterexamples/
vibestack/studio/test/__traces__/
vibestack/examples/*/test/counterexamples/
vibestack/examples/*/test/__traces__/
if-no-files-found: ignore
include-hidden-files: true
vibestack-fixture-selftests:
name: ${{ matrix.name }}
needs: changes
if: ${{ !cancelled() && needs.changes.result == 'success' && needs.changes.outputs.selftests != 'false' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: selftest-a
tasks: //#selftest:tools:a
- name: selftest-b
tasks: //#selftest:tools:b
- name: selftest-c
tasks: //#selftest:tools:c
- name: selftest-rest
tasks: //#selftest:tools:rest
environment: *cache-environment
env: *cache-env
steps: *verification-steps
vibestack-example-selftests:
name: ${{ matrix.name }}
needs: changes
if: ${{ !cancelled() && needs.changes.result == 'success' && needs.changes.outputs.vibestack != 'false' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: examples-assistant
tasks: //#selftest:examples:assistant
- name: examples-dashboard
tasks: //#selftest:examples:dashboard
- name: examples-fullstack
tasks: //#selftest:examples:fullstack
- name: examples-order
tasks: //#selftest:examples:order
environment: *cache-environment
env: *cache-env
steps: *verification-steps
queue-launcher-release:
needs: [verify, vibestack-precompute-simulations, vibestack-fixture-selftests, vibestack-example-selftests]
if: >-
!cancelled() &&
needs.verify.result == 'success' &&
needs.vibestack-precompute-simulations.result == 'success' &&
contains(fromJSON('["success","skipped"]'), needs.vibestack-fixture-selftests.result) &&
contains(fromJSON('["success","skipped"]'), needs.vibestack-example-selftests.result) &&
github.event_name == 'push' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
permissions:
actions: write
steps:
- name: Wait for the Android JVM tests of this commit to pass
env:
GH_TOKEN: ${{ github.token }}
run: |
deadline=$((SECONDS + 7200))
while :; do
found=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow android.yml --commit "$GITHUB_SHA" --event push --json status,conclusion --jq '.[0] | "\(.status) \(.conclusion)"')
case "$found" in
"completed success") exit 0 ;;
completed*) echo "::error::The Android workflow of $GITHUB_SHA ended $found; no release is queued."; exit 1 ;;
esac
if (( SECONDS > deadline )); then
echo "::error::The Android workflow of $GITHUB_SHA did not finish within two hours; no release is queued."
exit 1
fi
sleep 60
done
- name: Queue the versioned release for this successful main CI attempt
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref main \
-f operation=cut -f ci-run="$GITHUB_RUN_ID" -f ci-attempt="$GITHUB_RUN_ATTEMPT"