Skip to content
Open
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
13 changes: 1 addition & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,15 @@ jobs:

- run: bun install --frozen-lockfile

# typecheck builds first: examples import @corbits/artifacts through the
# published dist types, same path a consumer resolves.
- name: typecheck
run: bun run typecheck

- name: unit + integration tests
- name: unit, integration and reference-host acceptance tests
run: bun run test:coverage

# dist/ is already emitted by typecheck; re-run for a clean package build
# so acceptance and the node consumer smoke test do not depend on typecheck
# having side-effected the tree.
- name: build
run: bun run build

- name: install reference-host dependencies
run: bun install --cwd examples/reference-host

- name: reference-host acceptance
run: bun test --cwd examples/reference-host

# A consumer on plain Node must be able to install and import the
# tarball; Node cannot strip types, so a src-pointing manifest would die
# here rather than after publish.
Expand Down
26 changes: 15 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ docker run -d --name corbits-artifact-pg -p 5457:5432 \
export ALLOW_DESTRUCTIVE_ARTIFACT_TESTS=1

bun run typecheck
bun run test # unit + integration
bun run test # unit, integration and reference-host acceptance
bun run build # dist/ (JS + .d.ts)
bun run test:acceptance # builds, then examples/reference-host
```

Tests expect `postgres://postgres:postgres@localhost:5457/artifact_core` (override with
Expand All @@ -36,16 +35,22 @@ The harness truncates package tables between tests and drops the package schema
couple of migration cases. Those paths are fail-closed: set
`ALLOW_DESTRUCTIVE_ARTIFACT_TESTS=1` and point `ARTIFACT_DATABASE_URL` at an allowlisted
ephemeral database (`artifact_core`, or any name ending in `_test`). Without both, the
suite throws before mutating. The gate itself is pure URL/env parsing and is covered by
unit tests that do not need Postgres.
suite throws before mutating.

End-to-end suites live in `tests/`. `tests/lib/db-harness.ts` creates a fresh
`artifact_<random>_test` database per suite on the `ARTIFACT_DATABASE_URL` server,
applies Interchange's `runMigrations` and `runArtifactMigrations`, and drops it
afterwards. `artifactApp` mounts `createArtifactRoutes` for a seeded tenant
principal, authorized by the platform's real `createRequireGrant` over the
database's `grant` table. `bun run test` runs `src/` and `tests/`.

## The reference host is the acceptance suite, not a demo

`examples/reference-host` mounts the package on a real `@intx/hub-api` app against a
live Postgres and asserts the end-to-end scenarios, consuming the package through the
built `dist/` — the same artifact a consumer installs. That is why `test:acceptance`
builds first: running it against stale output is how a green acceptance run stops
meaning anything.
live Postgres. `tests/reference-host.test.ts` asserts the end-to-end scenarios against
it as part of `bun run test`; the example imports `@corbits/artifacts`, which the
root `tsconfig.json` maps to `src/`. CI's Node consumer smoke test covers the built
`dist/` a consumer installs.

If you change the route factory, a port, or anything about how a host wires this up, the
reference host is where that change has to be shown working.
Expand Down Expand Up @@ -76,9 +81,8 @@ is no ledger: a schema change is a new file whose statements are safe to re-run,
never an edit that assumes it runs once.

`schema.ts` and `migrations/` must agree — every query goes through the drizzle
table objects, and a test asserts the migrations create exactly the tables
`schema.ts` declares, no more and no less. Change one, change the other, in the
same commit.
table objects, and the route suites fail when a column they write is missing.
Change one, change the other, in the same commit.

## Pull requests

Expand Down
2 changes: 2 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ coverageThreshold = 0.8

# schema.ts is pure declarations — its "functions" are drizzle index/column
# callbacks the coverage instrumentation cannot attribute, not logic.
coveragePathIgnorePatterns = ["src/schema.ts", "src/test-helpers.ts"]
coveragePathIgnorePatterns = ["src/schema.ts", "src/test-helpers.ts", "tests/lib"]
Loading
Loading