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
78 changes: 78 additions & 0 deletions .github/workflows/spec-evidence.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Specification evidence

on:
pull_request:
push:
branches: [main]
schedule:
- cron: "23 4 1 * *"
workflow_dispatch:

env:
STRIPE_MOCK_VERSION: "0.188.0"

permissions:
contents: read

concurrency:
group: specification-evidence-${{ github.ref }}
cancel-in-progress: true

jobs:
evidence:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
Comment thread
stefan-burke marked this conversation as resolved.
Resolved
with:
persist-credentials: false

- name: Set up Deno
uses: ./.github/actions/setup-deno

- name: Cache stripe-mock
uses: actions/cache@v4
with:
path: .bin
key: stripe-mock-${{ env.STRIPE_MOCK_VERSION }}-linux-amd64

- name: Resolve Playwright version
id: playwright
run: |
version="$(deno eval '
const config = JSON.parse(await Deno.readTextFile("deno.json"));
const version = config.imports.playwright.match(/^npm:playwright@(.+)$/)?.[1];
if (!version) throw new Error("playwright must be pinned in deno.json");
console.log(version);
')"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Playwright Chromium
id: chromium-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }}

- name: Install Chromium and system dependencies
if: steps.chromium-cache.outputs.cache-hit != 'true'
run: deno run -A npm:playwright@${{ steps.playwright.outputs.version }} install --with-deps chromium

- name: Install Chromium system dependencies
if: steps.chromium-cache.outputs.cache-hit == 'true'
run: deno run -A npm:playwright@${{ steps.playwright.outputs.version }} install-deps chromium

- name: Test screenshot browser contracts
run: deno task test:screenshot-contract

- name: Capture specification evidence
run: deno task specs:evidence

