Skip to content

Commit

Permalink
Add pre-commit hooks (#102)
Browse files Browse the repository at this point in the history
* add commit hooks file

* add yaml lint & format

* fix tab/spaces

* increase line length

* disable linting for now

* format yaml files

* add ci for pre commit

* remove version

* add xml formatting

* format xml

* add EOF fixer

* format EOF

* add trailing wihtespace

* format trailing whitespace

* add destroyed symlinks

* add check-executables-have-shebangs

* add more checks

* add clang format

* format cpp

* add deps

* are you sudo?

* fix

* add python

* format python
  • Loading branch information
senceryazici authored Dec 19, 2024
1 parent 31a6243 commit 33d5b01
Show file tree
Hide file tree
Showing 114 changed files with 1,130 additions and 1,054 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BasedOnStyle: Google
---
BasedOnStyle: Google
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
github: [senceryazici, ituauvteam]
buy_me_a_coffee: ituauvteam
custom: ["https://auv.itu.edu.tr/sponsorship.html"]
11 changes: 5 additions & 6 deletions .github/workflows/build_and_push_images.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: main docker images

on:
Expand All @@ -7,8 +8,8 @@ on:
description: 'Type of image to build [main, base]'
required: true
type: string
concurrency:

concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || github.ref }}
cancel-in-progress: true

Expand All @@ -21,7 +22,7 @@ env:
jobs:
build-and-push:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
Expand All @@ -47,7 +48,7 @@ jobs:
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -98,7 +99,6 @@ jobs:
# build-and-push-arm64:
# runs-on: self-hosted

# strategy:
# matrix:
# host: [tegra]
Expand All @@ -115,7 +115,6 @@ jobs:
# uses: docker/setup-qemu-action@v3
# with:
# platforms: ${{ matrix.platform }}

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3.3.0
# with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_and_push_scheduled.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: scheduled build and push

# scheduled run every day at 00:00 GMT +03:00
Expand All @@ -12,7 +13,7 @@ on:
schedule:
- cron: "0 21 * * *"

concurrency:
concurrency:
group: scheduled-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || github.ref }}
cancel-in-progress: true

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Pre-commit Checks

on:
workflow_call:

jobs:
pre-commit:
name: Run Pre-commit Checks
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4

- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-format libxml2-utils
- name: Run pre-commit
run: pre-commit run --all-files

- name: Check for modifications
run: git diff --exit-code
3 changes: 2 additions & 1 deletion .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: industrial_ci

on:
Expand All @@ -23,7 +24,7 @@ jobs:
directory=$(mktemp -d)
echo build_directory=$directory >> $GITHUB_ENV
- uses: ros-industrial/industrial_ci@master
env:
env:
ROS_DISTRO: noetic
UPSTREAM_WORKSPACE: third_party.repos
ADDITIONAL_DEBS: lld
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: CI

on:
Expand All @@ -6,11 +7,14 @@ on:
- main
pull_request:

concurrency:
concurrency:
group: main-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || github.ref }}
cancel-in-progress: true

jobs:
formatting:
uses: ./.github/workflows/formatting.yml

build-and-push-base-docker:
uses: ./.github/workflows/build_and_push_images.yml
with:
Expand All @@ -26,10 +30,9 @@ jobs:
with:
runner: ${{ matrix.host }}
docker_image_tag: ghcr.io/itu-auv/auv-software-base:latest

build-and-push-main-docker:
needs: [native-ci, build-and-push-base-docker]
uses: ./.github/workflows/build_and_push_images.yml
with:
image_type: main

39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
files: \.(yaml|yml)$
- id: check-xml
files: \.(xml|launch|launch\.xml|sdf|urdf\.xacro|xacro|urdf)$|model\.config$
- id: end-of-file-fixer
- id: trailing-whitespace
- id: destroyed-symlinks
- id: check-executables-have-shebangs
exclude: \.cpp|\.cxx|\.hpp|\.h$
- id: forbid-submodules
- id: check-added-large-files
- id: check-case-conflict
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, "2", --sequence, "4", --offset, "2", --width, "150", --preserve-quotes]
exclude: ^auv_bringup/config/ekf.yaml$
- repo: https://github.com/lsst-ts/pre-commit-xmllint
rev: v1.0.0
hooks:
- id: format-xmllint
files: \.(xml|launch|launch\.xml|sdf|urdf\.xacro|xacro|urdf)$|model\.config$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
files: \.(cpp|h|hpp)$
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3
files: \.py$
3 changes: 2 additions & 1 deletion auv_bringup/config/cameras.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
cam_front:
width: 640
height: 480
Expand Down Expand Up @@ -50,4 +51,4 @@ cam_bottom:
projection_matrix:
rows: 3
cols: 4
data: [750.047689, 0, 313.903300,0, 0, 988.371962, 250.566244,0, 0, 0, 1,0]
data: [750.047689, 0, 313.903300, 0, 0, 988.371962, 250.566244, 0, 0, 0, 1, 0]
1 change: 1 addition & 0 deletions auv_bringup/config/environment.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
/env/sound_speed: 1500
2 changes: 1 addition & 1 deletion auv_bringup/config/move_base/costmap_common_params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
obstacle_range: 20.0
raytrace_range: 30.0

