Skip to content

CI: derive arch/source mapping from PlatformIO instead of hardcoding - #11161

Merged
vidplace7 merged 2 commits into
meshtastic:feature/surgical-cifrom
ayysasha:ci/derive-matrix-from-platformio
Jul 23, 2026
Merged

CI: derive arch/source mapping from PlatformIO instead of hardcoding#11161
vidplace7 merged 2 commits into
meshtastic:feature/surgical-cifrom
ayysasha:ci/derive-matrix-from-platformio

Conversation

@ayysasha

@ayysasha ayysasha commented Jul 23, 2026

Copy link
Copy Markdown

Builds on #11151. Three of the hardcoded constants in generate_ci_matrix.py can be derived from PlatformIO, which makes the change-detection self-maintaining when a board/arch is added:

  • Derive platform/<subdir> -> arch from build_src_filter. Each env re-includes its tree via +<platform/X>, so the reverse-map (including the ESP32 family self-grouping) is read from config. Drops ESP32_FAMILY and PLATFORM_SRC_TOPDIRS entirely, and fixes src/platform/extra_variants/ which was unmapped and fell back to a full build.
  • Read [platformio] extra_configs for the env-definition ini globs instead of a hardcoded 2-glob tuple. Anti-rot / future-proofing; no behavior change on the current tree.
  • _emittable is now an allowlist (None/pr/extra) so a retired or typo'd board_level fails closed rather than silently building. (Relevant now that community is being retired in this PR.)
  • Workflow: drop the EXTRA / [[ -s ]] bash plumbing -- the generator no-ops on an absent/empty --changed-files, so it is passed unconditionally.

Verified against real PlatformIO: full, PR, and check sets plus every changed-file scenario produce identical matrices to this PR's head (zero under-build). 28/28 unit tests pass.

Targeted at feature/surgical-ci so a merge folds straight into #11151. Happy to reshape or split however you prefer.

Summary by CodeRabbit

  • Bug Fixes

    • Improved pull-request CI matrix narrowing for both build and check jobs using the changed-files list when in PR context.
    • Updated change detection to derive platform/architecture relationships from PlatformIO metadata for more accurate target coverage.
    • Added stricter filtering so unknown or retired target levels are excluded (fails closed).
  • Tests

    • Expanded CI matrix generation and selection tests to validate derived platform mappings, ini/glob discovery, base-inclusion behavior, and the tightened filtering rules.

Builds on the surgical-CI change so the change-detection is self-maintaining
when a board or arch is added:

- Derive platform/<subdir> -> arch top-dirs from each env's build_src_filter
  (+<platform/X> re-includes). The ESP32 family self-groups, so ESP32_FAMILY
  and PLATFORM_SRC_TOPDIRS are dropped entirely. Also fixes src/platform/
  extra_variants/, which was unmapped and fell back to a full build.
- Read [platformio] extra_configs for the env-definition ini globs instead of
  a hardcoded 2-glob tuple (anti-rot; no behavior change on the current tree).
- Make _emittable an allowlist (None/pr/extra) so a retired or typo'd
  board_level fails closed rather than silently building.
- Workflow: the generator now no-ops on an absent/empty --changed-files, so
  drop the EXTRA / [[ -s ]] bash plumbing and pass it unconditionally.

Verified against real PlatformIO: full, PR, and check matrices plus every
changed-file scenario produce identical output to the PR head. 28/28 unit
tests pass.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f9b80a1a-e338-48b5-863c-1cd36c4dd8e0

📥 Commits

Reviewing files that changed from the base of the PR and between 9867630 and a0600bc.

📒 Files selected for processing (2)
  • bin/generate_ci_matrix.py
  • bin/test_generate_ci_matrix.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/generate_ci_matrix.py

📝 Walkthrough

Walkthrough

The CI matrix generator now derives source-platform and family-base mappings from PlatformIO metadata, applies them during changed-file selection, and uses an allowlist for emitted levels. The PR workflow always passes the changed-files path, with expanded unit tests covering the derived behavior.

Changes

CI matrix narrowing

Layer / File(s) Summary
PlatformIO metadata derivation
bin/generate_ci_matrix.py
Normalizes extra_configs, scans environment definitions, extracts build_src_filter platform inclusions, and derives source-platform and family-base mappings.
Changed-file selection
bin/generate_ci_matrix.py
Uses derived mappings for source-tree and architecture-ini matching, applies allowlisted emission levels, and preserves full-set fallback behavior.
PR workflow and validation
.github/workflows/main_matrix.yml, bin/test_generate_ci_matrix.py
Always passes --changed-files in PR builds and tests source fan-out, metadata derivation, filtering, glob normalization, and base-ini classification.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHub Actions
  participant generate_ci_matrix.py
  participant PlatformIO metadata
  participant CI matrix
  GitHub Actions->>generate_ci_matrix.py: pass changed-files path
  generate_ci_matrix.py->>PlatformIO metadata: load environments and includes
  PlatformIO metadata-->>generate_ci_matrix.py: provide source and base-ini mappings
  generate_ci_matrix.py->>CI matrix: select and emit narrowed environments
Loading

Suggested labels: github_actions

Suggested reviewers: vidplace7

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is substantive, but it does not follow the required template and omits the attestations section. Replace the freeform summary with the repository template and complete the testing/attestation checkboxes, including any affected hardware notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: deriving CI arch/source mapping from PlatformIO instead of hardcoding.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/generate_ci_matrix.py`:
- Around line 131-152: Update base_ini_platform_incl and select_changed so an
arch-base .ini with multiple direct platform includes is represented as an
ambiguous mapping and causes Tier-3 full fallback (None), rather than being
omitted and scoped to one top-level directory. Preserve the existing
single-include family mapping and no-include scoped behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fa3eeead-d5a2-4df9-9159-4781ad0f29bd

📥 Commits

Reviewing files that changed from the base of the PR and between 1e7bb3f and 9867630.

📒 Files selected for processing (3)
  • .github/workflows/main_matrix.yml
  • bin/generate_ci_matrix.py
  • bin/test_generate_ci_matrix.py

Comment thread bin/generate_ci_matrix.py
Follow-up to the derive-from-PlatformIO change, closing two review findings:

- base_ini_platform_incl() now uses the same extra_configs-derived globs as
  env_definition_dirs (via a shared board_ini_globs() helper) instead of the
  hardcoded fallback. Previously the two .ini scans could diverge: a new
  extra_configs glob would be picked up by the env-definition scan but not the
  arch-base scan, so a family base in a new location could be scoped to a single
  top-dir -> under-build. No behavior change on the current tree.
- base_ini_platform_incl() maps each base .ini to the SET of platform trees it
  re-includes (was: only bases with exactly one +<platform/X>). A base that
  re-includes multiple trees now fans out to all of them in Tier 2b, a safe
  superset, rather than being silently dropped (which scoped it to one top-dir
  -> under-build). Fails open, not closed.

Verified: 31/31 unit tests (3 new: multi-include mapping, Tier 2b superset,
board_ini_globs). Real-PlatformIO matrix output identical to the PR-head
baseline across full/PR/check sets and every changed-file scenario; the
extra_variants scenario is the expected 47-env superset. No under-build.
@vidplace7
vidplace7 merged commit 5e74d7b into meshtastic:feature/surgical-ci Jul 23, 2026
97 of 99 checks passed
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.

2 participants