Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.odds-api.io/llms.txt

Use this file to discover all available pages before exploring further.

PR Test Workflow — Design

Status: Approved Date: 2026-05-06 Owner: Markus

Goal

Run the full test suite for every PR targeting main and block merging until all checks pass.

Scope

In scope:
  • Unit tests, typecheck, and lint for all three subprojects (v3/, account-service/, web/)
  • A single GitHub Actions workflow gated as a required check on main
  • Per-subproject path filters with an aggregator job so branch protection works correctly
  • Documentation for the manual branch-protection setup step
Out of scope:
  • E2E / browser tests (no Playwright/Cypress today)
  • Coverage reporting
  • Deployment workflows
  • Matrix testing across multiple language versions
  • Load/stress tests (kept in the codebase but excluded from CI)

Architecture

One workflow file: .github/workflows/pr-tests.yml. Triggers on pull_request against main. Three independent jobs run in parallel, plus an aggregator.
pull_request → [ v3-go ] [ account-service ] [ web ] → [ all-checks ]
The aggregator job (all-checks) depends on all three with if: always() and a step that fails if any dependency failed. Branch protection requires only all-checks. This solves the GitHub quirk where path-filtered jobs that don’t run register as “skipped” rather than “passed”, which would otherwise block PRs that touched only one subproject.

Job: v3-go

  • Path filter: v3/**, .github/workflows/pr-tests.yml
  • Setup: actions/setup-go@v5 pinned to 1.24 (matches v3/go.mod)
  • Cache: built into setup-go
  • Steps:
    1. gofmt -l . — fail if output is non-empty
    2. go vet ./...
    3. go build ./...
    4. go test -short -race ./...

Job: account-service

  • Path filter: account-service/**, .github/workflows/pr-tests.yml
  • Setup: actions/setup-node@v4 (Node 22) + pnpm/action-setup@v4 with pnpm cache
  • Steps:
    1. pnpm install --frozen-lockfile
    2. pnpm typecheck
    3. pnpm exec biome check .
    4. pnpm test

Job: web

  • Path filter: web/**, .github/workflows/pr-tests.yml
  • Setup: same as account-service
  • Steps:
    1. pnpm install --frozen-lockfile
    2. pnpm typecheck (new script — see “Required code changes”)
    3. pnpm lint (already wired to biome)
    4. pnpm test
    5. pnpm build (catches Next.js build-time errors not caught by tsc)

Job: all-checks

  • needs: [v3-go, account-service, web]
  • if: always()
  • One step that exits non-zero if any of the three results is failure or cancelled. skipped is treated as success (path filter didn’t match).

Required code changes outside the workflow file

  1. Exclude load/stress Go tests from CI. Add if testing.Short() { t.Skip(...) } guards (or build tags) at the top of:
    • v3/websocket/load_test.go
    • v3/websocket/load_stress_test.go
    • v3/websocket/hub_performance_test.go
    • v3/websocket/replay_benchmark_test.go
    • v3/websocket/throughput_benchmark_test.go
    • v3/websocket/replay_deferred_bench_test.go
    • Any other file under v3/ that drives heavy concurrency or long timeouts.
    Audit each file before editing — only add the skip if the test is actually heavy. Benchmarks (Benchmark* funcs) are not run by go test by default and don’t need guards.
  2. Add typecheck script to web/package.json:
    "typecheck": "tsc --noEmit"
    
  3. Verify vitest tests don’t need live services. Check whether account-service/routes/webhooks.test.ts, trial.test.ts, and web/src/app/api/**/*.test.ts connect to real Mongo, Redis, or Stripe. If any do, the design choice is to mock them rather than spin up service containers in CI (simpler, faster, more reliable). Implementation step will fix any test that fails because it expects a live service.

Branch protection setup (manual step)

GitHub Actions can’t enable required checks itself — it has to be toggled in repo settings. Document in .github/workflows/README.md:
  1. Repo Settings → Branches → Add rule for main
  2. Require status checks: select all-checks
  3. Require branches to be up to date before merging
  4. Apply rules to administrators (recommended)

Failure modes & handling

ScenarioBehavior
Web-only PROnly web job runs; v3-go and account-service skip; all-checks passes
Test failsThat job fails; all-checks fails; PR blocked
Workflow file editedAll three jobs run (workflow path is in every filter)
Lockfile out of syncpnpm install --frozen-lockfile fails fast in install step
Cache missFirst run is slow but correct; subsequent runs hit cache

Testing the workflow

After merge, validate by:
  1. Opening a trivial PR touching only web/ — verify v3-go and account-service skip and all-checks still passes
  2. Opening a PR with a deliberately failing test — verify all-checks fails and the PR shows as blocked
  3. Opening a PR touching all three subprojects — verify all jobs run

Open questions

None at design time. Service-mocking decisions will be made during implementation when we know which (if any) tests fail.