Skip to content

Commit d760741

Browse files
committed
perf(ci): rebalance webapp test shards
1 parent a302f65 commit d760741

3 files changed

Lines changed: 611 additions & 298 deletions

File tree

.github/workflows/e2e-webapp.yml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
version: 10.33.2
5858

5959
- name: ⎔ Setup node
60-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
60+
uses: WarpBuilds/setup-node@bc639b444d583175926b588962199c247d23e8d3 # v6
6161
with:
6262
node-version: 24.18.0
6363
cache: "pnpm"
@@ -73,18 +73,52 @@ jobs:
7373
if: ${{ !env.DOCKERHUB_USERNAME }}
7474
run: echo "DockerHub login skipped because secrets are not available."
7575

76-
- name: 🐳 Pre-pull testcontainer images
76+
- name: 📥 Prepare deps and testcontainer images
7777
run: |
78-
echo "Pre-pulling Docker images with authenticated session..."
79-
docker pull postgres:14
80-
docker pull redis:7.2
81-
docker pull testcontainers/ryuk:0.14.0
82-
docker pull ghcr.io/s2-streamstore/s2:0.40.0@sha256:b26249e2ede0949755f5af8028185dc2bcfc3aa2db21eb9610543d144eb6ee9d
83-
docker pull minio/minio:latest
84-
echo "Image pre-pull complete"
85-
86-
- name: 📥 Download deps
87-
run: pnpm install --frozen-lockfile
78+
# Pull images concurrently with dependency installation. Retry each pull because
79+
# registry timeouts are a recurring transient CI flake.
80+
pull() {
81+
for attempt in 1 2 3; do
82+
docker pull "$1" && return 0
83+
echo "::warning::docker pull $1 failed (attempt ${attempt}/3); retrying in 10s"
84+
sleep 10
85+
done
86+
echo "::error::docker pull $1 failed after 3 attempts"
87+
return 1
88+
}
89+
90+
pull_images() {
91+
local pids=()
92+
local failed=0
93+
for image in \
94+
postgres:14 \
95+
redis:7.2 \
96+
testcontainers/ryuk:0.14.0 \
97+
ghcr.io/s2-streamstore/s2:0.40.0@sha256:b26249e2ede0949755f5af8028185dc2bcfc3aa2db21eb9610543d144eb6ee9d \
98+
minio/minio:latest
99+
do
100+
pull "$image" &
101+
pids+=("$!")
102+
done
103+
for pid in "${pids[@]}"; do
104+
if ! wait "$pid"; then
105+
failed=1
106+
fi
107+
done
108+
return "$failed"
109+
}
110+
111+
echo "Installing dependencies and pre-pulling Docker images..."
112+
pull_images &
113+
pull_pid=$!
114+
install_status=0
115+
pnpm install --frozen-lockfile || install_status=$?
116+
pull_status=0
117+
wait "$pull_pid" || pull_status=$?
118+
if (( install_status != 0 || pull_status != 0 )); then
119+
exit 1
120+
fi
121+
echo "Dependency install and image pre-pull complete"
88122
89123
- name: 📀 Generate Prisma Client
90124
run: pnpm run generate

.github/workflows/unit-tests-webapp.yml

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ on:
1414
jobs:
1515
unitTests:
1616
name: "🧪 Unit Tests: Webapp"
17-
# 10 shards on 16x machines: webapp test throughput is limited per-machine (one
18-
# docker daemon + disk absorbing all the per-file Postgres/ClickHouse container
19-
# spin-up), so many machines beats few big ones - fewer/bigger (3x32) measured
20-
# SLOWER than 10x8. The 16x (vs 8x) gives the fork pool the CPU headroom the 8x
21-
# runners lacked. Setup overhead per machine is ~1 min on warm runners.
17+
# Webapp test throughput is limited per-machine (one docker daemon + disk absorbing
18+
# all the per-file Postgres/ClickHouse container spin-up), so many machines beats
19+
# few big ones - fewer/bigger (3x32) measured slower than 10x8. The 16x (vs 8x)
20+
# gives the fork pool the CPU headroom the 8x runners lacked.
2221
runs-on: warp-ubuntu-latest-x64-16x
2322
strategy:
2423
# one flaky shard shouldn't cancel its siblings - lets us re-run only the failed shard
2524
fail-fast: false
2625
matrix:
27-
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
28-
shardTotal: [12]
26+
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
27+
shardTotal: [24]
2928
env:
3029
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
3130
SHARD_INDEX: ${{ matrix.shardIndex }}
@@ -69,7 +68,7 @@ jobs:
6968
version: 10.33.2
7069

