Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ concurrency:
# ── THE TWO SPEEDS (#22998) ──────────────────────────────────────────────────
# A `pull_request` run carries the FAST SET: `Build Core`, `Test Core`
# (affected-only) and `Build Docs`. A `merge_group` run carries the fast set
# plus the three `dogfood` shards (#30461, ruling record 6663883327, letter B),
# plus the `dogfood` shards (#30461, ruling record 6663883327, letter B),
# whose job alone spells
#
# github.event_name != 'pull_request'
Expand Down Expand Up @@ -1032,9 +1032,11 @@ jobs:
# the longest pole in the whole workflow — and at 2 shards the slower shard
# still ran ~10 min, keeping merge-queue builds at ~11 min end-to-end
# (#4859).
# scripts/partition-test-shards.mjs splits the package list into ten
# deterministic bins balanced on MEASURED per-package test duration
# (scripts/test-shard-timings.json, generated — see #10472 below) and each
# scripts/partition-test-shards.mjs splits the package list into one
# deterministic bin per matrix shard, balanced on MEASURED per-package
# test duration (scripts/test-shard-timings.json, generated — see #10472
# below; a split that carries a file-level slice is placed by modelled
# wall instead, see TWELVE below) and each
# shard runs its slice through turbo. NOT the dogfood
# job's vitest --shard passthrough, deliberately: that works for dogfood
# because it is ONE package with ~60 files, but applied workspace-wide,
Expand Down Expand Up @@ -2964,14 +2966,17 @@ jobs:
pnpm --filter @objectstack/knowledge-pgvector exec vitest run live-postgres

dogfood:
# Sharded 3-way: the suite is ~60 independent test files, each booting its
# Sharded 4-way: the suite is ~60 independent test files, each booting its
# own in-process app; a single 4-vCPU runner needed ~7½ minutes for the
# lot, and at 2 shards each half still ran ~7 min — the longest pole left
# once Test Core went 3-way (#4859). vitest partitions the file list
# deterministically across shards; all shards must pass. The bare
# "Dogfood Regression Gate" context is carried by the dogfood-gate job
# below — the shard count can change without touching it.
name: Dogfood Regression Gate (${{ matrix.shard }}/3)
# below — the shard count can change without touching it. Four since
# #36646: on the merge queue the three shard jobs ran ~18 min each (p50)
# and, after Test Core, set the run's end; a fourth shard cuts each one's
# file list by a quarter.
name: Dogfood Regression Gate (${{ matrix.shard }}/4)
needs: [filter, queue-verdict]
# See THE FILTER CONTRACT on the filter job's outputs (#4928). The queue
# build and the full battery, never a pull request: see THE TWO SPEEDS
Expand All @@ -2988,13 +2993,13 @@ jobs:
contents: read
# Fail-fast on `merge_group` only, as on Test Core (#31517, ruling record
# 6730013883; the reasons are on the `test` job's strategy). Push and
# schedule, the other events this matrix runs on, run all three shards to
# their end. A red shard dominates the matrix result over the siblings it
# schedule, the other events this matrix runs on, run every shard to
# its end. A red shard dominates the matrix result over the siblings it
# cancels, and `Dogfood Regression Gate` reads `failure` as a veto.
strategy:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix:
shard: [1, 2, 3]
shard: [1, 2, 3, 4]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -3141,7 +3146,7 @@ jobs:
# `--summarize` writes `.turbo/runs/<id>.json` and moves no task hash;
# it names the closure's `build` tasks and `dogfood#test` alike, and
# the prune before the seed save keeps exactly those entries.
export OS_TEST_SHARD="${{ matrix.shard }}/3"
export OS_TEST_SHARD="${{ matrix.shard }}/4"
node scripts/run-with-stall-guard.mjs --log "$RUNNER_TEMP/dogfood.log" --stall-minutes 10 \
--report-dir "$RUNNER_TEMP/stall-reports" -- \
pnpm turbo run test --filter=@objectstack/dogfood --summarize --log-order=stream
Expand All @@ -3154,7 +3159,7 @@ jobs:
run: |
node scripts/ci/report-test-leftovers.mjs report \
--before "$RUNNER_TEMP/test-leftovers/before.json" \
--label "Dogfood Regression Gate (${{ matrix.shard }}/3)"
--label "Dogfood Regression Gate (${{ matrix.shard }}/4)"

# Dogfood boots real apps in-process, so a native/OOM abort is likelier
# here than in the unit suites — and a shard that dies silently looks like
Expand Down Expand Up @@ -3194,7 +3199,7 @@ jobs:
id: prune-turbo-cache
if: always() && github.event_name == 'push'
run: |
node scripts/ci/prune-turbo-cache.mjs --site 'Dogfood Regression Gate (${{ matrix.shard }}/3)' \
node scripts/ci/prune-turbo-cache.mjs --site 'Dogfood Regression Gate (${{ matrix.shard }}/4)' \
--cache .turbo/cache --run-summaries .turbo/runs

# Seed the shared Turbo cache from main only (see the restore step
Expand All @@ -3214,14 +3219,14 @@ jobs:
if: needs.queue-verdict.outputs.covered != 'true'
run: |
node scripts/check-shard-attestation.mjs --emit \
--job dogfood --shard ${{ matrix.shard }} --total 3 \
--job dogfood --shard ${{ matrix.shard }} --total 4 \
--out "$RUNNER_TEMP/shard-attestation"

