Curriculum

Curriculum

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.

  1. 1Step 1 · Checkout repository and load shared fixtures
  2. 2Step 2 · Run JavaScript & Python test runners
  3. 3Step 3 · Run Go test runner (missing negative guard)
GitHub Actions
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:examples

Try it yourself

Step through the CI job to see what happens if Go drifts from Python and JavaScript.

Reveal the explanation
  1. Step 1 · Checkout repository and load shared fixtures

    All three runners read the exact same input/expected cases from one checked-in fixture file.

  2. Step 2 · Run JavaScript & Python test runners

    JS passes 5/5 cases; Python passes 5/5 cases.

  3. 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.

Review first
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

If your CI pipeline ran Node.js and Python tests but Go was not installed, how should the report describe Go?
Show the answer and reasoning

Correct answer Report Node.js and Python as executed and explicitly mark Go as not executed

Honest verification separates executed runtimes from unexecuted reference code.