- name: Upload specification evidence
uses: actions/upload-artifact@v4
with:
name: tickets-evidence
path: reports/evidence
if-no-files-found: error
retention-days: 90
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ logging and table-scoped cache invalidation stay automatic.
- `deno task test` - Run the full suite
- `deno task test:coverage` - Run the full suite with coverage
- `deno task test:files <file>...` - Run only the given test files with the same setup as the full runner (builds static assets, starts stripe-mock, cleans up after)
- `deno task test:screenshot-contract` - Run the real-browser screenshot timing and responsive-layout contracts (requires Chromium)
- `deno task specs` - Run every Cucumber Feature through the shared test harness and write ignored Messages, HTML, and JUnit reports under `reports/`
- `deno task specs:evidence` - Run only cases with declared screenshot captures, one at a time, and write the versioned manifest plus PNG assets under `reports/evidence/`; the task requires a clean Git worktree so the manifest commit matches the captured code
- `deno task specs:check` - Parse every Feature and validate the strict authored profile and stable catalog
- `deno task specs:files <feature>... [--tags <expression>]` - Run selected Features through the shared harness
- `deno task lint` - Format and lint all code with Biome (`check --write`; auto-fixes in place). Biome is the sole formatter and linter.
Expand Down Expand Up @@ -936,6 +938,10 @@ Execution is equally strict:
of truth and are not committed.
- Stable repository IDs come only from authored tags. Cucumber AST/Pickle IDs,
names, paths, and line numbers are not durable IDs.
- Screenshot evidence uses those authored story, rule, and case IDs plus a
separate stable capture ID. Its public contract is
`reports/evidence/manifest.json` with files under `reports/evidence/assets/`;
raw Cucumber Messages stay generated and private.
- A Cucumber journey never supplies the only coverage of a production line or
branch. Keep 100% direct Deno coverage, and run direct tests before Cucumber
integration tests in mutation runs.
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,25 @@ deno task screenshot all --social facebook,instagram-portrait
deno task screenshot dashboard --social all
```

### Specification evidence

`deno task specs:evidence` runs only Cucumber cases that declare evidence. It
runs them one at a time and captures each declared final page before that
scenario's test database is removed. Normal `specs` and `test` runs do not start
Chromium. Commit local changes before running it: the task refuses a dirty Git
worktree so the manifest cannot name a commit that differs from the captured
code.

The task writes a versioned `reports/evidence/manifest.json` and PNG files under
`reports/evidence/assets/`. The manifest uses the authored story, rule, case,
and capture IDs. It includes the app commit, image hash and dimensions, browser
profile, viewport, and presentation type. Raw Cucumber messages and reports are
not part of this evidence folder. The app workflow verifies the capture on pull
requests. Main pushes and a monthly refresh upload this folder as the stable
`tickets-evidence` artifact with GitHub's 90-day retention. The Tickets website
imports that artifact into a reviewed pull request
and keeps its ordinary site build offline.


```bash
# Install Deno, cache dependencies, run all checks
Expand Down
4 changes: 3 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"test": "deno run --v8-flags=--expose-gc -A scripts/run-tests.ts",
"test:coverage": "deno run --v8-flags=--expose-gc -A scripts/run-tests.ts --coverage",
"test:files": "deno run --v8-flags=--expose-gc -A scripts/run-test-files.ts",
"test:screenshot-contract": "deno test --no-check -A test/scripts/screenshots-browser.contract.ts",
"specs": "deno run --v8-flags=--expose-gc -A scripts/run-specs.ts",
"specs:evidence": "deno run --v8-flags=--expose-gc -A scripts/run-spec-evidence.ts",
"specs:check": "deno run --allow-read scripts/check-specs.ts",
"specs:files": "deno run --v8-flags=--expose-gc -A scripts/run-specs.ts",
"test:raw": "deno task build:static && deno test --no-check --allow-net --allow-env --allow-read --allow-write --allow-run --allow-sys --allow-ffi test/",
"lint": "deno run -A scripts/biome.ts check --write --error-on-warnings src test scripts cli e2e-payments",
"lint:ci": "deno run -A scripts/biome.ts check --error-on-warnings src test scripts cli e2e-payments",
"typecheck": "deno check src/**/*.ts src/**/*.tsx test/**/*.ts cli/**/*.ts scripts/database-snapshot.ts scripts/restore.ts scripts/turso-migration.ts scripts/mutation.ts scripts/mutation/**/*.ts scripts/precommit.ts scripts/precommit/**/*.ts scripts/check-copy.ts scripts/check-copy/**/*.ts scripts/specs/**/*.ts scripts/run-specs.ts scripts/check-specs.ts scripts/test-quality-audit.ts scripts/bench/bundle-composition/**/*.ts scripts/screenshots.ts scripts/screenshots/**/*.ts && deno check --config=e2e-payments/deno.json e2e-payments/src/**/*.ts",
"typecheck": "deno check src/**/*.ts src/**/*.tsx test/**/*.ts cli/**/*.ts scripts/database-snapshot.ts scripts/restore.ts scripts/turso-migration.ts scripts/mutation.ts scripts/mutation/**/*.ts scripts/precommit.ts scripts/precommit/**/*.ts scripts/check-copy.ts scripts/check-copy/**/*.ts scripts/specs/**/*.ts scripts/run-specs.ts scripts/run-spec-evidence.ts scripts/check-specs.ts scripts/test-quality-audit.ts scripts/bench/bundle-composition/**/*.ts scripts/screenshots.ts scripts/screenshots/**/*.ts && deno check --config=e2e-payments/deno.json e2e-payments/src/**/*.ts",
"cpd": "deno run -A scripts/cpd.ts --config .jscpd.json && deno run -A scripts/cpd.ts --config .jscpd.test.json && deno run -A scripts/cpd.ts --config .jscpd.css.json src/ui/static/style.scss",
"check:copy": "deno run --allow-read=src/locales scripts/check-copy.ts",
"precommit": "deno run -A scripts/precommit.ts",
Expand Down
23 changes: 22 additions & 1 deletion scripts/browser-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { LaunchOptions } from "playwright";
import type { Browser, chromium, LaunchOptions } from "playwright";

type Chromium = typeof chromium;

const SCREENSHOT_LAUNCH_ARGS = ["--disable-features=CDPScreenshotNewSurface"];

export const browserLaunchOptions = (
headless: boolean,
Expand All @@ -9,3 +13,20 @@ export const browserLaunchOptions = (
...(executablePath ? { executablePath } : {}),
headless,
});

/** Launch Chromium with screenshot-mode flags (headless, CDP screenshot fix). */
const launchScreenshotChromium = (
browser: Chromium,
executablePath?: string,
): Promise<Browser> =>
browser.launch(
browserLaunchOptions(true, executablePath, SCREENSHOT_LAUNCH_ARGS),
);

export const defineScreenshotBrowserLauncher =
(
browser: Chromium,
executablePath: () => Promise<string | undefined>,
): (() => Promise<Browser>) =>
async () =>
launchScreenshotChromium(browser, await executablePath());
7 changes: 7 additions & 0 deletions scripts/checksum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const toHex = (bytes: ArrayBuffer): string =>
[...new Uint8Array(bytes)]
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("");

export const sha256Hex = async (bytes: Uint8Array): Promise<string> =>
toHex(await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes)));
8 changes: 8 additions & 0 deletions scripts/run-spec-evidence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S deno run --allow-all
import { runEvidenceSpecs } from "./specs/evidence/run.ts";
import { withTestHarness } from "./test-harness.ts";

if (import.meta.main) {
const result = await withTestHarness(runEvidenceSpecs);
Deno.exit(result.success ? 0 : 1);
}
Loading