- name: Publish this shard's attestation
if: needs.queue-verdict.outputs.covered != 'true'
uses: actions/upload-artifact@v7
with:
name: shard-attest-dogfood-${{ matrix.shard }}-of-3
name: shard-attest-dogfood-${{ matrix.shard }}-of-4
path: ${{ runner.temp }}/shard-attestation/
if-no-files-found: error
retention-days: 1
Expand Down Expand Up @@ -3313,7 +3318,7 @@ jobs:
# Stable check name for a SHARDED job (#3622 follow-up), a required
# context again since #30461 (THE TWO SPEEDS above `jobs:`). On a PR both
# legs skip and this gate counts zero expected attestations; on a
# queue build (since #30461) the three dogfood shards run and are counted,
# queue build (since #30461) the four dogfood shards run and are counted,
# while `dogfood-verify` skips and is judged with zero expected; the full
# battery runs and counts both. The history below is why the name and the
# `if: always()` stay.
Expand Down Expand Up @@ -3347,7 +3352,7 @@ jobs:
# undocumented `abandoned` that runner starvation produces, in both of
# those runs — either paints a false red or, once whitelisted, swallows a
# sibling's real `failure`. Each of the FOUR legs this context covers
# (3 dogfood shards + the CLI pass) now publishes its own "I ran and
# (4 dogfood shards + the CLI pass) now publishes its own "I ran and
# passed" artifact, and this gate passes only when it counts all four.
#
# `cancelled` still passes without counting, for #3668's reason: it is a
Expand Down Expand Up @@ -3397,8 +3402,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v7

# One pattern covers both legs: `shard-attest-dogfood-*` matches the three
# `…-dogfood-<n>-of-3` shard credentials and `…-dogfood-verify-1-of-1`
# One pattern covers both legs: `shard-attest-dogfood-*` matches the four
# `…-dogfood-<n>-of-4` shard credentials and `…-dogfood-verify-1-of-1`
# alike. See test-gate for why continue-on-error and why no new
# permission is needed.
- name: Download dogfood attestations
Expand Down Expand Up @@ -3426,7 +3431,7 @@ jobs:
--dir "$OS_ATTEST_DIR" \
--filter-result "$OS_FILTER_RESULT" \
--download-outcome "$OS_DOWNLOAD_OUTCOME" \
--leg "dogfood/3:$OS_DOGFOOD_RESULT" \
--leg "dogfood/4:$OS_DOGFOOD_RESULT" \
--leg "dogfood-verify/1:$OS_VERIFY_RESULT"

build-core:
Expand Down
22 changes: 14 additions & 8 deletions scripts/partition-test-shards.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,13 @@ export const PREVIOUS_FILE_SHARDED_PACKAGES = Object.freeze({
// in that unit, 270s x 2.9: the whole-package seconds that take as long on its
// shard as the closure does. Charged anything less, LPT gives that shard back
// most of the whole leg the closure displaces, and it stays the slowest shard
// by the difference; charged this, its shard and the other slice shards come
// out equal in the wall model.
// by the difference; charged this, its shard and the other slice shards came
// out equal in the wall model under partition()'s plain-sum placement. Under
// placeByWall() (#36646), which every split carrying a slice now takes, a
// slice shard carries no whole package while the slice-free shards fit them,
// so nothing is left to give back: the reader slice's shard is the heaviest
// modelled shard, by its closure (wallOfBin() counts the charge / divisor as
// serial wall).
//
// ⛔ Packing weight only: the charge is no test load, so wholeLegProblems()
// (pin 3d) grades the whole legs it moves exactly as before -- the whole
Expand Down Expand Up @@ -1412,12 +1417,13 @@ export function refineToCap(bins, items, cap) {
//
// So a candidate split that CARRIES the reader slice is judged against the cap
// plus that displacement: DECLARATION_CLOSURE_CHARGE_SECONDS / (shardCount - 1),
// 111.86s at 8 shards, 87.00s at 10 (#34710). It is the charge's own arithmetic -- the density the
// closure pin already chose to move -- and nothing else: a split with no reader
// slice (the package whole, a run without it, a document that states its own
// slicing) is judged against the bare cap, and a split denser than the cap plus
// the charge's share is still refused, by name (renderSliceDecision()). A
// one-shard run displaces nothing and is allowed nothing.
// 111.86s at 8 shards, 87.00s at 10 (#34710), 71.18s at 12 (#36646). It is the
// charge's own arithmetic -- the density the closure pin already chose to
// move -- and nothing else: a split with no reader slice (the package whole, a
// run without it, a document that states its own slicing) is judged against
// the bare cap, and a split denser than the cap plus the charge's share is
// still refused, by name (renderSliceDecision()). A one-shard run displaces
// nothing and is allowed nothing.
export function closureAllowance(items, shardCount) {
return shardCount > 1 && items.some((i) => i.closure !== undefined)
? DECLARATION_CLOSURE_CHARGE_SECONDS / (shardCount - 1)
Expand Down
Loading