Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
616f5d5
perf(claim): lock only claimed jobs and serialize claims with a claim…
tinchoz49 Dec 2, 2026
0273545
fix(claim): end a stalled claim_lock holder and document the claim lo…
tinchoz49 Dec 2, 2026
376c473
Merge perf/claim-candidate-limit: claims lock only the jobs they take…
tinchoz49 Dec 2, 2026
718b13e
feat(stop): shutdownTimeout option; graceful stop releases unfinished…
tinchoz49 Dec 2, 2026
b24d344
fix(stop): keep a job's outcome, liveness and step statuses on releas…
tinchoz49 Dec 2, 2026
0c976b3
Merge feat/shutdown-timeout-release: shutdownTimeout option; stop rel…
tinchoz49 Dec 2, 2026
3417ab4
fix: database-clock finished_at, migrate lock, per-schema prune key, …
tinchoz49 Dec 2, 2026
490c9f5
fix(migrate): run the locked migration transaction READ COMMITTED (F3…
tinchoz49 Dec 2, 2026
b09c1a8
test: run the suite in parallel processes and create test databases f…
tinchoz49 Dec 2, 2026
d6e916c
Merge fix/pre-existing-behaviours: database-clock finish times, locke…
tinchoz49 Dec 2, 2026
f2bb377
Merge remote-tracking branch 'origin/feat/review-followups' into chor…
tinchoz49 Dec 2, 2026
ff067d1
test: serialize more wall-clock files, add a per-file timeout, drop s…
tinchoz49 Dec 2, 2026
7cc71ba
test(claim-isolation): count only the claim's SERIALIZABLE setup
tinchoz49 Dec 2, 2026
93094e4
Merge fix/claim-isolation-set-tx: claim-isolation counts only the cla…
tinchoz49 Dec 2, 2026
c5a37e1
Merge chore/fast-tests: parallel test runner and template databases
tinchoz49 Dec 2, 2026
7e9e98a
refactor: shared column lists, #op helpers, prune scheduler module, s…
tinchoz49 Dec 2, 2026
7feb97c
fix: route prune faults through _retirePruning, brand StopGateError a…
tinchoz49 Dec 2, 2026
e22773a
test(shutdown-release): tolerate slow heartbeat writes in the long-dr…
tinchoz49 Dec 2, 2026
e7c7945
Merge refactor/review-structure: behaviour-neutral refactors (follow-…
tinchoz49 Dec 2, 2026
912175d
Merge fix/stop-double-run: shutdown-release liveness test tolerates a…
tinchoz49 Dec 2, 2026
862de4d
chore: group test files by feature, pg_isready readiness, How it work…
tinchoz49 Dec 2, 2026
08e063b
Merge branch 'feat/review-followups' into chore/tests-docs-consolidation
tinchoz49 Dec 2, 2026
8a8b744
Merge chore/tests-docs-consolidation: tests grouped by feature, 'How …
tinchoz49 Dec 2, 2026
c83dd37
chore: F5 review nits (define B, dedupe shutdown text, stale comments…
tinchoz49 Dec 2, 2026
a55c2f3
Merge chore/f5-nits: docs and test-infra nits from the F5 review
tinchoz49 Dec 2, 2026
f7e3b8a
ci: run the test workflow for pull requests into any branch (stacked …
tinchoz49 Dec 2, 2026
922edc6
Merge fix/postgres-reliability (CI trigger for stacked PRs)
tinchoz49 Dec 2, 2026
0816a3c
test(prune-lock): give the owned-close test room to close sessions on…
tinchoz49 Dec 2, 2026
0e6151c
Merge fix/prune-lock-budget: owned-close test tolerates a loaded data…
tinchoz49 Dec 2, 2026
fa8d9d6
test(recover): delete the worker scripts when each test ends
tinchoz49 Dec 2, 2026
0a49793
fix(stop): write skipped step statuses in the job's final transaction
tinchoz49 Dec 2, 2026
d5652f1
fix(lifecycle): log stop-gate refusals as a plain Error again
tinchoz49 Dec 2, 2026
d815cb2
docs: subclasses overriding _completeJob/_failJob must apply options.…
tinchoz49 Dec 2, 2026
debb0b2
Merge fix/review-leftovers: atomic step writes on stop, plain Error l…
tinchoz49 Dec 2, 2026
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
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ jobs:
# typecheck uses `bun check`; the published `dist` is emitted by tsc, so build it too.
- name: Build
run: bun run build
# scripts/test-parallel.ts: files in parallel processes, timing-sensitive files serially.
- name: Run tests
run: bun test --timeout 10000
run: bun run test

# The native PostgreSQL suite (POSTGRES_TEST=true) on every supported server major.
# test/docker.ts provisions the server itself: it runs DURON_TEST_POSTGRES_IMAGE as the
# container duron-postgres-test-<image> on port 5440 and creates one database per test
# with `docker exec` (createdb/psql/dropdb). The runner's Docker daemon is enough, so no
# over SQL from a template database. The runner's Docker daemon is enough, so no
# `services:` container is used (docker.ts would refuse one that holds port 5440).
native:
timeout-minutes: 60
Expand All @@ -61,7 +62,7 @@ jobs:
run: docker pull "$DURON_TEST_POSTGRES_IMAGE"
# Every PostgreSQL test runs only with POSTGRES_TEST; the test job above is PGlite only.
- name: Run native tests
run: bun test --timeout 10000
run: bun run test
- name: PostgreSQL container logs
if: failure()
run: docker logs "duron-postgres-test-${DURON_TEST_POSTGRES_IMAGE//[^a-zA-Z0-9_.-]/-}" 2>&1 | tail -200
13 changes: 12 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"suspicious": "warn"
},
"rules": {
"import/no-unassigned-import": ["error", { "allow": ["./app.css", "**/*.css"] }],
"import/no-unassigned-import": [
"error",
{
"allow": ["./app.css", "**/*.css"]
}
],
"no-underscore-dangle": "off"
},
"overrides": [
Expand All @@ -20,6 +25,12 @@
"rules": {
"no-shadow": "off"
}
},
{
"files": ["packages/duron/test/*.test.ts"],
"rules": {
"unicorn/consistent-function-scoping": "off"
}
}
],
"ignorePatterns": ["dist", "build", "node_modules", ".wrangler", "**/*.gen.ts", "**/env.d.ts"]
Expand Down
24 changes: 17 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bun run lint # oxlint check
bun run lint:fix # oxlint fix
bun run fmt:check # oxfmt check
bun run fmt # oxfmt fix
bun test --timeout 10000 # runs packages/duron tests (same as `bun run test`)
bun run test # packages/duron tests in parallel processes (scripts/test-parallel.ts)

# Build
bun run build # all packages
Expand All @@ -61,9 +61,19 @@ bun run build:docs # docs only
- Framework: `bun:test`
- Tests live in `packages/duron/test/*.test.ts`
- Run single file: `bun test --timeout 10000 specific.test.ts`
- Default per-test timeout: pass `--timeout 10000` (the `test` script and CI do). Bun ignores a `timeout` key in `bunfig.toml` (oven-sh/bun#7789), so a plain `bun test` uses 5000 ms.
- Core tests run with `bun test --timeout 10000` (no `--concurrent`: many suites share native resources and time-sensitive lifecycle budgets, and fail under cross-file concurrency)
- A plain `bun test --timeout 10000` runs PGlite only and needs no Docker. PostgreSQL tests run only with `POSTGRES_TEST=true`; every file that uses PostgreSQL gates it on that variable.
- Default per-test timeout: pass `--timeout 10000` (the runner and CI do). Bun ignores a `timeout` key in `bunfig.toml` (oven-sh/bun#7789), so a plain `bun test` uses 5000 ms.
- Full suite: `bun run test` (root or `packages/duron`) runs `packages/duron/scripts/test-parallel.ts`. CI uses it too.
- Each test file runs in its own `bun test --timeout 10000 <file>` process. Files without wall-clock budgets run in a pool of `--jobs N` processes (default: half the CPU cores; `DURON_TEST_JOBS` overrides).
- Files with wall-clock budgets (the `SERIAL` list in the script: `lifecycle*`, `prune-*`, `stop*`, `shutdown-*`, `wait-native*`, `wait-timing`, `discovery-throughput`, `claim-isolation`, `claim.test`, `cross-mechanism`, `step-abort-settlement`, `local-cancellation.test`, `worker-discovery`) run after the pool, one at a time, with no other test process. Add a file there when it asserts elapsed time or observes timers/cadences under a bound, and put a timing-sensitive test only in a file of that list.
- Test files are grouped by feature (for example `lifecycle.test.ts`, `prune-lock.test.ts`, `prune-scheduler.test.ts`, `wait.test.ts`, `wait-timing.test.ts`). Each former file is one `{ ... }` block with its own helpers, under a `// ===` banner with its old name; the imports are shared at the top. Keep a new group's helpers inside its block (the lint override for `packages/duron/test/*.test.ts` turns off `unicorn/consistent-function-scoping` for this reason).
- Output: one line per finished file (pass/skip/fail counts, time); then the complete output of each failed file, a per-file count table and the totals. Exit status 1 when a file fails (non-zero `bun test` exit, a failed test, no summary, or longer than the file timeout: 300000 ms, `--file-timeout` or `DURON_TEST_FILE_TIMEOUT`; a timed-out file is killed and reported by name, and the run continues). Every file's log is kept in `DURON_TEST_LOG_DIR` (default: a new temporary directory; the path is printed).
- Filters: `bun run test -- wait-` (in `packages/duron`) runs the files whose path contains a filter.
- `bun test --timeout 10000` (root, or `bun run test:serial` in `packages/duron`) still runs every file in one process, one file after another. It is slower; use it for one file or to compare.
- PGlite tests need no Docker. PostgreSQL tests run only with `POSTGRES_TEST=true`; every file that uses PostgreSQL gates it on that variable.
- Test databases (`test/adapters.ts`, `test/docker.ts`):
- `pgliteFactory` / `postgresFactory` give a database with all migrations already applied; `migrateOnStart` only checks them. With `fresh: true` or `migrateOnStart: false` the database is empty (as a new one). Use `fresh: true` in a test that observes the migrations themselves.
- PGlite: each process dumps one migrated and one empty engine once (`dumpDataDir`); every factory engine starts from a dump (`loadDataDir`), which skips `initdb` (about 450 ms of the 500 ms of a new engine).
- PostgreSQL: each test database is `CREATE DATABASE "<random>" TEMPLATE "<template>"` over SQL, and `deleteDb` drops it over SQL. The templates `duron_test_tpl_base_<key>` (pgcrypto) and `duron_test_tpl_migrated_<key>` (plus all migrations) are built once per server, under an advisory lock. `<key>` hashes the migrations folder and the Drizzle version, so a changed migration builds new templates. The runner drops the templates of other keys before a run (best effort); a run that loses its template rebuilds it. With `POSTGRES_TEST=true` the runner prepares the container and templates once and sets `DURON_TEST_CONTAINER_READY=1`, so the test processes skip the container checks. `getPostgresConnection()` gives an empty (base) database unless `{ migrated: true }`.
- With `POSTGRES_TEST=true`, `test/docker.ts` auto-creates a Docker container on port 5440 for the PostgreSQL tests. Docker must be running.
- Image: `DURON_TEST_POSTGRES_IMAGE` (default `postgres:19-alpine`). The suite is also verified on `postgres:16-alpine`.
- Container: `duron-postgres-test-<image>` (for example `duron-postgres-test-postgres-19-alpine`), so a changed image never reuses a container of another version. `DURON_TEST_POSTGRES_CONTAINER` overrides the name; an existing container must run the selected image.
Expand Down Expand Up @@ -110,8 +120,8 @@ bun run build:docs # docs only

Workflow `.github/workflows/test.yml` (Bun pinned with `BUN_VERSION`, currently 1.4.5) has two jobs:

- `test`: `bun install --frozen-lockfile` → `typecheck` → `lint` → `fmt:check` → `build` → `bun test --timeout 10000` (PGlite only, no Docker).
- `native`: matrix over `postgres:16-alpine` and `postgres:19-alpine` (`DURON_TEST_POSTGRES_IMAGE`), `POSTGRES_TEST=true bun test --timeout 10000`. `test/docker.ts` starts the container on the runner's Docker.
- `test`: `bun install --frozen-lockfile` → `typecheck` → `lint` → `fmt:check` → `build` → `bun run test` (parallel runner, PGlite only, no Docker).
- `native`: matrix over `postgres:16-alpine` and `postgres:19-alpine` (`DURON_TEST_POSTGRES_IMAGE`), `POSTGRES_TEST=true bun run test`. `test/docker.ts` starts the container on the runner's Docker.

## Branch Workflow

Expand All @@ -122,7 +132,7 @@ Workflow `.github/workflows/test.yml` (Bun pinned with `BUN_VERSION`, currently
```bash
bun run typecheck # TypeScript check across all packages
bun run lint # Lint check
bun test --timeout 10000 # Full test suite (not just packages/duron)
bun run test # Full test suite (parallel runner)
```

## Telemetry
Expand Down
Loading
Loading