Skip to content

Commit

Permalink
test: add tests for pre-commit-hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
  • Loading branch information
Kenji Miyake committed Mar 23, 2022
1 parent c97f757 commit f7fa94c
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test-pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -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
110 changes: 110 additions & 0 deletions tests/pre-commit-hooks/prettier-launch-xml/sample.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<!-- Essential parameters -->
<arg name="map_path" description="point cloud and lanelet2 map directory path"/>
<arg name="vehicle_model" description="vehicle model name"/>
<arg name="sensor_model" description="sensor model name"/>
<arg name="use_pointcloud_container" default="true" description="launch pointcloud container"/>
<arg name="pointcloud_container_name" default="pointcloud_container"/>
<!-- Optional parameters -->
<arg name="rviz" default="true" description="launch rviz"/>
<arg name="lanelet2_map_file" default="lanelet2_map.osm" description="lanelet2 map file name"/>
<arg name="pointcloud_map_file" default="pointcloud_map.pcd" description="pointcloud map file name"/>

<!-- Global parameters -->
<!-- Do not add "group" in order to propagate global parameters -->
<include file="$(find-pkg-share global_parameter_loader)/launch/global_params.launch.py">
<arg name="vehicle_model" value="$(var vehicle_model)"/>
</include>

<!-- Pointcloud container -->
<group>
<include file="$(find-pkg-share autoware_launch)/launch/pointcloud_container.launch.py" if="$(var use_pointcloud_container)">
<arg name="use_multithread" value="true"/>
<arg name="container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

<!-- Vehicle -->
<group>
<include file="$(find-pkg-share tier4_vehicle_launch)/launch/vehicle.launch.xml">
<arg name="vehicle_model" value="$(var vehicle_model)"/>
<arg name="sensor_model" value="$(var sensor_model)"/>
<arg name="launch_vehicle_interface" value="true"/>
</include>
</group>

<!-- System -->
<group>
<include file="$(find-pkg-share tier4_system_launch)/launch/system.launch.xml">
<arg name="run_mode" value="online"/>
<arg name="sensor_model" value="$(var sensor_model)"/>
</include>
</group>

<!-- Map -->
<group>
<include file="$(find-pkg-share tier4_map_launch)/launch/map.launch.py">
<arg name="lanelet2_map_path" value="$(var map_path)/$(var lanelet2_map_file)"/>
<arg name="pointcloud_map_path" value="$(var map_path)/$(var pointcloud_map_file)"/>
</include>
</group>

<!-- Sensing -->
<group>
<include file="$(find-pkg-share tier4_sensing_launch)/launch/sensing.launch.xml">
<arg name="launch_driver" value="true"/>
<arg name="sensor_model" value="$(var sensor_model)"/>
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="vehicle_mirror_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/mirror.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

<!-- Localization -->
<group>
<include file="$(find-pkg-share tier4_localization_launch)/launch/localization.launch.xml"/>
</group>

<!-- Perception -->
<group>
<include file="$(find-pkg-share tier4_perception_launch)/launch/perception.launch.xml">
<arg name="mode" value="lidar"/>
<arg name="vehicle_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
</include>
</group>

<!-- Planning -->
<group>
<include file="$(find-pkg-share tier4_planning_launch)/launch/planning.launch.xml">
<arg name="vehicle_info_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
</include>
</group>

<!-- Control -->
<group>
<include file="$(find-pkg-share tier4_control_launch)/launch/control.launch.py">
<arg name="lateral_controller_mode" value="mpc_follower"/>
<arg name="vehicle_info_param_file" value="$(find-pkg-share $(var vehicle_model)_description)/config/vehicle_info.param.yaml"/>
</include>
</group>

<!-- Tools -->
<group>
<!-- Rviz -->
<node
pkg="rviz2"
exec="rviz2"
name="rviz2"
output="screen"
args="-d $(find-pkg-share autoware_launch)/rviz/autoware.rviz -s $(find-pkg-share autoware_launch)/rviz/image/autoware.png"
if="$(var rviz)"
/>

<!-- Web Controller -->
<include file="$(find-pkg-share web_controller)/launch/web_controller.launch.xml"/>
</group>
</launch>
24 changes: 24 additions & 0 deletions tests/pre-commit-hooks/prettier-package-xml/normal/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rospkg</name>
<version>0.0.0</version>
<description>The dummy package to test sort_package_xml</description>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>aaaaa</depend>
<depend>bbbbb</depend>
<depend>ccccc</depend>
<depend>ddddd</depend>
<depend>eeeee</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
18 changes: 18 additions & 0 deletions tests/pre-commit-hooks/prettier-xacro/sample.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<!-- load parameter -->
<xacro:property
name="vehicle_info"
value="${load_yaml('$(find sample_vehicle_description)/config/vehicle_info.param.yaml')}"
/>

<!-- vehicle body -->
<link name="base_link">
<visual>
<origin xyz="${vehicle_info['/**']['ros__parameters']['wheel_base']/2.0} 0 0" rpy="${pi/2.0} 0 ${pi}"/>
<geometry>
<mesh filename="package://sample_vehicle_description/mesh/lexus.dae" scale="1 1 1"/>
</geometry>
</visual>
</link>
</robot>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifndef FOO_BAR__BAZ_HPP_
#define FOO_BAR__BAZ_HPP_
#endif // FOO_BAR__BAZ_HPP_
24 changes: 24 additions & 0 deletions tests/pre-commit-hooks/sort-package-xml/normal/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rospkg</name>
<version>0.0.0</version>
<description>The dummy package to test sort_package_xml</description>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>aaaaa</depend>
<depend>bbbbb</depend>
<depend>ccccc</depend>
<depend>ddddd</depend>
<depend>eeeee</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
14 changes: 14 additions & 0 deletions tests/pre-commit-hooks/test-pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -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/.*

0 comments on commit f7fa94c

Please sign in to comment.