Skip to content

Commit

Permalink
Merge branch 'ros2' into ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc authored Aug 8, 2024
2 parents 9b5a988 + 7d0224d commit 7363d87
Show file tree
Hide file tree
Showing 15 changed files with 1,770 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/check_style.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

# Given a set of commits current script checks the style based on clang_format
# on the list of changed files that exist in the commits.
#
# Script should be called from a travis.yml file.

# Functions
######################

# This is run by travis automatically from the root of the project

set +e
set +x

DIRS_IN="."
DIRS_OUT="scripts"
LANGS=cpp
FORMAT_CODE_BIN="scripts/clang_git_format/format_code.py"

function lint() {

# Get list of changed files for lint to run on. Grep only .h, .cpp files and
# mind the DIRS_IN, DIRS_OUT vars

# Following command fails if you "git commit --amend" - Works correctly on
# standard commits
echo "commit_range: $TRAVIS_COMMIT_RANGE"
changed_files=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
printf "Summary of changed files:\n\n${changed_files}\n\n"

# include
regexp_in=
for i in $DIRS_IN; do
if [ -n "${regexp_in}" ]; then
regexp_in="${regexp_in}\|${i}"
else
regexp_in="${i}"
fi
done

# exclude
regexp_out=
for i in $DIRS_OUT; do
if [ -n "${regexp_out}" ]; then
regexp_out="${regexp_out}\|${i}"
else
regexp_out="${i}"
fi
done

echo "regexp_in: ${regexp_in}"
echo "regexp_out: ${regexp_out}"

valid_files=$(echo ${changed_files} \
| xargs -d' ' -n 1 \
| grep -i -e "${regexp_in}" \
| grep -v "${regexp_out}" \
| grep -ie ".*\.h$\|.*\.cpp")


printf "Valid files for lint:\n\t${valid_files}\n"
if [ -n "${valid_files}" ]; then
${FORMAT_CODE_BIN} -g . --lint_files ${valid_files}
else
true
fi
exit $?

}

function lint_all() {

${FORMAT_CODE_BIN} -g . --lang ${LANGS} \
-o ${DIRS_OUT} -i ${DIRS_IN} \
-l

exit $?
}

lint_all
3 changes: 3 additions & 0 deletions .github/python_clang_format_reqs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Requisites for the clang-format linter script
argparse
colorlog
40 changes: 40 additions & 0 deletions .github/workflows/check-clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI clang-format

on: [push, pull_request]

jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
# Github Actions requires a single row to be added to the build matrix.
# See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
name: [
clang-format-check
]

include:
- name: clang-format-check
os: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@master

- name: Git submodule
run: |
git submodule sync
git submodule update --init --recursive
- name: Install Dependencies
run: |
sudo apt install clang-format-14 -yq
pip3 install --user -r .github/python_clang_format_reqs.txt
- name: Check code style
run: |
echo "TASK=lint_all" >> $GITHUB_ENV
bash .github/check_style.sh
74 changes: 74 additions & 0 deletions .github/workflows/ros-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Based on GTSAM file (by @ProfFan)
name: CI Build colcon

on: [push, pull_request]

jobs:
build_docker: # On Linux, iterates on all ROS 1 and ROS 2 distributions.
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
strategy:
matrix:
# Github Actions requires a single row to be added to the build matrix.
# See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
# ros_distribution:
# - humble
# - iron
# - rolling

# Define the Docker image(s) associated with each ROS distribution.
# The include syntax allows additional variables to be defined, like
# docker_image in this case. See documentation:
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-configurations-in-a-matrix-build
#
# Platforms are defined in REP 3 and REP 2000:
# https://ros.org/reps/rep-0003.html
# https://ros.org/reps/rep-2000.html
include:
# Humble Hawksbill (May 2022 - May 2027)
- docker_image: ubuntu:jammy
ros_distribution: humble
ros_version: 2

# Iron Irwini (May 2023 - November 2024)
- docker_image: ubuntu:jammy
ros_distribution: iron
ros_version: 2

# Jazzy (2024 - ??)
- docker_image: ubuntu:noble
ros_distribution: jazzy
ros_version: 2

# Rolling Ridley (No End-Of-Life)
# - docker_image: ubuntu:noble
# ros_distribution: rolling
# ros_version: 2

container:
image: ${{ matrix.docker_image }}

steps:
- name: Checkout
run: |
apt-get -y update
apt-get -y install git
git clone https://github.com/$GITHUB_REPOSITORY.git --recursive "$GITHUB_WORKSPACE"
- name: setup ROS environment
uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distribution }}

- name: Install rosdep dependencies
run: |
. /opt/ros/*/setup.sh
rosdep update
rosdep install --from-paths . --ignore-src -r -y
- name: Build with colcon
run: |
. /opt/ros/*/setup.sh
env
MAKEFLAGS="-j2" colcon build --symlink-install --parallel-workers 2 --event-handlers console_direct+
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![CI Build colcon](https://github.com/mrpt-ros-pkg/mrpt_sensors/actions/workflows/ros-build.yml/badge.svg)](https://github.com/mrpt-ros-pkg/mrpt_sensors/actions/workflows/ros-build.yml)
[![CI clang-format](https://github.com/mrpt-ros-pkg/mrpt_sensors/actions/workflows/check-clang-format.yml/badge.svg)](https://github.com/mrpt-ros-pkg/mrpt_sensors/actions/workflows/check-clang-format.yml)


| Distro | Build dev | Release |
| --- | --- | --- |
| ROS 2 Humble (u22.04) | [![Build Status](https://build.ros2.org/job/Hdev__mrpt_sensors__ubuntu_jammy_amd64/badge/icon)](https://build.ros2.org/job/Hdev__mrpt_sensors__ubuntu_jammy_amd64/) | [![Version](https://img.shields.io/ros/v/humble/mrpt_sensors)](https://index.ros.org/search/?term=mrpt_sensors) |
Expand Down
40 changes: 40 additions & 0 deletions scripts/clang_git_format/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

build/
Loading

0 comments on commit 7363d87

Please sign in to comment.