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
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions ops/test-server-start.sh
Original file line number Diff line number Diff line change
@@ -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 '<!doctype html>' "$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)."
41 changes: 21 additions & 20 deletions ops/test-workflow-pins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tasks/done.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading