chore(ci): optimise runners, distribute test shards (#4240)

- Use bigger/smaller runners as recommended by warpbuild
- Distribute test shards more evenly, move internal tests single big
shard
This commit is contained in:
Chris Arderne
2026-07-13 15:58:33 +01:00
committed by GitHub
parent 022e5c1ad0
commit 703a6dcb4c
15 changed files with 1605 additions and 1236 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ on:
jobs:
e2eTests:
name: "🧪 E2E Tests: Webapp"
runs-on: warp-ubuntu-latest-x64-8x
runs-on: warp-ubuntu-latest-x64-16x
timeout-minutes: 20
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [warp-ubuntu-latest-x64-4x, warp-windows-latest-x64-4x]
os: [warp-ubuntu-latest-x64-4x, warp-windows-latest-x64-8x]
package-manager: ["npm", "pnpm"]
steps:
- name: ⬇️ Checkout repo
+2 -2
View File
@@ -48,7 +48,7 @@ jobs:
release:
name: 🚀 Release npm packages
runs-on: ubuntu-latest
runs-on: ubuntu-latest # this cannot run on non-GH runner
environment: npm-publish
permissions:
contents: write
@@ -281,7 +281,7 @@ jobs:
# The prerelease job needs to be on the same workflow file due to a limitation related to how npm verifies OIDC claims.
prerelease:
name: 🧪 Prerelease
runs-on: ubuntu-latest
runs-on: ubuntu-latest # this cannot run on non-GH runner
environment: npm-publish
permissions:
contents: read
+1 -1
View File
@@ -8,7 +8,7 @@ permissions:
jobs:
typecheck:
runs-on: warp-ubuntu-latest-x64-8x
runs-on: warp-ubuntu-latest-x64-16x
steps:
- name: ⬇️ Checkout repo
+35 -50
View File
@@ -14,17 +14,14 @@ on:
jobs:
unitTests:
name: "🧪 Unit Tests: Internal"
runs-on: warp-ubuntu-latest-x64-8x
strategy:
# one flaky shard shouldn't cancel its siblings - lets us re-run only the failed shard
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
shardTotal: [12]
# Single big machine instead of a 12-job matrix: the internal suites are serial
# (fileParallelism: false) and container-wait-bound, so 12 in-machine shard processes
# fit comfortably in 32 vCPUs while paying the setup cost (install, prisma generate,
# image pulls) once instead of 12 times.
runs-on: warp-ubuntu-latest-x64-32x
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
SHARD_TOTAL: 12
steps:
- name: 🔧 Disable IPv6
run: |
@@ -108,8 +105,34 @@ jobs:
- name: 📀 Generate Prisma Client
run: pnpm run generate
- name: 🧪 Run Internal Unit Tests
run: pnpm run test:internal --reporter=default --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --passWithNoTests
- name: 🏗️ Build test dependencies
# Build once up-front so the parallel shard runs below (turbo --only) never race
# to build or cache-restore the same outputs concurrently.
run: pnpm exec turbo run build --filter "@internal/*..."
- name: 🧪 Run Internal Unit Tests (${{ env.SHARD_TOTAL }} in-machine shards)
run: |
# Same shard partitioning as the old 12-job matrix (DurationShardingSequencer
# keys off --shard=i/N), but as parallel local processes. --only skips the
# ^build dependency handled by the step above.
status=0
declare -a pids
for i in $(seq 1 "$SHARD_TOTAL"); do
pnpm exec turbo run test --only --concurrency=1 --filter "@internal/*" -- \
--run --reporter=default --reporter=blob --shard="$i/$SHARD_TOTAL" --passWithNoTests \
> "/tmp/internal-shard-$i.log" 2>&1 &
pids[i]=$!
done
for i in $(seq 1 "$SHARD_TOTAL"); do
if ! wait "${pids[i]}"; then
status=1
echo "::error::internal unit test shard $i/$SHARD_TOTAL failed"
fi
echo "::group::🧪 shard $i/$SHARD_TOTAL"
cat "/tmp/internal-shard-$i.log"
echo "::endgroup::"
done
exit "$status"
- name: Gather all reports
if: ${{ !cancelled() }}
@@ -118,44 +141,6 @@ jobs:
find . -type f -path '*/.vitest-reports/blob-*.json' \
-exec bash -c 'src="$1"; basename=$(basename "$src"); pkg=$(dirname "$src" | sed "s|^\./||;s|/\.vitest-reports$||;s|/|_|g"); cp "$src" ".vitest-reports/${pkg}-${basename}"' _ {} \;
- name: Upload blob reports to GitHub Actions Artifacts
- name: 📊 Merge reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: internal-blob-report-${{ matrix.shardIndex }}
path: .vitest-reports/*
include-hidden-files: true
retention-days: 1
merge-reports:
name: "📊 Merge Reports"
if: ${{ !cancelled() }}
needs: [unitTests]
runs-on: warp-ubuntu-latest-x64-2x
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
persist-credentials: false
- name: ⎔ Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: 10.33.2
- name: ⎔ Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22.23.1
# no cache enabled, we're not installing deps
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: .vitest-reports
pattern: internal-blob-report-*
merge-multiple: true
- name: Merge reports
run: pnpm dlx vitest@4.1.7 run --merge-reports --pass-with-no-tests
+8 -3
View File
@@ -14,13 +14,18 @@ on:
jobs:
unitTests:
name: "🧪 Unit Tests: Webapp"
runs-on: warp-ubuntu-latest-x64-8x
# 10 shards on 16x machines: webapp test throughput is limited per-machine (one
# docker daemon + disk absorbing all the per-file Postgres/ClickHouse container
# spin-up), so many machines beats few big ones - fewer/bigger (3x32) measured
# SLOWER than 10x8. The 16x (vs 8x) gives the fork pool the CPU headroom the 8x
# runners lacked. Setup overhead per machine is ~1 min on warm runners.
runs-on: warp-ubuntu-latest-x64-16x
strategy:
# one flaky shard shouldn't cancel its siblings - lets us re-run only the failed shard
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
shardTotal: [12]
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
SHARD_INDEX: ${{ matrix.shardIndex }}