Run Shared Contract Tests Across All Languages in CI
Scenario
Trace a CI workflow that checks out one commit and runs the shared booking fixtures against JavaScript, Python, and Go.
- 1Step 1 · Checkout repository and load shared fixtures
- 2Step 2 · Run JavaScript & Python test runners
- 3Step 3 · Run Go test runner (missing negative guard)
name: Shared contracts
on: [push, pull_request]
jobs:
contracts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-go@v5
with:
go-version: "1.24"
- run: npm run test:examplesTry it yourself
Step through the CI job to see what happens if Go drifts from Python and JavaScript.
| Case | State after the step |
|---|---|
| Step 1 · Checkout repository and load shared fixtures | — |
| Step 2 · Run JavaScript & Python test runners | — |
| Step 3 · Run Go test runner (missing negative guard) | — |
Reveal the explanation
- Step 1 · Checkout repository and load shared fixtures
All three runners read the exact same input/expected cases from one checked-in fixture file.
- Step 2 · Run JavaScript & Python test runners
JS passes 5/5 cases; Python passes 5/5 cases.
- Step 3 · Run Go test runner (missing negative guard)
Go fails case bk-invalid-negative → entire CI job turns red before merge.
Never report a language as verified unless its actual runner executed. A shared CI matrix executes every language you ship and flags drift immediately.
Download shared test cases
Your turn
Add a step name and command to the workflow YAML for running a Python contract test script alongside `npm test`.
Common mistake Running only JavaScript tests in CI while claiming Python and Go are also verified.
Check your work
Two explicit steps: `run: npm test` and `run: python3 scripts/verify-python-contracts.py`, reporting each runner’s result separately.
Quick check
This browser could not save your progress. Changes last until you leave the page.