From 1be3bdfd58cd77c46b160b10468845c9224aa41d Mon Sep 17 00:00:00 2001 From: Jacob Stephens Date: Sun, 15 Nov 2026 16:39:53 -0500 Subject: [PATCH] Verify Node 22 and 26 builds and server startup (#53) --- .github/workflows/ci.yml | 11 ++++++--- README.md | 3 ++- ops/README.md | 16 ++++++++----- ops/test-server-start.sh | 48 +++++++++++++++++++++++++++++++++++++++ ops/test-workflow-pins.sh | 41 +++++++++++++++++---------------- tasks/done.md | 1 + 6 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 ops/test-server-start.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c92dfce..f99dd70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,11 +11,15 @@ permissions: jobs: verify: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [22.23.4, 26.13.1] steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: - node-version: 22.23.4 + node-version: ${{ matrix.node }} cache: npm - run: bash ops/test-workflow-pins.sh - run: bash ops/test-package-release.sh @@ -25,13 +29,14 @@ jobs: - run: npm test - run: npm run typecheck - run: npm run build + - run: bash ops/test-server-start.sh - name: Package the verified release - if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + if: startsWith(matrix.node, '22.') && github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) env: DEPLOY_COMMIT: ${{ github.sha }} run: bash ops/package-release.sh "$DEPLOY_COMMIT" "$RUNNER_TEMP/clave-release.tgz" - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + if: startsWith(matrix.node, '22.') && github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) with: name: production-release path: ${{ runner.temp }}/clave-release.tgz diff --git a/README.md b/README.md index 9b8b25f..ee4e55c 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ adjudicated build plan is [`docs/plans/clave-plan.md`](docs/plans/clave-plan.md) ## Play locally -Requires Node 22 or newer. +Requires Node 22 or newer. CI verifies Node 22 and 26. ```sh npm install @@ -74,6 +74,7 @@ npm run test:e2e npm run typecheck npm run lint npm run build +bash ops/test-server-start.sh # after building; isolated database, no secrets ``` ## Application map diff --git a/ops/README.md b/ops/README.md index 57913f6..7ce234c 100644 --- a/ops/README.md +++ b/ops/README.md @@ -18,12 +18,16 @@ the repository's default branch (including a merged PR) then deploys to the `production` environment. `workflow_dispatch` can retry the default branch without creating another commit. PRs, tags, and other branches cannot deploy. -CI uses Node 22 to match the server, runs release-packaging and validation checks, -ShellCheck, -`npm ci`, the full unit suite, typechecking, and the production build. It packages -the exact checked-out source and all four built packages into one immutable Actions -artifact. `/release.json` identifies its commit. No credentials or `node_modules` -are shipped in the artifact. +CI uses exact Node 22 and 26 releases, covering both the current host runtime and +its planned upgrade. Each runs release-packaging and validation checks, ShellCheck, +`npm ci`, the full unit suite, typechecking, the production build, and +`bash ops/test-server-start.sh`. The smoke check starts the built server on loopback +with a temporary database, checks `/healthz` and `/`, and rejects startup deprecation +warnings. Only the Node 22 job packages the exact checked-out source and all four +built packages into the immutable `production-release` artifact; deployment waits +for both runtimes to pass. `/release.json` identifies its commit. No credentials or +`node_modules` are shipped in the artifact. This matrix does not change the host's +Node installation or service configuration. The deployment job rejects superseded commits and serializes releases without cancelling an in-progress deployment. It streams the artifact over host-key-pinned diff --git a/ops/test-server-start.sh b/ops/test-server-start.sh new file mode 100644 index 0000000..8b52e41 --- /dev/null +++ b/ops/test-server-start.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail + +root=$(cd "$(dirname "$0")/.." && pwd) +fixture=$(mktemp -d) +server_pid= +cleanup() { + local status=$? + if [[ -n "$server_pid" ]]; then + kill "$server_pid" 2>/dev/null || true + wait "$server_pid" 2>/dev/null || true + fi + if [[ "$status" -ne 0 ]]; then + cat "$fixture/server.log" >&2 + fi + rm -rf "$fixture" +} +trap cleanup EXIT +cd "$root" + +# Ask the OS for a free loopback port so concurrent checkouts can run the smoke check. +port=$(node --input-type=module <<'NODE' +import { createServer } from 'node:net'; +const server = createServer(); +server.listen(0, '127.0.0.1', () => { + console.log(server.address().port); + server.close(); +}); +NODE +) + +HOST=127.0.0.1 PORT="$port" CLAVE_DB_PATH="$fixture/clave.sqlite" \ + node --trace-deprecation packages/server/dist/index.js > "$fixture/server.log" 2>&1 & +server_pid=$! +curl --fail --silent --show-error --retry 10 --retry-connrefused --retry-delay 1 \ + --max-time 2 --retry-max-time 15 "http://127.0.0.1:$port/healthz" > "$fixture/health.json" +jq -e '.ok == true and .service == "clave"' "$fixture/health.json" > /dev/null +curl --fail --silent --show-error --max-time 2 "http://127.0.0.1:$port/" > "$fixture/index.html" +grep -q '' "$fixture/index.html" +kill "$server_pid" +wait "$server_pid" +server_pid= + +if grep -q 'DeprecationWarning' "$fixture/server.log"; then + echo "Server startup emitted a deprecation warning." >&2 + exit 1 +fi +echo "Server startup, /healthz and / passed without deprecation warnings on $(node --version)." diff --git a/ops/test-workflow-pins.sh b/ops/test-workflow-pins.sh index 7bf3a16..0135b1e 100644 --- a/ops/test-workflow-pins.sh +++ b/ops/test-workflow-pins.sh @@ -33,29 +33,30 @@ check_action() { check_action checkout check_action setup-node -node_found=0 -while IFS= read -r line; do - [[ -n "$line" ]] || continue - node_found=1 - number=${line%%:*} - body=${line#*:} - value=${body#*node-version:} - value=${value%%#*} - value=${value#"${value%%[![:space:]]*}"} - value=${value%"${value##*[![:space:]]}"} - if [[ "$value" == \"*\" && "$value" == *\" ]]; then - value=${value:1:${#value}-2} - elif [[ "$value" == \'*\' && "$value" == *\' ]]; then - value=${value:1:${#value}-2} - fi - if [[ ! "$value" =~ ^22\.[0-9]+\.[0-9]+$ ]]; then - echo "node-version on line ${number} must be an exact Node 22 release, not: ${value}" >&2 +if ! grep -Eq '^[[:space:]]*node-version: \$\{\{ matrix.node \}\}[[:space:]]*$' "$workflow"; then + echo "CI must select node-version from \${{ matrix.node }}." >&2 + fail=1 +fi + +# Keep exact release pins while covering both the current and next host runtime. +versions=$(sed -nE 's/^[[:space:]]*node: \[([^]]*)\][[:space:]]*$/\1/p' "$workflow") +IFS=',' read -ra node_versions <<< "$versions" +node_22=0 +node_26=0 +for value in "${node_versions[@]}"; do + value=${value//[[:space:]\"\']/} + if [[ "$value" =~ ^22\.[0-9]+\.[0-9]+$ ]]; then + node_22=1 + elif [[ "$value" =~ ^26\.[0-9]+\.[0-9]+$ ]]; then + node_26=1 + else + echo "matrix.node must use exact Node 22 and 26 releases, not: ${value}" >&2 fail=1 fi -done < <(grep -nE '^[[:space:]]*node-version:' "$workflow" || true) +done -if [[ "$node_found" -eq 0 ]]; then - echo "CI workflow does not set node-version." >&2 +if [[ "$node_22" -ne 1 || "$node_26" -ne 1 ]]; then + echo "CI matrix must cover both Node 22 and Node 26." >&2 fail=1 fi diff --git a/tasks/done.md b/tasks/done.md index e2be66f..ec8551f 100644 --- a/tasks/done.md +++ b/tasks/done.md @@ -1,3 +1,4 @@ +- [x] Build, test, and run on Node 26 alongside Node 22 (issue #53): add exact-release CI matrix coverage, retain one Node 22 production artifact gated on both runtimes, update workflow pin checks, and smoke-start the built server against an isolated database on both runtimes without startup deprecation warnings; existing engine constraints and locked dependencies need no changes. - [x] turn images into markdown - [x] Write an opinionated rulebook to docs/rules/game-rules according to docs/rules/decisions and docs/rules/game-rules-draft. Feel free to look elsewhere in the repo, and especially the handwritten-notes, for inspiration. - [x] Add a file or files to docs/cards which defines cards for v1 of Clave.