Skip to content

Show the application order for mixins referencing other mixins - #73

Open
PiousCrossten wants to merge 1 commit into
PiousCrossten/mixins-referencing-mixinsfrom
PiousCrossten/Streach-Goal-Show--render-resolvedgraph
Open

Show the application order for mixins referencing other mixins#73
PiousCrossten wants to merge 1 commit into
PiousCrossten/mixins-referencing-mixinsfrom
PiousCrossten/Streach-Goal-Show--render-resolvedgraph

Conversation

@PiousCrossten

@PiousCrossten PiousCrossten commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Makes the result of mixin composition visible in colcon mixin show. Once a mixin can reference other mixins, the arguments printed for it no longer tell the whole story: the values it inherits, and the order they get applied in, are only discoverable by following the mixin keys by hand. This adds a single application order line for the mixins which have references.

Follow-up to #70, which implements the composition itself (#39).

Given:

build:
  debug:
    cmake-args: ['-DCMAKE_BUILD_TYPE=Debug']
  ccache:
    cmake-args: ['-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']
  dev:
    mixin: ['debug', 'ccache']
    cmake-args: ['-DBUILD_TESTING=ON']
  dev-symlink:
    mixin: ['dev']
    symlink-install: true

colcon mixin show gains the lines marked +:

 build:
 - ccache
   cmake-args: ['-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']
 - debug
   cmake-args: ['-DCMAKE_BUILD_TYPE=Debug']
 - dev
   mixin: ['debug', 'ccache']
   cmake-args: ['-DBUILD_TESTING=ON']
+  application order: debug -> ccache -> dev
 - dev-symlink
   mixin: ['dev']
   symlink-install: True
+  application order: debug -> ccache -> dev -> dev-symlink

and colcon mixin show build dev prints it unindented, matching the existing single mixin output:

mixin: ['debug', 'ccache']
cmake-args: ['-DBUILD_TESTING=ON']
application order: debug -> ccache -> dev

Mixins which don't use the key - debug, ccache, and every mixin in an existing mixin repository - print exactly as they did before.

How it works

_get_application_order() returns None for a mixin without a mixin key or with an empty one, and main() only prints when it returns something. That single check is the only thing standing between the old and the new behaviour, so a mixin which doesn't compose takes no new code path at all.

The order comes from compute_application_order() in colcon_mixin.mixin.order - the same function mixin_argument.py uses to decide what to apply. What is shown is therefore the order which is applied, not a second implementation of the same rules. That includes the duplicates, which are intentional: a mixin reached through several paths is applied once per path to keep last-applied-wins semantics, so a mixin referencing two mixins which both reference debug shows

application order: debug -> fast -> debug -> small -> everything

Circular, unknown and malformed references are caught and rendered inline:

- dev
  mixin: ['coverage']
  application order: unavailable (Mixin 'dev' references unknown mixin 'coverage')

They are reported rather than raised on purpose: show is the command a user reaches for when a mixin file is misbehaving, so a single broken reference must not hide the mixins which are fine.

One small refactor: indent moves out of the argument loop, since the new line is printed after that loop and would otherwise be undefined for a mixin without any arguments.

Tests

test/test_show.py - 8 tests covering the added line for a chain of references, its absence both for plain mixins and for an empty mixin: [], the unindented single mixin output, re-application through several paths, and the three error cases (unknown, circular, malformed).

Known limitation

A mixin whose body is not a dict - base: left with an empty YAML body parses as None - makes colcon mixin show <verb> <referencing-mixin> raise an AttributeError. add_mixins() checks that a mixin file contains a dict but not that each mixin does, so the same file already fails on colcon mixin show without arguments and on colcon build --mixin, both in code this PR doesn't touch. Validating the mixin bodies in add_mixins() would fix all three at once - happy to add that here or open it separately, whichever you prefer.


Stacked on #70 - this PR targets that branch, so the diff here shows only the show subverb work. It'll retarget to master and be rebased once #70 lands.

@codecov-commenter

codecov-commenter commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.11%. Comparing base (df953e1) to head (a8258a6).

Additional details and impacted files
@@                             Coverage Diff                             @@
##           PiousCrossten/mixins-referencing-mixins      #73      +/-   ##
===========================================================================
+ Coverage                                    37.37%   46.11%   +8.74%     
===========================================================================
  Files                                           12       12              
  Lines                                          602      618      +16     
  Branches                                       102      104       +2     
===========================================================================
+ Hits                                           225      285      +60     
+ Misses                                         365      318      -47     
- Partials                                        12       15       +3     

☔ View full report in Codecov by Harness.
📢 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.

Print an additional 'application order' line for every mixin which
references other mixins through a 'mixin' key, so the resolved
composition is visible without following the references by hand. The
order is computed with colcon_mixin.mixin.order and therefore matches
the order which is applied at build time.

Circular, unknown and malformed references are reported inline as
'unavailable (<reason>)' rather than raised, so the remaining mixins are
still being shown. Mixins which don't reference other mixins are shown
exactly as before.

Add tests covering the added line and its indentation in both the list
and the single mixin output, its absence for mixins without references
and for an empty reference list, re-application through several paths
and the three error cases.
@PiousCrossten
PiousCrossten force-pushed the PiousCrossten/Streach-Goal-Show--render-resolvedgraph branch from f2a58c2 to a8258a6 Compare August 20, 2026 02:26
@PiousCrossten
PiousCrossten changed the base branch from PiousCrossten/mixins-referencing-mixins to master August 22, 2026 10:46
@PiousCrossten
PiousCrossten changed the base branch from master to PiousCrossten/mixins-referencing-mixins August 22, 2026 10:48
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