feat: Add 'ament_yamllint' package for YAML style validation#567
feat: Add 'ament_yamllint' package for YAML style validation#567frozenreboot wants to merge 5 commits intoament:rollingfrom
Conversation
This introduces ament_yamllint and ament_cmake_yamllint packages to support YAML linting in ROS 2. This work revives and finalizes the original proposal in PR ament#351. Co-authored-by: Scott K Logan <logans@cottsay.net> Signed-off-by: wj <frozenreboot@gmail.com>
|
@cottsay do you mind to take a look ? |
…2026) Signed-off-by: wj <frozenreboot@gmail.com>
88d9d29 to
8fd6c05
Compare
|
@ahcorde Thanks for the detailed review! I have applied all the requested changes:
The CI checks passed successfully. It is ready for re-review. |
cottsay
left a comment
There was a problem hiding this comment.
A few comments.
For the record, I pretty much just copied the original PR from another ament_lint tool and modified it for use with yamllint. I never pushed the PR forward because there wasn't really any outside interest in the tool at the time and most of Chris' feedback was applicable to the other ament_lint tool I had copied the code from.
Happy to help push this forward now that somebody's interested, though.
- Update license to SPDX identifier in setup.py - Add headers to CHANGELOG.rst files - Remove COLCON_IGNORE from IGNORE_MARKERS in main.py Signed-off-by: wj <frozenreboot@gmail.com>
|
I have addressed all the review comments. Ready for re-review. |
cottsay
left a comment
There was a problem hiding this comment.
A couple more changes, but this is looking good. I'll trigger some CI builds on the next round of changes.
The switch for Rolling to RHEL 10 is imminent, and I'm still working on yamllint support there, so we may have to hold off a bit until that work lands.
Thanks!
| # @public | ||
| # | ||
| function(ament_yamllint) | ||
| cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) |
There was a problem hiding this comment.
I believe this is a copy/paste error from another extension. The argument doesn't appear to be used and isn't documented.
| cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) | |
| cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN}) |
| set_tests_properties( | ||
| "${ARG_TESTNAME}" | ||
| PROPERTIES | ||
| LABELS "yamllint;linter" |
There was a problem hiding this comment.
Let's order these alphabetically.
| LABELS "yamllint;linter" | |
| LABELS "linter;yamllint" |
Signed-off-by: wj <frozenreboot@gmail.com>
|
Thanks for the review! I've addressed the feedback in the latest commit:
I also noted your comment about the RHEL 10 transition. I'm ready to wait until the infrastructure work lands, so please take your time triggering the CI. |
|
Cross-link to ros2/ci#847 I'll trigger CI once that change merges. |
|
I can see some tests failing on windows: test\test_yamllint.py:22: in test_yamllint
rc = main(argv=[])
ament_yamllint\main.py:104: in main
report = invoke_yamllint(files, config_file=temp_config.name)
ament_yamllint\main.py:244: in invoke_yamllint
raise subprocess.CalledProcessError(
E subprocess.CalledProcessError: Command '['C:\\pixi_ws\\.pixi\\envs\\default\\Scripts\\yamllint.EXE', '-s', '-f', 'parsable', '-c', 'C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\yamllint__s5pfsoe.yaml', 'ament_yamllint\\configuration\\yamllint.yaml']' returned non-zero exit status 1. |
|
Thanks for your review. I noticed the Windows build failure. The error from Would you be open to me adding a |
994afbe to
16f6415
Compare
…mllint execution Signed-off-by: wj <frozenreboot@gmail.com>
16f6415 to
0ebd40d
Compare
|
I have updated the PR to fix the Windows CI failure. The root cause was a For context, here is the exact trace from the Windows runner: Click to expand error log File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\yamllint\cli.py", line 197, in run
conf = YamlLintConfig(file=args.config_file)
File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\yamllint\config.py", line 41, in __init__
with open(file, mode='rb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\yamllint_fp73nw0q.yaml'I changed the logic to explicitly close() the temporary file before invoking the subprocess, and then manually clean it up using os.remove() in a finally block. I also verified this fix on my fork using a Windows GitHub Actions runner, and it passes perfectly. Could you please re-trigger the CI? |
|
Hi @cottsay, |
Description
This PR adds ament_yamllint to support YAML style validation.
It revive original PR
Origianl proposal PR
#351.
Changes from original proposal
test
Valid YAML files -> Pass
Invalid/Broken YAML files -> Fail (correctly reported syntax errors and lint issues)
Directories with COLCON_IGNORE -> Skipped
Relate issue
#412.
ros-navigation/navigation2#5853, where the lack of a standard YAML linter in ROS 2 was highlighted.