Skip to content

Only force the full test matrix on API changes when the contract changes#68060

Merged
shahar1 merged 1 commit into
apache:mainfrom
shahar1:selective-checks-narrow-api-full-tests
Jun 5, 2026
Merged

Only force the full test matrix on API changes when the contract changes#68060
shahar1 merged 1 commit into
apache:mainfrom
shahar1:selective-checks-narrow-api-full-tests

Conversation

@shahar1
Copy link
Copy Markdown
Contributor

@shahar1 shahar1 commented Jun 5, 2026

What

Any change under the API directory (airflow-core/src/airflow/api_fastapi/, the
legacy api/, or their test dirs) currently sets full-tests-needed=true — the
whole ~135-job matrix, including every provider's tests. The API tree is large
and churns constantly, so this is the single largest source of unnecessary
full-matrix runs.

But only the API contract changing ripples broadly: the generated OpenAPI
spec, consumed by the UI codegen and the generated clients. Plain API
source/test edits that leave the committed spec untouched do not — and a prek
hook (Generate the FastAPI API spec) regenerates and verifies the spec, so an
unchanged committed spec reliably means an unchanged contract.

This narrows the full-tests trigger from API_FILES to API_CODEGEN_FILES (the
generated spec / client generator):

  • API source/test edit, no spec change → no longer full matrix. Still runs
    the API core test type and the fab provider (via run_api_tests); just no
    longer drags in the entire provider matrix.
  • OpenAPI spec change → still forces the full matrix (locked by a test).

Sizing

Measured by replaying the full_tests_needed gates over 750 merged PRs to main
(30-day window) from their changed-file lists:

  • full-tests-needed fires on 31.6% of PRs.
  • API was the sole reason on 75 PRs (10%); only 12 of those also
    changed the OpenAPI spec.
  • So this spares ~63 full-matrix runs / month (8.4% of PRs) while preserving
    full coverage on the 12 contract-changing PRs.

Part of the CI-capacity work to reduce GitHub Actions runner load (fork PRs run
on public runners and are the constrained resource). Sibling over-trigger fix
for the file-count gate: #68059.

Tests

Updated the four API selective-check cases to assert the new lean selection
(API + Always + Providers[common.compat,fab]), and locked in that an
OpenAPI spec change still forces the full matrix. Full suite green (172 passed).


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

Any change under the API directory (airflow-core/src/airflow/api_fastapi/,
the legacy api/, or their test dirs) forced full-tests-needed=true — the whole
~135-job matrix including every provider's tests. The API tree is large and
churns constantly, so this fired on ~1 in 8 PRs and was, by measurement, the
single largest source of unnecessary full-matrix runs.

But only the API *contract* changing ripples broadly: the generated OpenAPI
spec (consumed by the UI codegen and the generated clients). Plain API
source/test edits that leave the committed spec untouched do not — and a prek
hook regenerates and verifies the spec, so an unchanged spec reliably means an
unchanged contract.

Narrow the full-tests trigger from API_FILES to API_CODEGEN_FILES (the
generated spec / client generator). API source edits still run the `API` test
type and the `fab` provider via run_api_tests; they just no longer drag in the
full provider matrix. Spec changes still force the full matrix.

In a 30-day sample (750 merged PRs) this spares ~63 full-matrix runs while
preserving full coverage on the 12 PRs that changed the contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Sounds reasonable!

@shahar1 shahar1 merged commit d452d27 into apache:main Jun 5, 2026
143 checks passed
@shahar1 shahar1 deleted the selective-checks-narrow-api-full-tests branch June 5, 2026 16:17
@shahar1 shahar1 restored the selective-checks-narrow-api-full-tests branch June 5, 2026 16:17
@shahar1 shahar1 deleted the selective-checks-narrow-api-full-tests branch June 5, 2026 16:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Backport successfully created: v3-2-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test PR Link

potiuk added a commit that referenced this pull request Jun 6, 2026
…ontract changes (#68060) (#68084)

* [v3-2-test] Only force the full test matrix on API changes when the contract changes (#68060)

Any change under the API directory (airflow-core/src/airflow/api_fastapi/,
the legacy api/, or their test dirs) forced full-tests-needed=true — the whole
~135-job matrix including every provider's tests. The API tree is large and
churns constantly, so this fired on ~1 in 8 PRs and was, by measurement, the
single largest source of unnecessary full-matrix runs.

But only the API *contract* changing ripples broadly: the generated OpenAPI
spec (consumed by the UI codegen and the generated clients). Plain API
source/test edits that leave the committed spec untouched do not — and a prek
hook regenerates and verifies the spec, so an unchanged spec reliably means an
unchanged contract.

Narrow the full-tests trigger from API_FILES to API_CODEGEN_FILES (the
generated spec / client generator). API source edits still run the `API` test
type and the `fab` provider via run_api_tests; they just no longer drag in the
full provider matrix. Spec changes still force the full matrix.

In a 30-day sample (750 merged PRs) this spares ~63 full-matrix runs while
preserving full coverage on the 12 PRs that changed the contract.
(cherry picked from commit d452d27)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Fix selective-checks test expectations for v3-2-test (no shared/state)

The backported tests expected mypy-shared-state in the skip-prek-hooks
output, but the shared/state distribution does not exist on v3-2-test,
so that hook is never generated. Drop mypy-shared-state from the two
expected skip-prek-hooks strings so the API-matrix selective-check tests
pass on this branch.

---------

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Jun 6, 2026

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants