- Node.js+: This project requires a recent Node.js version
- npm: Included with Node.js
- Build Tool: Vite - Fast development server with HMR
- Test Framework: Vitest - Vite-native testing framework
- Linting & Formatting: Biome - Unified toolchain for code quality
- Type Safety: TypeScript with strict mode enabled
- React: Function components with React Router
This is an example of how to set up a deployment pipeline for a consumer that does not make use of PactFlow/Pact Broker webhooks. This flow is a good alternative where the use of webhooks is not possible due to firewalls.
Webhooks are typically used to ensure that a recently change pact gets verified by the provider immediately, rather than waiting for a provider build to run. This workflow ensures changed pacts are verified immediately by checking out the provider codebase in the consumer's pipeline, and running the verification as part of the consumer's own tests.
The downside of this flow is that it requires the consumer to have access to the provider code, and understand how to execute the tests.
The deployment pipeline runs in Github Actions, and is defined in the build.yml file.
The Test, Can-I-Deploy and Deploy steps are identical to the flow that uses webhooks. The Verify step is the extra part that usually runs out of bound in the provider's CI environment.
- Test
- Run tests
- Publish pacts
- Verify (set to continue workflow on error)
- Check if a verification from the master version of the provider already exists using can-i-deploy, raise error if it does exist so we do not continue with the rest of the steps
- Checkout provider
- Verify pacts
- Publish verification results
- Can-I-Deploy
- Check if the current version of the consumer is compatible with the production version of the provider.
- Deploy
- Deploy application
- Tag the deployed version in PactFlow as 'prod'
This consumer requires a running provider service for local development.
In terminal 1 - Start the provider:
git clone https://github.com/pactflow/example-provider
cd example-provider
npm install
npm run devIn terminal 2 - Start this consumer:
npm install
npm run devThe consumer runs at http://localhost:3000 and connects to the provider at http://localhost:8080 by default.
The dev server will automatically check if the provider is available and show helpful instructions if it's not running.
Copy .env.local.example to .env.local to customize the provider URL:
cp .env.local.example .env.localThe default provider URL is http://localhost:8080. Modify VITE_API_BASE_URL in .env.local if your provider runs on a different port.
npm run dev- Start the Vite development server with hot module replacementnpm test- Run all tests with Vitestnpm run test:pact- Run only Pact contract testsnpm run type-check- Check TypeScript types without emitting filesnpm run check- Run all Biome checks (linting + formatting)npm run check:fix- Automatically fix Biome issues (use with caution)
This project uses Biome for linting and formatting. Configuration is in biome.jsonc.
The CI pipeline runs:
- Type checking (
npm run type-check) - Code quality checks (
npm run check) - Build validation (
npm run build) - Tests (
npm test)