Skip to content

ci: gate integration tests on unit-test success - #1283

Merged
ogenstad merged 1 commit into
stablefrom
pog-em/pipeline-fail-fast-z0qg3
Aug 28, 2026
Merged

ci: gate integration tests on unit-test success#1283
ogenstad merged 1 commit into
stablefrom
pog-em/pipeline-fail-fast-z0qg3

Conversation

@ogenstad

@ogenstad ogenstad commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

Gate the integration-test job on unit-test success so CI fails fast.

integration-tests-latest-infrahub (which runs on the huge-runners group with a 40-minute timeout) previously listed only:

needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]

Its guard !contains(needs.*.result, 'failure') therefore never inspected the unit-tests matrix, so the expensive integration job started in parallel with unit tests and kept running even when unit tests were red.

Change

Add unit-tests to that needs list. The existing !contains(needs.*.result, 'failure') / 'cancelled') guards then gate the integration job on unit-test success automatically - a matrix job aggregates to failure if any Python-version leg fails, so a single failing leg skips integration. The always() prefix keeps the guard evaluating when unit-tests is skipped (no Python changes), where the python == 'true' clause already skips integration.

The commented-out integration-tests-local-infrahub job's needs is updated to match so it stays correct if re-enabled.

Tradeoff (deliberate and accepted)

This serializes what used to run in parallel: integration tests now start only after every unit-test matrix leg (Python 3.10-3.14) has finished, rather than concurrently with them.

  • On green runs, total pipeline wall-clock increases by roughly the unit-test stage duration, since integration no longer overlaps it.
  • On red runs, we save an entire huge-runner integration pass (up to the 40-minute timeout) that would previously have run - and often finished - alongside already-failing unit tests.

The added latency on passing runs is a known, accepted cost. The goal is to stop spending scarce huge-runners capacity on branches whose unit tests are already failing, where the integration result would not change the outcome.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4cac0c5
Status: ✅  Deploy successful!
Preview URL: https://9431be37.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-em-pipeline-fail-fast-z0.infrahub-sdk-python.pages.dev

View logs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/ci.yml">

<violation number="1" location=".github/workflows/ci.yml:320">
P2: Adding `unit-tests` to this job's `needs` now gates `integration-tests-latest-infrahub` (40-min huge-runner job) not just on test failures but on every step inside the `unit-tests` matrix leg, including the `Upload coverage to Codecov` and `Report coverage for pytest-plugin` steps. Those upload `CODECOV_TOKEN` to an external service, so a transient Codecov outage or upload failure marks the leg `failure` and silently skips integration coverage even when the actual tests are green. Previously integration ran independently of unit-tests/Codecov health. Consider making the coverage-upload steps conditional on test success or not part of the aggregate gate, so a non-test failure does not block the expensive integration job.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/workflows/ci.yml
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint", "unit-tests"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Adding unit-tests to this job's needs now gates integration-tests-latest-infrahub (40-min huge-runner job) not just on test failures but on every step inside the unit-tests matrix leg, including the Upload coverage to Codecov and Report coverage for pytest-plugin steps. Those upload CODECOV_TOKEN to an external service, so a transient Codecov outage or upload failure marks the leg failure and silently skips integration coverage even when the actual tests are green. Previously integration ran independently of unit-tests/Codecov health. Consider making the coverage-upload steps conditional on test success or not part of the aggregate gate, so a non-test failure does not block the expensive integration job.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/ci.yml, line 320:

<comment>Adding `unit-tests` to this job's `needs` now gates `integration-tests-latest-infrahub` (40-min huge-runner job) not just on test failures but on every step inside the `unit-tests` matrix leg, including the `Upload coverage to Codecov` and `Report coverage for pytest-plugin` steps. Those upload `CODECOV_TOKEN` to an external service, so a transient Codecov outage or upload failure marks the leg `failure` and silently skips integration coverage even when the actual tests are green. Previously integration ran independently of unit-tests/Codecov health. Consider making the coverage-upload steps conditional on test success or not part of the aggregate gate, so a non-test failure does not block the expensive integration job.</comment>

<file context>
@@ -317,7 +317,7 @@ jobs:
       !contains(needs.*.result, 'cancelled') &&
       needs.files-changed.outputs.python == 'true'
-    needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
+    needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint", "unit-tests"]
     runs-on:
       group: "huge-runners"
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified against this repo's setup - this specific risk doesn't apply here, so no change is needed.

The concern assumes a failed Codecov upload marks the unit-tests leg as failure. But the repo pins the legacy codecov==2.1.13 uploader, whose upload path is non-fatal by default. From codecov/__init__.py:

except Exception as e:
    write("Error: " + str(e))
    ...
    sys.exit(1 if codecov.required else 0)  # exits 0 unless --required is passed

The steps invoke uv run codecov --flags ... with no --required/-Z, so any upload error (transient 5xx outage, network failure, 4xx) is caught and exits 0. The leg stays success and integration is not spuriously skipped.

The reasoning is sound in the general case (codecov-cli, or this uploader with --required, both fail on upload error) - just not for the current config. Noting for the record: if we ever migrate to codecov-cli or add --required, the clean fix is continue-on-error: true on the coverage-upload steps.

Add unit-tests to the needs list of integration-tests-latest-infrahub so
the expensive huge-runner integration job is skipped when any unit-test
matrix leg fails, instead of running in parallel with failing unit tests.
@ogenstad
ogenstad force-pushed the pog-em/pipeline-fail-fast-z0qg3 branch from 2b0ba2b to 4cac0c5 Compare August 28, 2026 07:50
@github-actions github-actions Bot added the group/ci Issue related to the CI pipeline label Aug 28, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##           stable    #1283      +/-   ##
==========================================
- Coverage   84.24%   84.23%   -0.01%     
==========================================
  Files         147      147              
  Lines       13066    13045      -21     
  Branches     1940     1930      -10     
==========================================
- Hits        11007    10989      -18     
+ Misses       1494     1493       -1     
+ Partials      565      563       -2     
Flag Coverage Δ
integration-tests 39.09% <ø> (-0.09%) ⬇️
python-3.10 57.05% <ø> (+0.06%) ⬆️
python-3.11 57.05% <ø> (+0.07%) ⬆️
python-3.12 57.05% <ø> (+0.06%) ⬆️
python-3.13 57.07% <ø> (+0.07%) ⬆️
python-3.14 57.07% <ø> (+0.07%) ⬆️
python-filler-3.12 23.68% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad
ogenstad marked this pull request as ready for review August 28, 2026 11:03
@ogenstad
ogenstad requested a review from fatih-acar August 28, 2026 11:03

@fatih-acar fatih-acar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch, thank you for the help on this!

@ogenstad
ogenstad merged commit 4eb1b35 into stable Aug 28, 2026
21 checks passed
@ogenstad
ogenstad deleted the pog-em/pipeline-fail-fast-z0qg3 branch August 28, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/ci Issue related to the CI pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants