Skip to content

Enable show subverb to print yamllint compliant YAML. - #58

Open
leander-dsouza wants to merge 1 commit into
colcon:masterfrom
leander-dsouza:print-yaml
Open

Enable show subverb to print yamllint compliant YAML.#58
leander-dsouza wants to merge 1 commit into
colcon:masterfrom
leander-dsouza:print-yaml

Conversation

@leander-dsouza

Copy link
Copy Markdown
Contributor

Basic Info

Info Result
Primary OS tested on Ubuntu

Description of contribution in a few bullet points

  • Enabled colcon mixin show to print in a YAML that is compliant with the onboard yamllint linter.
  • Included a custom IndentDumper so that yaml.dump would print indentation that is suited to the linter.
  • Reformatted all the strings to f-strings for brevity.

Description of how this change was tested

  • Add the mixins from the sample colcon-mixin-repository:

    colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
    colcon mixin update default
  • Without this change, the show subverb would yield the following:

    colcon mixin show test
    - coverage-pytest
      pytest-args: ['--cov-report=term']
      pytest-with-coverage: True
    - linters-only
      ctest-args: ['-L', 'linter']
      pytest-args: ['-m', 'linter']
    - linters-skip
      ctest-args: ['-LE', 'linter']
      pytest-args: ['-m', 'not linter']
    - memcheck
      ctest-args: ['-D', 'ExperimentalMemCheck']

    This is printed in a non-standard format, and is not a YAML file.

  • After incorporating this PR, the output is as follows:

    ---
    test:
      coverage-pytest:
        pytest-args:
          - --cov-report=term
        pytest-with-coverage: true
      linters-only:
        ctest-args:
          - -L
          - linter
        pytest-args:
          - -m
          - linter
      linters-skip:
        ctest-args:
          - -LE
          - linter
        pytest-args:
          - -m
          - not linter
      memcheck:
        ctest-args:
          - -D
          - ExperimentalMemCheck
  • You can verify the sanctity of this output by testing it against yamllint:

    colcon mixin show test > test.yaml && yamllint test.yaml 

Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
@codecov-commenter

codecov-commenter commented Nov 26, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.32%. Comparing base (ebedd27) to head (b82b79e).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
colcon_mixin/subverb/show.py 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
+ Coverage   15.30%   15.32%   +0.02%     
==========================================
  Files          11       11              
  Lines         562      561       -1     
  Branches       94       91       -3     
==========================================
  Hits           86       86              
+ Misses        474      473       -1     
  Partials        2        2              

☔ 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.

@leander-dsouza
leander-dsouza marked this pull request as ready for review November 26, 2025 13:37

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

Tested it and I get this as well:

> colcon mixin show test
---
test:
  coverage-pytest:
    pytest-args:
      - --cov-report=term
    pytest-with-coverage: true
  linters-only:
    ctest-args:
      - -L
      - linter
    pytest-args:
      - -m
      - linter
  linters-skip:
    ctest-args:
      - -LE
      - linter
    pytest-args:
      - -m
      - not linter
  memcheck:
    ctest-args:
      - -D
      - ExperimentalMemCheck

An added benefit is that if there are any mixins with malformed yaml formats, it will fail here, which I'm not sure it would have failed with colcon mixin before. Perhaps an good thing to add in another PR to the other functions than show (not part of this PR)

@KmoM88 KmoM88 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm getting the same results testing with the colcon-mixin-repository example

$ colcon mixin show test                                                                                       [9:55:31]
---
test:
  coverage-pytest:
    pytest-args:
      - --cov-report=term
    pytest-with-coverage: true
  linters-only:
    ctest-args:
      - -L
      - linter
    pytest-args:
      - -m
      - linter
  linters-skip:
    ctest-args:
      - -LE
      - linter
    pytest-args:
      - -m
      - not linter
  memcheck:
    ctest-args:
      - -D
      - ExperimentalMemCheck

Also tested that with this feature it produces a valid yamllint while the previous version fails that validation.

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.

4 participants