Skip to content
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

test: add tests for pre-commit-hooks #49

Merged
merged 3 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
35 changes: 35 additions & 0 deletions tests/pre-commit-hooks/prettier-xacro/calibration.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<robot name="vehicle" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:arg name="config_dir" default="$(find crow_sensor_description)/config"/>
<xacro:arg name="gpu" default="false"/>

<xacro:include filename="$(find velodyne_description)/urdf/VLP-16.urdf.xacro"/>
<xacro:include filename="$(find imu_description)/urdf/imu.xacro"/>
<xacro:property name="calibration" value="${load_yaml('$(arg config_dir)/sensors_calibration.yaml')}"/>

<!-- lidar -->
<xacro:VLP-16 parent="base_link" name="velodyne_top" topic="/points_raw" hz="10" samples="220" gpu="$(arg gpu)">
<origin
xyz="${calibration['base_link']['velodyne_top_base_link']['x']}
${calibration['base_link']['velodyne_top_base_link']['y']}
${calibration['base_link']['velodyne_top_base_link']['z']}"
rpy="${calibration['base_link']['velodyne_top_base_link']['roll']}
${calibration['base_link']['velodyne_top_base_link']['pitch']}
${calibration['base_link']['velodyne_top_base_link']['yaw']}"
/>
</xacro:VLP-16>

<!-- imu -->
<xacro:imu_macro
parent="base_link"
name="imu"
namespace=""
x="${calibration['base_link']['imu_link']['x']}"
y="${calibration['base_link']['imu_link']['y']}"
z="${calibration['base_link']['imu_link']['z']}"
roll="${calibration['base_link']['imu_link']['roll']}"
pitch="${calibration['base_link']['imu_link']['pitch']}"
yaw="${calibration['base_link']['imu_link']['yaw']}"
fps="100"
/>
</robot>
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,4 @@
#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/.*