Skip to content

Commit 8469706

Browse files
committed
fix: harden the two local-only CI steps against what a fresh runner never sees
The Postgres readiness probe now goes over TCP inside the container. The image's entrypoint runs a temporary init-phase server on the unix socket only, so a socket probe read ready before the real server listened on the port the test connects to, and every run is a fresh container so the window is there warm or not. The website e2e step refuses when something already answers on :5001 (the step would otherwise test that server while its own died with EADDRINUSE) and pins PORT=5001, since the website dev script honours an exported PORT and the probe would wait out its two minutes. framework-dev.md described the pg driver as linked under test/pg/node_modules, the approach that was tried and did not satisfy drizzle's resolution; it now describes the --no-save install the script does, and the prerequisites name setsid and pgrep. Claude-Session: https://claude.ai/code/session_0125BCU48L9AmmM1JbBKeyQe
1 parent f9a6691 commit 8469706

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎framework-dev.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ the root `npm test`, the in-repo app typechecks and suites plus the website
188188
boot-check, the Conventions group (`webjs check` and `webjs doctor` per in-repo
189189
app, the buildless-packages invariant, the em-dash scan), and the Postgres
190190
round-trip against a throwaway `postgres:16` container (`scripts/ci-postgres.sh`,
191-
which also installs the `pg` driver into a scratch prefix and links it under
192-
`test/pg/node_modules`, so the shared lock stays without it, the same posture
193-
the CI job takes). The Docker image build is its own top-level step after the
191+
which also installs the `pg` driver `--no-save` into the repo's own
192+
`node_modules` and refuses to do so through a symlinked one, so the shared lock
193+
stays without it, the same posture the CI job takes). The Docker image build is its own top-level step after the
194194
Gate, so `--only Gate` skips it on a routine run and a signoff run includes it.
195195
Each slot's output is replayed whole when it finishes, and the wall-clock is the
196196
longest slot rather than the sum. `npm run ci` runs the lot; `npm run ci --
@@ -223,9 +223,12 @@ container and the image build; the user must be in the `docker` group, or set
223223
`WEBJS_DOCKER` to the command that reaches a daemon, such as `sudo -n docker`
224224
or `podman`), the Playwright browsers (`npx playwright
225225
install chromium firefox webkit`), `puppeteer-core` (a root devDependency),
226-
`gh` with the signoff extension (the script installs it), and a shell that does
227-
NOT export `FORCE_COLOR` (it flips tsc to pretty output and reds two type
228-
guards that parse the plain format).
226+
`gh` with the signoff extension (the script installs it), `setsid` and `pgrep`
227+
(util-linux and procps, present on Linux and absent from a stock macOS: the
228+
website e2e step and the runner's interrupt test use them), and a shell that
229+
does NOT export `FORCE_COLOR` (it flips tsc to pretty output and reds two type
230+
guards that parse the plain format) or `PORT` (the website e2e step pins 5001
231+
itself, but nothing else in the list should be steered by it either).
229232

230233
`gallery`, `examples/blog`, and `website` each declare their own shorter list
231234
(setup, then `webjs check` / `webjs doctor` / typecheck / tests two at a time)

‎scripts/ci-e2e-website.sh‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,26 @@
1919
# - On a failure the server log is printed, so a boot failure, a build failure,
2020
# or a 500 on /ui/button does not fail the step with its cause in a file
2121
# nobody reads.
22+
# - Two things a fresh CI runner never had to guard against. A server ALREADY
23+
# on :5001 (a machine that was just editing the website) would answer the
24+
# probe first try while ours died with EADDRINUSE, and the step would report
25+
# on that server rather than this tree, so it is refused. And the website's
26+
# dev script is `webjs dev --port ${PORT:-5001}`, so a shell exporting PORT
27+
# would put the server elsewhere and the probe would wait out its two
28+
# minutes; the port is pinned.
2229

2330
set -euo pipefail
2431

2532
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
2633
LOG="${TMPDIR:-/tmp}/webjs-ci-website-dev-$$.log"
2734
cd "$ROOT"
2835

29-
setsid npm run dev --workspace=@webjsdev/website > "$LOG" 2>&1 < /dev/null &
36+
if curl -sf -o /dev/null http://localhost:5001/ui/button; then
37+
echo "something already answers on :5001; stop it first, or this step tests that server instead of this tree" >&2
38+
exit 1
39+
fi
40+
41+
PORT=5001 setsid npm run dev --workspace=@webjsdev/website > "$LOG" 2>&1 < /dev/null &
3042
server_pid=$!
3143
trap 'rc=$?; if [ "$rc" -ne 0 ]; then echo "--- website dev server log ---"; tail -n 200 "$LOG" || true; fi; kill -- -"$server_pid" 2>/dev/null || true; rm -f "$LOG"; exit "$rc"' EXIT
3244

‎scripts/ci-postgres.sh‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ $DOCKER run -d --rm --name "$NAME" \
5252
-e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=webjs_test \
5353
-p "127.0.0.1:${PORT}:5432" postgres:16 >/dev/null
5454

55-
# Same readiness probe the CI service container declares, up to ~50s.
55+
# The CI service container's readiness probe, up to ~50s, but over TCP: the
56+
# image's entrypoint first runs a temporary init-phase server on the unix
57+
# socket only, and a socket probe (no -h) reads ready there, before the real
58+
# server listens on the port the test connects to.
5659
for _ in $(seq 1 50); do
57-
if $DOCKER exec "$NAME" pg_isready -U postgres >/dev/null 2>&1; then break; fi
60+
if $DOCKER exec "$NAME" pg_isready -h 127.0.0.1 -U postgres >/dev/null 2>&1; then break; fi
5861
sleep 1
5962
done
60-
if ! $DOCKER exec "$NAME" pg_isready -U postgres >/dev/null 2>&1; then
63+
if ! $DOCKER exec "$NAME" pg_isready -h 127.0.0.1 -U postgres >/dev/null 2>&1; then
6164
echo "ci-postgres: postgres:16 did not become ready in time" >&2
6265
$DOCKER logs "$NAME" >&2 || true
6366
exit 1

0 commit comments

Comments
 (0)