7170
- name: ⎔ Setup node
72-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
71+
uses: WarpBuilds/setup-node@bc639b444d583175926b588962199c247d23e8d3 # v6
7372
with:
7473
node-version: 24.18.0
7574
cache: "pnpm"
@@ -85,9 +84,10 @@ jobs:
8584
if: ${{ !env.DOCKERHUB_USERNAME }}
8685
run: echo "DockerHub login skipped because secrets are not available."
8786

88-
- name: 🐳 Pre-pull testcontainer images
87+
- name: 📥 Prepare deps and testcontainer images
8988
run: |
90-
# Retry each pull - DockerHub registry timeouts are a recurring transient CI flake.
89+
# Pull images concurrently with dependency installation. Retry each pull because
90+
# DockerHub registry timeouts are a recurring transient CI flake.
9191
pull() {
9292
for attempt in 1 2 3; do
9393
docker pull "$1" && return 0
@@ -97,18 +97,41 @@ jobs:
9797
echo "::error::docker pull $1 failed after 3 attempts"
9898
return 1
9999
}
100-
echo "Pre-pulling Docker images with authenticated session..."
101-
pull postgres:14
102-
pull postgres:17
103-
pull clickhouse/clickhouse-server:26.2.19.43-alpine@sha256:c6ad6a7eb2fb5999df3adfb8b69a0c7222c68fa9b8f6b04a088564ebbc959251
104-
pull redis:7.2
105-
pull testcontainers/ryuk:0.14.0
106-
pull electricsql/electric:1.2.4@sha256:20da3d0b0e74926c5623392db67fd56698b9e374c4aeb6cb5cadeb8fea171c36
107-
pull minio/minio:latest
108-
echo "Image pre-pull complete"
109-
110-
- name: 📥 Download deps
111-
run: pnpm install --frozen-lockfile
100+
101+
pull_images() {
102+
local pids=()
103+
local failed=0
104+
for image in \
105+
postgres:14 \
106+
postgres:17 \
107+
clickhouse/clickhouse-server:26.2.19.43-alpine@sha256:c6ad6a7eb2fb5999df3adfb8b69a0c7222c68fa9b8f6b04a088564ebbc959251 \
108+
redis:7.2 \
109+
testcontainers/ryuk:0.14.0 \
110+
electricsql/electric:1.2.4@sha256:20da3d0b0e74926c5623392db67fd56698b9e374c4aeb6cb5cadeb8fea171c36 \
111+
minio/minio:latest
112+
do
113+
pull "$image" &
114+
pids+=("$!")
115+
done
116+
for pid in "${pids[@]}"; do
117+
if ! wait "$pid"; then
118+
failed=1
119+
fi
120+
done
121+
return "$failed"
122+
}
123+
124+
echo "Installing dependencies and pre-pulling Docker images..."
125+
pull_images &
126+
pull_pid=$!
127+
install_status=0
128+
pnpm install --frozen-lockfile || install_status=$?
129+
pull_status=0
130+
wait "$pull_pid" || pull_status=$?
131+
if (( install_status != 0 || pull_status != 0 )); then
132+
exit 1
133+
fi
134+
echo "Dependency install and image pre-pull complete"
112135
113136
- name: 📀 Generate Prisma Client
114137
run: pnpm run generate

0 commit comments

Comments
 (0)