Skip to content

feat: PLAN §5.1–5.3 — Pact contract testing#23

Open
mcalthrop wants to merge 4 commits intomainfrom
feat/plan-5-1-5-3-pact-contract-testing
Open

feat: PLAN §5.1–5.3 — Pact contract testing#23
mcalthrop wants to merge 4 commits intomainfrom
feat/plan-5-1-5-3-pact-contract-testing

Conversation

@mcalthrop
Copy link
Copy Markdown
Owner

Summary

  • Adds a Pact consumer test (apps/web/pact/recipes.pact.test.ts) that generates a contract for the /recipes and /recipes/{id} endpoints, plus a publish script (apps/web/scripts/pact-publish.sh)
  • Adds a provider verification script (apps/api/scripts/pact-provider-verify.sh) and the @pact-foundation/pact npm bindings under apps/api
  • Adds docker-compose.yml to spin up a local Pact broker for the full consumer → publish → verify loop
  • Adds a root scripts/pact-verify.sh helper and wires pact:verify into the Turbo pipeline
  • Pins apps/api to Python 3.13 via .python-version and updates the README setup instructions accordingly
  • Updates CI workflow, .gitignore, and vite.config.ts for Pact integration

Test plan

  • Run pnpm pact:consumer-test in apps/web — contract file generated under apps/web/pacts/
  • Start local broker via docker compose up --detach and run pnpm pact:publish — contract visible in broker UI
  • Run pnpm pact:provider-verify in apps/api — provider verification passes and results published
  • Run root pnpm pact:verify — full end-to-end loop (broker start → publish → verify) succeeds
  • CI workflow passes on push

Made with Cursor

…der verify)

- Add Pact consumer test (apps/web/pact/recipes.pact.test.ts) and publish script
- Add provider verify script and pact npm bindings (apps/api)
- Add docker-compose.yml for local Pact broker
- Add root pact:verify helper script and Turbo pipeline tasks
- Pin apps/api Python to 3.13 (.python-version) and update README accordingly
- Update CI workflow, .gitignore, and vite config for Pact integration

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 13, 2026 09:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces Pact contract testing to the monorepo, enabling an end-to-end consumer → broker publish → provider verification loop for the Recipes API, with local Docker broker support and CI wiring.

Changes:

  • Added Pact consumer tests in apps/web and scripts to publish generated pacts.
  • Added provider verification script + Pact CLI dependency in apps/api.
  • Added a local Pact Broker via Docker Compose and a root helper script, then wired the flow into CI/Turborepo plus updated docs/ignores.

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
turbo.json Adds Turbo tasks for Pact-related commands (cache disabled).
scripts/pact-verify.sh New root helper to run the full broker up → consumer test → publish → provider verify → broker down loop.
README.md Documents Pact workflow and adds pnpm pact:verify to CI description and script list.
pnpm-lock.yaml Locks new @pact-foundation/pact / @pact-foundation/pact-cli dependencies.
PLAN.md Marks contract testing plan items §5.1–5.3 complete.
package.json Adds root Pact scripts (broker up/down, consumer test/publish, provider verify, full verify).
docker-compose.yml Adds local Postgres + Pact Broker services for contract workflow.
apps/web/vite.config.ts Splits Vitest into unit and pact projects (Node env for Pact tests).
apps/web/scripts/pact-publish.sh New script to publish pacts to a broker with branch/version metadata.
apps/web/README.md Documents consumer Pact test and publish usage.
apps/web/pact/recipes.pact.test.ts Adds Pact consumer tests for /recipes and /recipes/{recipe_id} interactions.
apps/web/package.json Adds pact scripts and updates test scripts to target the unit project.
apps/web/biome.json Excludes generated pacts/ output from Biome.
apps/api/scripts/pact-provider-verify.sh New provider verification script that can verify via broker or local pact files, starting uvicorn locally.
apps/api/README.md Documents provider verification and updates venv setup example.
apps/api/package.json Adds provider verify script and Pact CLI dev dependency.
apps/api/.python-version Pins local Python version to 3.13 for the API package.
.vscode/settings.json Adds “healthcheck” to cSpell words list.
.gitignore Ignores generated pact files under apps/web/pacts/.
.github/workflows/ci.yml Runs pnpm pact:verify as part of CI.
.cursor/rules/long-command-options.mdc Adds guideline preferring long-form CLI flags in scripts/docs.
.cursor/rules/google-shell-style.mdc Adds (optional) guideline to follow Google Shell Style Guide for Bash scripts.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/pact-verify.sh
export PACT_PROVIDER_HOSTNAME="${PACT_PROVIDER_HOSTNAME:-127.0.0.1}"
export PACT_PROVIDER_PORT="${PACT_PROVIDER_PORT:-8000}"
export PACT_PROVIDER_TRANSPORT="${PACT_PROVIDER_TRANSPORT:-http}"
export PACT_PROVIDER_BRANCH="${PACT_PROVIDER_BRANCH:-$(git branch --show-current)}"
Comment thread apps/api/package.json
"pact:provider-verify": "bash scripts/pact-provider-verify.sh",
"test": ".venv/bin/python -m pytest -v",
"test:coverage": "pnpm test --cov=app --cov-report=term-missing",
"postinstall": "bash -e -c 'test -d .venv || python3 -m venv .venv; .venv/bin/python -m pip install -e \".[dev]\"'"
Comment thread .github/workflows/ci.yml
Comment thread scripts/pact-verify.sh
Comment on lines +24 to +25
docker compose up --detach

Comment thread scripts/pact-verify.sh
Comment on lines +53 to +57
./node_modules/.bin/pact-broker publish \
"${package_root}/pacts" \
"--consumer-app-version=${version}" \
"--branch=${branch}" \
"--broker-base-url=${broker_url}"
Comment thread apps/api/README.md
Comment on lines +45 to +49
Provider contract verification:

```bash
pnpm pact:provider-verify
```
Comment thread apps/api/README.md
Comment thread apps/api/scripts/pact-provider-verify.sh
Comment thread apps/web/vite.config.ts
Comment on lines +60 to +64
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
mcalthrop and others added 3 commits April 13, 2026 10:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd docs

Update pyproject.toml (requires-python), pyrightconfig.json (pythonVersion),
CI workflow (setup-python), and README (prerequisites + venv setup steps).

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants