Skip to content

Add support for mixin composition#60

Open
ArizmendiWan wants to merge 2 commits intocolcon:masterfrom
ArizmendiWan:feature/mixin-composition
Open

Add support for mixin composition#60
ArizmendiWan wants to merge 2 commits intocolcon:masterfrom
ArizmendiWan:feature/mixin-composition

Conversation

@ArizmendiWan
Copy link
Copy Markdown

@ArizmendiWan ArizmendiWan commented Mar 27, 2026

Allows mixins to reference other mixins via a reserved mixin key. Resolves #39.

A mixin definition can now include a list of other mixin names to compose:

build:
  debug:
    cmake-args: ["-DCMAKE_BUILD_TYPE=Debug"]
  asan:
    cmake-args: ["-DSANITIZE_ADDRESS=ON"]
  debug-asan:
    mixin: ["debug", "asan"]
    cmake-args: ["-DEXTRA_FLAG=1"]

Using --mixin debug-asan resolves all referenced mixins recursively before applying the mixin's own arguments. Precedence matches existing CLI --mixin behavior:

  • Lists are prepended (later mixin values come first, matching _update_args)
  • Scalars between references use first-write-wins (matching how _update_args skips already-set scalars)
  • Own args always override referenced values

Also adds validation and tests for:

  • missing references
  • composition cycles
  • invalid mixin definitions
  • parser-level composed mixin application and error paths

Existing mixin files without a mixin key are unaffected.

Allow mixins to reference other mixins via a 'mixin' key containing a
list of mixin names. Referenced mixins are resolved recursively with
cycle detection, and their arguments are merged left-to-right before
the composing mixin's own arguments are applied on top.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: ArizmendiWan <2311602492@qq.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.09%. Comparing base (ebedd27) to head (7822bef).

Files with missing lines Patch % Lines
colcon_mixin/mixin/__init__.py 87.09% 2 Missing and 2 partials ⚠️
colcon_mixin/mixin/mixin_argument.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
+ Coverage   15.30%   19.09%   +3.79%     
==========================================
  Files          11       11              
  Lines         562      597      +35     
  Branches       94      106      +12     
==========================================
+ Hits           86      114      +28     
- Misses        474      479       +5     
- Partials        2        4       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@ArizmendiWan
Copy link
Copy Markdown
Author

Added a follow up commit to tighten mixin composition validation.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add mixin compositing

2 participants