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
5 changes: 5 additions & 0 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
- name: Run round contract unit tests
run: cargo test -p sub-rosa-round

- name: Fail if generated contract snapshots differ from committed evidence
run: |
git diff --exit-code -- contracts/round/test_snapshots/test
test -z "$(git ls-files --others --exclude-standard -- contracts/round/test_snapshots/test)"

- name: Check ERRORS.md stays in sync with enum Error
run: node scripts/check-round-errors.mjs

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ jobs:
- name: Check web CI configuration
run: node --test scripts/web-ci.test.mjs

- name: Check snapshot CI configuration
run: node --test scripts/snapshot-ci.test.mjs

- name: Install JS dependencies
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Check committed contract snapshot inventory
run: pnpm snapshot:check

- name: Test web
run: pnpm web:test

Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/dashboard/fixture-health-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import assert from "node:assert/strict";
import { test } from "node:test";

import { DASHBOARD_FIXTURE } from "./fixture.js";
import { DEMO_TRACE } from "../demo/demo-trace.generated.js";
import {
assertDashboardData,
DashboardDataHealthCheckError,
Expand All @@ -12,6 +13,21 @@ test("bundled dashboard fixture contains every field required by the UI", () =>
assert.doesNotThrow(() => assertDashboardData(DASHBOARD_FIXTURE));
});

test("dashboard fixture agrees with the committed demo trace", () => {
assert.equal(DASHBOARD_FIXTURE.meta.contractId, DEMO_TRACE.meta.contractId);
assert.equal(DASHBOARD_FIXTURE.meta.roundId, DEMO_TRACE.meta.roundId);
assert.equal(DASHBOARD_FIXTURE.round.revealRound, DEMO_TRACE.meta.revealRound);
assert.equal(DASHBOARD_FIXTURE.meta.fetchedAt, DEMO_TRACE.meta.recordedAt);
assert.equal(DASHBOARD_FIXTURE.round.status, DEMO_TRACE.meta.roundStatus);
assert.equal(DASHBOARD_FIXTURE.round.winner, DEMO_TRACE.keeper.clearWinner);
assert.equal(DASHBOARD_FIXTURE.round.winningBid, DEMO_TRACE.settlement.operatorReceivedUsdc);
assert.equal(DASHBOARD_FIXTURE.settlement?.contractBalance, DEMO_TRACE.keeper.contractBalanceFinal);
assert.deepEqual(
DASHBOARD_FIXTURE.bidders.map(({ address, bidUsdc }) => ({ address, bidUsdc })),
DEMO_TRACE.bidders.map(({ address, bidUsdc }) => ({ address, bidUsdc })),
);
});

test("health check identifies a missing required field by its path", () => {
const invalidData = structuredClone(DASHBOARD_FIXTURE) as unknown as {
meta: { contractId?: string };
Expand Down
6 changes: 6 additions & 0 deletions docs/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ dependencies without lifecycle scripts, then runs `pnpm web:test`,
locally to check `apps/web`; `node --test scripts/web-ci.test.mjs` verifies the
CI job configuration.

The same job runs `pnpm snapshot:check` to require the committed contract
snapshot categories, while `web:test` checks the generated demo trace and its
agreement with the dashboard fixture. The contract job regenerates Rust test
snapshots and fails if tracked snapshots change or new snapshots appear. Run
`node --test scripts/snapshot-ci.test.mjs` to verify these CI gates.

## SDK checks

The `SDK checks` workflow (`.github/workflows/sdk.yml`) runs on pushes to
Expand Down
28 changes: 28 additions & 0 deletions scripts/snapshot-ci.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2026 Sub Rosa contributors
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";

const web = readFileSync(new URL("../.github/workflows/web.yml", import.meta.url), "utf8");
const contract = readFileSync(new URL("../.github/workflows/contract.yml", import.meta.url), "utf8");
const scripts = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).scripts;
const webScripts = JSON.parse(readFileSync(new URL("../apps/web/package.json", import.meta.url), "utf8")).scripts;

test("web CI blocks on snapshot inventory and dashboard evidence checks", () => {
assert.equal(scripts["snapshot:check"], "node scripts/check-snapshots.mjs");
assert.match(web, /^ run: node --test scripts\/snapshot-ci\.test\.mjs$/m);
assert.match(web, /^ run: pnpm snapshot:check$/m);
assert.doesNotMatch(web, /\bcontinue-on-error\s*:/);
assert.ok(web.indexOf("pnpm install --frozen-lockfile --ignore-scripts") < web.indexOf("pnpm snapshot:check"));
assert.ok(web.indexOf("pnpm snapshot:check") < web.indexOf("pnpm web:test"));
assert.match(webScripts.test, /src\/dashboard\/fixture-health-check\.test\.ts/);
assert.match(webScripts.test, /src\/demo\/trace-health-check\.test\.ts/);
});

test("contract CI rejects regenerated or newly created snapshots", () => {
assert.match(contract, /^ run: cargo test -p sub-rosa-round$/m);
assert.match(contract, /git diff --exit-code -- contracts\/round\/test_snapshots\/test/);
assert.match(contract, /git ls-files --others --exclude-standard -- contracts\/round\/test_snapshots\/test/);
assert.doesNotMatch(contract, /\bcontinue-on-error\s*:/);
assert.ok(contract.indexOf("cargo test -p sub-rosa-round") < contract.indexOf("git diff --exit-code -- contracts/round/test_snapshots/test"));
});
Loading