-
Notifications
You must be signed in to change notification settings - Fork 128
feat: Add 'ament_yamllint' package for YAML style validation #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frozenreboot
wants to merge
5
commits into
ament:rolling
Choose a base branch
from
frozenreboot:feat/add-ament-yamllint
base: rolling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25c1e79
Add 'ament_yamllint' package for YAML style validation
frozenreboot 8fd6c05
Refactor: Apply review comments (Update version to 0.20.3, Copyright …
frozenreboot 379da3b
Address review comments from cottsay
frozenreboot 320cd2c
fix: clean up ament_yamllint.cmake test configuration
frozenreboot 0ebd40d
fix: resolve Windows PermissionError for NamedTemporaryFile during ya…
frozenreboot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Changelog for package ament_cmake_yamllint | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| cmake_minimum_required(VERSION 3.20) | ||
|
|
||
| project(ament_cmake_yamllint NONE) | ||
|
|
||
| find_package(ament_cmake_core REQUIRED) | ||
| find_package(ament_cmake_test REQUIRED) | ||
|
|
||
| ament_package( | ||
| CONFIG_EXTRAS | ||
| cmake/ament_yamllint.cmake | ||
| ) | ||
|
|
||
| install( | ||
| DIRECTORY cmake | ||
| DESTINATION share/${PROJECT_NAME} | ||
| ) | ||
|
|
||
| if(BUILD_TESTING) | ||
| find_package(ament_cmake_copyright REQUIRED) | ||
| ament_copyright() | ||
|
|
||
| find_package(ament_cmake_lint_cmake REQUIRED) | ||
| ament_lint_cmake() | ||
|
|
||
| find_package(ament_cmake_xmllint REQUIRED) | ||
| ament_xmllint() | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Copyright 2026 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # | ||
| # Add a test to check YAML files with yamllint. | ||
| # | ||
| # :param TESTNAME: the name of the test, default: "yamllint" | ||
| # :type TESTNAME: string | ||
| # :param ARGN: the files or directories to check | ||
| # :type ARGN: list of strings | ||
| # | ||
| # @public | ||
| # | ||
| function(ament_yamllint) | ||
| cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN}) | ||
| if(NOT ARG_TESTNAME) | ||
| set(ARG_TESTNAME "yamllint") | ||
| endif() | ||
|
|
||
| find_program(ament_yamllint_BIN NAMES "ament_yamllint") | ||
| if(NOT ament_yamllint_BIN) | ||
| message(FATAL_ERROR "ament_yamllint() could not find program 'ament_yamllint'") | ||
| endif() | ||
|
|
||
| set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") | ||
| set(cmd "${ament_yamllint_BIN}" "--xunit-file" "${result_file}") | ||
| list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) | ||
|
|
||
| find_program(yamllint_BIN NAMES "yamllint") | ||
|
|
||
| if(NOT yamllint_BIN) | ||
| if(${CMAKE_VERSION} VERSION_LESS "3.8.0") | ||
| message(WARNING "WARNING: 'yamllint' not found, skipping yamllint test creation") | ||
| return() | ||
| endif() | ||
| endif() | ||
|
|
||
| file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_yamllint") | ||
| ament_add_test( | ||
| "${ARG_TESTNAME}" | ||
| COMMAND ${cmd} | ||
| OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_yamllint/${ARG_TESTNAME}.txt" | ||
| RESULT_FILE "${result_file}" | ||
| WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| ) | ||
| set_tests_properties( | ||
| "${ARG_TESTNAME}" | ||
| PROPERTIES | ||
| LABELS "linter;yamllint" | ||
| ) | ||
| if(NOT yamllint_BIN) | ||
| set_tests_properties( | ||
| "${ARG_TESTNAME}" | ||
| PROPERTIES | ||
| DISABLED TRUE | ||
| ) | ||
| endif() | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ament_yamllint | ||
| ============== | ||
|
|
||
| Checks YAML files using `yamllint <https://yamllint.readthedocs.io>`_. | ||
|
|
||
| Files with the following extensions are being considered: ``.yaml``, ``.yml``. | ||
|
|
||
| How to run the check from the command line? | ||
|
|
||
| The command line tool is provided by the package `ament_yamllint | ||
| <https://github.com/ament/ament_lint>`_. | ||
|
|
||
| How to run the check from within a CMake ament package as part of the tests? | ||
| ---------------------------------------------------------------------------- | ||
|
frozenreboot marked this conversation as resolved.
|
||
|
|
||
| ``package.xml``: | ||
|
|
||
| .. code:: xml | ||
|
|
||
| <buildtool_depend>ament_cmake</buildtool_depend> | ||
| <test_depend>ament_cmake_yamllint</test_depend> | ||
|
|
||
| ``CMakeLists.txt``: | ||
|
|
||
| .. code:: cmake | ||
|
|
||
| find_package(ament_cmake REQUIRED) | ||
| if(BUILD_TESTING) | ||
| find_package(ament_cmake_yamllint REQUIRED) | ||
| ament_yamllint() | ||
| endif() | ||
|
|
||
| The documentation of the package `ament_cmake_test | ||
| <https://github.com/ament/ament_cmake>`_ provides more information on testing | ||
| in CMake ament packages. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
| <package format="2"> | ||
| <name>ament_cmake_yamllint</name> | ||
| <version>0.20.3</version> | ||
| <description> | ||
| The CMake API for ament_yamllint to check YAML file using yamllint. | ||
| </description> | ||
|
|
||
| <maintainer email="logans@cottsay.net">Scott K Logan</maintainer> | ||
| <maintainer email="ahcorde@gmail.com">Alejandro Hernández Cordero</maintainer> | ||
|
|
||
| <license>Apache License 2.0</license> | ||
|
|
||
| <author email="frozenreboot@gmail.com">Woojin Jung</author> | ||
|
|
||
| <buildtool_depend>ament_cmake_core</buildtool_depend> | ||
| <buildtool_depend>ament_cmake_test</buildtool_depend> | ||
|
|
||
| <buildtool_export_depend>ament_cmake_test</buildtool_export_depend> | ||
| <buildtool_export_depend>ament_yamllint</buildtool_export_depend> | ||
|
|
||
| <test_depend>ament_cmake_copyright</test_depend> | ||
| <test_depend>ament_cmake_lint_cmake</test_depend> | ||
| <test_depend>ament_cmake_xmllint</test_depend> | ||
|
|
||
| <export> | ||
| <build_type>ament_cmake</build_type> | ||
| </export> | ||
| </package> |
|
frozenreboot marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Changelog for package ament_yamllint | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| extends: default | ||
|
|
||
| rules: | ||
| document-start: disable | ||
| indentation: | ||
| indent-sequences: consistent | ||
| line-length: disable | ||
| new-lines: disable |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.