Skip to content

CI: build only affected target for single-target PRs#11450

Merged
sensei-hacker merged 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:ci/single-target-build
Mar 22, 2026
Merged

CI: build only affected target for single-target PRs#11450
sensei-hacker merged 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:ci/single-target-build

Conversation

@sensei-hacker
Copy link
Member

Summary

Many pull requests only add or modify a single flight controller target — all changed files are within one src/main/target/<TARGET>/ directory. In those cases it is wasteful to spin up 15 CI runners and rebuild all ~150 targets.

This adds a fast detect job that runs before the build. If every changed file in the PR is inside exactly one src/main/target/<DIR>/ sub-directory, the target names are read directly from that directory's CMakeLists.txt and a single build-single-target job runs ninja <targets> on one runner instead of the usual 15-job matrix.

Any PR that touches files outside a single target directory falls through to the existing full matrix build unchanged. Push events and workflow_call (nightly builds) always do a full build.

Changes

  • New detect job: diffs PR against base branch, outputs single_target=true/false and target_names
  • build matrix job: skipped when single_target == 'true'
  • New build-single-target job: runs ninja <target_names> on a single runner
  • upload-artifacts updated to accept output from either build path

Testing

  • Logic validated locally against several target CMakeLists.txt files (single-target pattern target_stm32xxx(NAME) extracts correctly)
  • Full-build path is structurally unchanged; the if: needs.detect.outputs.single_target != 'true' condition passes through for all non-PR and multi-target scenarios
  • For a PR like Add target BLUEBERRYH743 #11279 (only touches src/main/target/BLUEBERRYH743/), this would build only BLUEBERRYH743 instead of all targets

Related Issues

Reduces CI time and runner cost for the common case of single-target additions/fixes.

When a pull request only modifies files within one directory under
src/main/target/, there is no need to rebuild all ~150 targets.

A new `detect` job inspects the changed files. If every changed file
is inside exactly one src/main/target/<DIR>/ sub-directory, the target
names are read from that directory's CMakeLists.txt and passed to a
new `build-single-target` job which runs `ninja <targets>` on a single
runner instead of the usual 15-job matrix.

Any PR that touches files outside a single target directory falls
through to the existing full matrix build unchanged.

The `upload-artifacts` job is updated to accept output from either
build path.
@sensei-hacker sensei-hacker merged commit 47e98d3 into iNavFlight:maintenance-9.x Mar 22, 2026
22 checks passed
@github-actions
Copy link

Test firmware build ready — commit 4b9137c

Download firmware for PR #11450

228 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant