From 08c5724f325069e180e6b0a33b390de3a38d4c0c Mon Sep 17 00:00:00 2001 From: Kenji Miyake Date: Wed, 23 Mar 2022 12:26:03 +0900 Subject: [PATCH] test: add tests for pre-commit-hooks Signed-off-by: Kenji Miyake --- .github/workflows/test-pre-commit-hooks.yaml | 16 +++ .../prettier-launch-xml/sample.launch.xml | 110 ++++++++++++++++++ .../prettier-package-xml/normal/package.xml | 24 ++++ .../prettier-xacro/sample.xacro | 18 +++ .../ros-include-guard/include/foo_bar/baz.hpp | 3 + .../sort-package-xml/normal/package.xml | 24 ++++ .../test-pre-commit-hooks.yaml | 14 +++ 7 files changed, 209 insertions(+) create mode 100644 .github/workflows/test-pre-commit-hooks.yaml create mode 100644 tests/pre-commit-hooks/prettier-launch-xml/sample.launch.xml create mode 100644 tests/pre-commit-hooks/prettier-package-xml/normal/package.xml create mode 100644 tests/pre-commit-hooks/prettier-xacro/sample.xacro create mode 100644 tests/pre-commit-hooks/ros-include-guard/include/foo_bar/baz.hpp create mode 100644 tests/pre-commit-hooks/sort-package-xml/normal/package.xml create mode 100644 tests/pre-commit-hooks/test-pre-commit-hooks.yaml diff --git a/.github/workflows/test-pre-commit-hooks.yaml b/.github/workflows/test-pre-commit-hooks.yaml new file mode 100644 index 0000000..1e86fcf --- /dev/null +++ b/.github/workflows/test-pre-commit-hooks.yaml @@ -0,0 +1,16 @@ +name: test-pre-commit-hooks + +on: + pull_request: + +jobs: + test-pre-commit-hooks: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Run pre-commit + uses: autowarefoundation/autoware-github-actions/pre-commit@v1 + with: + pre-commit-config: tests/pre-commit-hooks/test-pre-commit-hooks.yaml diff --git a/tests/pre-commit-hooks/prettier-launch-xml/sample.launch.xml b/tests/pre-commit-hooks/prettier-launch-xml/sample.launch.xml new file mode 100644 index 0000000..9b6271d --- /dev/null +++ b/tests/pre-commit-hooks/prettier-launch-xml/sample.launch.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/pre-commit-hooks/prettier-package-xml/normal/package.xml b/tests/pre-commit-hooks/prettier-package-xml/normal/package.xml new file mode 100644 index 0000000..da42506 --- /dev/null +++ b/tests/pre-commit-hooks/prettier-package-xml/normal/package.xml @@ -0,0 +1,24 @@ + + + + rospkg + 0.0.0 + The dummy package to test sort_package_xml + Takagi, Isamu + Apache License 2.0 + + ament_cmake + + aaaaa + bbbbb + ccccc + ddddd + eeeee + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/tests/pre-commit-hooks/prettier-xacro/sample.xacro b/tests/pre-commit-hooks/prettier-xacro/sample.xacro new file mode 100644 index 0000000..c915174 --- /dev/null +++ b/tests/pre-commit-hooks/prettier-xacro/sample.xacro @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/tests/pre-commit-hooks/ros-include-guard/include/foo_bar/baz.hpp b/tests/pre-commit-hooks/ros-include-guard/include/foo_bar/baz.hpp new file mode 100644 index 0000000..0ff1033 --- /dev/null +++ b/tests/pre-commit-hooks/ros-include-guard/include/foo_bar/baz.hpp @@ -0,0 +1,3 @@ +#ifndef FOO_BAR__BAZ_HPP_ +#define FOO_BAR__BAZ_HPP_ +#endif // FOO_BAR__BAZ_HPP_ diff --git a/tests/pre-commit-hooks/sort-package-xml/normal/package.xml b/tests/pre-commit-hooks/sort-package-xml/normal/package.xml new file mode 100644 index 0000000..da42506 --- /dev/null +++ b/tests/pre-commit-hooks/sort-package-xml/normal/package.xml @@ -0,0 +1,24 @@ + + + + rospkg + 0.0.0 + The dummy package to test sort_package_xml + Takagi, Isamu + Apache License 2.0 + + ament_cmake + + aaaaa + bbbbb + ccccc + ddddd + eeeee + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/tests/pre-commit-hooks/test-pre-commit-hooks.yaml b/tests/pre-commit-hooks/test-pre-commit-hooks.yaml new file mode 100644 index 0000000..47bffee --- /dev/null +++ b/tests/pre-commit-hooks/test-pre-commit-hooks.yaml @@ -0,0 +1,14 @@ +repos: + - repo: . + rev: HEAD + hooks: + - id: prettier-xacro + files: tests/pre-commit-hooks/prettier-xacro/.* + - id: prettier-launch-xml + files: tests/pre-commit-hooks/prettier-launch-xml/.* + - id: prettier-package-xml + files: tests/pre-commit-hooks/prettier-package-xml/.* + - id: sort-package-xml + files: tests/pre-commit-hooks/sort-package-xml/.* + - id: ros-include-guard + files: tests/pre-commit-hooks/ros-include-guard/.*