Skip to content

Run v1/v2 test jobs only when their side of the SDK changes - #233

Merged
amarcozzi merged 1 commit into
mainfrom
ci-split-v1-v2-tests
Oct 13, 2026
Merged

amarcozzi merged 1 commit into
mainfrom
ci-split-v1-v2-tests

Conversation

@amarcozzi

Copy link
Copy Markdown
Contributor

PRs to main used to run both live suites, test-v1 and test-v2, whatever changed. Each takes about 15 minutes against prod and starts real prod jobs. Now each suite runs only when its side of the SDK is affected.

Changes

Only .github/workflows/tests_main.yml changes.

  • A new changes job lists the PR's changed files through the GitHub API, including the old path of a renamed file, and classifies each one:

    Changed files Runs
    fastfuels_sdk/v1/**, tests/v1/** v1
    fastfuels_sdk/v2/**, tests/v2/** v2
    docs/**, *.md, mkdocs.yml, LICENSE, lint config, other workflows neither
    everything else: pyproject.toml, uv.lock, fastfuels_sdk/__init__.py, tests/__init__.py, tests/conftest.py, tests/data/**, this workflow, any unrecognised path both

    The shared set comes from what the suites actually import. fastfuels_sdk/__init__.py imports all of v1, and both suites use tests/__init__.py, tests/conftest.py and tests/data/.

  • test-v1 and test-v2 use job-level if: conditions rather than an on.pull_request.paths filter. An unaffected suite reports "skipped", which branch protection accepts, so test-v1 can still be made a required check.

  • If the changes job fails, both suites run. Otherwise a broken changes job would report test-v1 as "skipped" and let a PR merge untested.

  • The changes job only has pull-requests: read. It doesn't check out code or see the API-key secrets.

Known gap

A v1-only change doesn't run test-v2, but import fastfuels_sdk.v2 currently loads v1 too (eager re-export in fastfuels_sdk/__init__.py). #232 makes that import lazy, which removes the coupling.

Verification

  • actionlint and the GitHub workflow schema check pass, and so does pre-commit.
  • The classification script was run locally on 16 sets of changed files, and each gave the expected v1/v2 result. The sets covered v1-only, v2-only, mixed, shared, docs-only, renames, unrecognised paths and an empty PR.
  • This PR changes tests_main.yml itself, so its own run classifies as "both" and runs both suites. The skip path will show on the next v1-only or v2-only PR.

Add a changes job that classifies the PR's changed files and gate test-v1
and test-v2 on its outputs with job-level if: conditions, so an unaffected
suite reports skipped instead of hitting the live prod API. Shared paths
(pyproject.toml, uv.lock, top-level package, test scaffolding and data,
this workflow, unrecognised paths) run both; docs, markdown, lint config
and other workflows run neither. Detection failure runs both.
@amarcozzi amarcozzi added the 🧪 testing You're not done until you write tests label Oct 13, 2026
@amarcozzi amarcozzi self-assigned this Oct 13, 2026
@amarcozzi
amarcozzi merged commit dc666bb into main Oct 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧪 testing You're not done until you write tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant