Integration tests for the Gandalf contract, auth and reliability; fix worker offline status
CI / Lint (eslint) (push) Successful in 46s
CI / Security (npm audit) (push) Successful in 26s
CI / Integration (api) (push) Successful in 1m31s
CI / Test (jest) (pull_request) Successful in 50s
CI / UI (playwright) (push) Successful in 2m31s
CI / Integration (api) (pull_request) Successful in 1m58s
CI / Test (jest) (push) Successful in 13s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / UI (playwright) (pull_request) Successful in 2m16s
CI / Lint (eslint) (pull_request) Successful in 15s
CI / Security (npm audit) (pull_request) Successful in 15s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped

New CI job `Integration (api)` (#45 phase 3) runs the real server and three
workers on Node 20 against MariaDB and tests them as a black box over HTTP
and WebSocket (20 tests, about 12 s):

- Gandalf contract: submit and poll, stdout from command_result, failures
  with exit code and stderr, 401 for wrong or missing key, 400 for missing
  fields or an unknown worker, 404 for an unknown execution
- Auth: SSO identity, 401/403, heartbeat key, /healthz exposes only status;
  WebSocket upgrade refused without credentials, with a wrong key or a wrong
  group; live events reach a signed-in browser; a browser socket cannot
  forge a command result
- Reliability: a worker killed mid-command fails the execution at once; a
  worker at capacity answers with a failure; an aborted execution stays
  failed when the late result arrives; a disconnected worker shows offline

The last test found a bug from #42: the close handler deleted the worker's
runtime-id entry before checking whether the socket was still live under its
database id, and the two ids are normally the same key. So a disconnected
worker was never marked offline and showed 'online' until the stale
heartbeat sweep. Gandalf was unaffected (it checks live sockets).

MariaDB setup for CI moves to scripts/ci/mariadb.sh, shared by both jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-22 14:14:28 -05:00
1 parent 1d5b8cdd53
commit def926d41e
11 files changed
+391 -21

No files matched your search

+16 -2
View File
@@ -589,14 +589,28 @@ Everything runs from `.gitea/workflows/ci.yml`:
| `Lint (eslint)` | `npm run lint`, plus a check that fails on em or en dashes in Pulse-owned files | Every push and PR |
| `Test (jest)` | `npm test`: unit tests for `lib/` and the deploy-script sandbox tests | Every push and PR |
| `Security (npm audit)` | `npm audit --audit-level=high` | Every push and PR, and weekly (Monday 06:00) |
| `Integration (api)` | Starts the real server and three workers on Node 20 against MariaDB, then runs `tests/integration/` over HTTP and WebSocket: the Gandalf API contract, HTTP and WebSocket auth, and execution reliability (worker crash, capacity, abort) | Every push and PR |
| `UI (playwright)` | Starts the real server and three workers against a MariaDB service container, then runs the Playwright tests in `tests/ui/` (desktop and phone) | Every push and PR |
| `Deploy` | Calls the `pulse-deploy` webhook on CT 122, waits until `/healthz` reports the tested commit, then tags it `deploy-*` | Push to `main`, only after all four checks pass |
| `Deploy` | Calls the `pulse-deploy` webhook on CT 122, waits until `/healthz` reports the tested commit, then tags it `deploy-*` | Push to `main`, only after all five checks pass |
| `Notify` | Matrix alert on any failure on `main` or in the weekly audit, and on every deploy | As needed |
Branch protection on `main` requires `CI / Lint (eslint) (push)`, `CI / Test (jest) (push)`,
`CI / Security (npm audit) (push)` and `CI / UI (playwright) (push)`. Actions are pinned to commit
`CI / Security (npm audit) (push)`, `CI / Integration (api) (push)` and `CI / UI (playwright) (push)`. Actions are pinned to commit
SHAs and builds use `npm ci`. The plan for the rest of the pipeline is tracked in #45.
### Integration tests
`tests/integration/` tests the running server as a black box, the way Gandalf and the workers
use it: Gandalf's submit-and-poll contract (`/api/internal/command`, `/api/internal/executions/:id`),
SSO and worker-key auth on HTTP and on the WebSocket upgrade, forged results from a browser socket,
and that executions always finish (a worker killed mid-command, a worker at capacity, an abort
followed by a late result). Tests that need to kill or limit a worker start their own.
```bash
DB_HOST=127.0.0.1 DB_PORT=3399 DB_USER=pulse DB_PASSWORD=... DB_NAME=pulse scripts/ci/ui-stack.sh start
npm run test:integration
```
### UI tests
The Playwright tests drive the real UI end to end: every page loads with no page errors, console