Expand All @@ -20,4 +21,3 @@ map_type: costmap

observation_sources: pointcloud
pointcloud: {sensor_frame: taluy/base_link, data_type: PointCloud, topic: pointcloud, marking: true, clearing: true}

5 changes: 3 additions & 2 deletions auv_bringup/config/move_base/dwa_local_planner_params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
DWAPlannerROS:

# Robot Configuration Parameters
Expand All @@ -16,7 +17,7 @@ DWAPlannerROS:

acc_lim_x: 2.0
acc_lim_y: 0.0
acc_lim_theta: 3.0
acc_lim_theta: 3.0
acc_lim_trans: 5.0

# Goal Tolerance Parametes
Expand Down Expand Up @@ -44,5 +45,5 @@ DWAPlannerROS:
oscillation_reset_dist: 0.05

# Debugging
publish_traj_pc : true
publish_traj_pc: true
publish_cost_grid_pc: true
3 changes: 2 additions & 1 deletion auv_bringup/config/move_base/global_costmap_params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
global_costmap:
global_frame: odom
robot_base_frame: taluy/base_link
Expand All @@ -11,5 +12,5 @@ global_costmap:
resolution: 0.1

static_map: false
rolling_window: true
rolling_window: true
track_unknown_space: false
3 changes: 2 additions & 1 deletion auv_bringup/config/move_base/local_costmap_params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
local_costmap:
global_frame: odom
robot_base_frame: taluy/base_link
Expand All @@ -11,4 +12,4 @@ local_costmap:
width: 10
height: 10
resolution: 0.01
track_unknown_space: false
track_unknown_space: false
1 change: 1 addition & 0 deletions auv_bringup/config/move_base/move_base_params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
shutdown_costmaps: false
controller_frequency: 10.0
planner_patience: 5.0
Expand Down
2 changes: 1 addition & 1 deletion auv_bringup/launch/cameras.launch
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<arg name="verbose" value="$(arg verbose)" />
<arg name="pub_camera_info" value="$(arg pub_camera_info)" />
</include>
</launch>
</launch>
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
<?xml version="1.0"?>
<launch>
<arg name="namespace" default="turquoise" />
<arg name="port" default="/dev/ttyACM0" />
<arg name="baudrate" default="1500000" />
<arg name="virtual_port" default="/tmp/vcom0" />
<arg name="respawn" default="true" />

<arg name="namespace" default="turquoise"/>
<arg name="port" default="/dev/ttyACM0"/>
<arg name="baudrate" default="1500000"/>
<arg name="virtual_port" default="/tmp/vcom0"/>
<arg name="respawn" default="true"/>
<group ns="$(arg namespace)">
<!-- start expansion board bridge -->
<node pkg="rosserial_python" type="serial_node.py" name="expansion_board_bridge_node"
args="$(arg port) _baud:=$(arg baudrate)" output="screen" respawn="$(arg respawn)" />

<node pkg="rosserial_python" type="serial_node.py" name="expansion_board_bridge_node" args="$(arg port) _baud:=$(arg baudrate)" output="screen" respawn="$(arg respawn)"/>
<!-- start serial to ros bridge -->
<node pkg="auv_hardware_bridge" type="serial_to_ros_bridge_node"
name="expansion_serial_to_ros_bridge_node" output="screen" respawn="$(arg respawn)">
<param name="virtual_port" value="$(arg virtual_port)" />
<remap from="incoming" to="board/serial_port/incoming" />
<remap from="outgoing" to="board/serial_port/outgoing" />
<node pkg="auv_hardware_bridge" type="serial_to_ros_bridge_node" name="expansion_serial_to_ros_bridge_node" output="screen" respawn="$(arg respawn)">
<param name="virtual_port" value="$(arg virtual_port)"/>
<remap from="incoming" to="board/serial_port/incoming"/>
<remap from="outgoing" to="board/serial_port/outgoing"/>
</node>

<!-- start remapper node: depth -> pose -->
<node pkg="auv_hardware_bridge" type="expansion_bridge_remapper_node.py"
name="expansion_bridge_remapper_node" respawn="$(arg respawn)">
<param name="pressure_sensor_position_covariance" value="0.1" />
<remap from="depth" to="sensors/external_pressure_sensor/depth" />
<remap from="pose" to="sensors/external_pressure_sensor/pose" />
<node pkg="auv_hardware_bridge" type="expansion_bridge_remapper_node.py" name="expansion_bridge_remapper_node" respawn="$(arg respawn)">
<param name="pressure_sensor_position_covariance" value="0.1"/>
<remap from="depth" to="sensors/external_pressure_sensor/depth"/>
<remap from="pose" to="sensors/external_pressure_sensor/pose"/>
</node>
</group>
</launch>
</launch>
Loading

0 comments on commit 33d5b01

Please sign in to comment.