From 07791cbc8218ce49b713706fffcae9faaeb8cca0 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Thu, 5 Dec 2024 12:27:19 -0800 Subject: [PATCH] enable github workflows to rolling branch. (#52) * enable github workflows to rolling branch. Signed-off-by: Tomoya Fujita * add exec permission for scripts/github_workflows.sh. Signed-off-by: Tomoya Fujita * enable workflow for other distro branches. Signed-off-by: Tomoya Fujita --------- Signed-off-by: Tomoya Fujita (cherry picked from commit cb678ba2bd97b3a040b34a9add651aa2832dd682) --- .github/workflows/humble.yaml | 33 ++++++++++ .github/workflows/iron.yaml | 33 ++++++++++ .github/workflows/jazzy.yaml | 33 ++++++++++ .github/workflows/rolling.yaml | 33 ++++++++++ scripts/github_workflows.sh | 113 +++++++++++++++++++++++++++++++++ 5 files changed, 245 insertions(+) create mode 100644 .github/workflows/humble.yaml create mode 100644 .github/workflows/iron.yaml create mode 100644 .github/workflows/jazzy.yaml create mode 100644 .github/workflows/rolling.yaml create mode 100755 scripts/github_workflows.sh diff --git a/.github/workflows/humble.yaml b/.github/workflows/humble.yaml new file mode 100644 index 0000000..5d1ee33 --- /dev/null +++ b/.github/workflows/humble.yaml @@ -0,0 +1,33 @@ +# This is workflow for humble distribution +name: humble + +# Because of rcl_logging interface, rcl_logging_syslog has each distribution branch. +on: + push: + branches: [ "humble" ] + pull_request: + branches: [ "humble" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + # each job goes for each ros supported distribution. + # each job description absorb the distribution dependency as much as possible, + # so that build/test verification script can be agnostic from distribution dependency. + + build: + runs-on: ubuntu-latest + container: + image: ros:humble + env: + ROS_DISTRO: humble + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Build and Test with ROS humble + shell: bash + run: | + ./scripts/github_workflows.sh diff --git a/.github/workflows/iron.yaml b/.github/workflows/iron.yaml new file mode 100644 index 0000000..99ec486 --- /dev/null +++ b/.github/workflows/iron.yaml @@ -0,0 +1,33 @@ +# This is workflow for iron distribution +name: iron + +# Because of rcl_logging interface, rcl_logging_syslog has each distribution branch. +on: + push: + branches: [ "iron" ] + pull_request: + branches: [ "iron" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + # each job goes for each ros supported distribution. + # each job description absorb the distribution dependency as much as possible, + # so that build/test verification script can be agnostic from distribution dependency. + + build: + runs-on: ubuntu-latest + container: + image: ros:iron + env: + ROS_DISTRO: iron + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Build and Test with ROS iron + shell: bash + run: | + ./scripts/github_workflows.sh diff --git a/.github/workflows/jazzy.yaml b/.github/workflows/jazzy.yaml new file mode 100644 index 0000000..39cec44 --- /dev/null +++ b/.github/workflows/jazzy.yaml @@ -0,0 +1,33 @@ +# This is workflow for jazzy distribution +name: jazzy + +# Because of rcl_logging interface, rcl_logging_syslog has each distribution branch. +on: + push: + branches: [ "jazzy" ] + pull_request: + branches: [ "jazzy" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + # each job goes for each ros supported distribution. + # each job description absorb the distribution dependency as much as possible, + # so that build/test verification script can be agnostic from distribution dependency. + + build: + runs-on: ubuntu-latest + container: + image: ros:jazzy + env: + ROS_DISTRO: jazzy + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Build and Test with ROS jazzy + shell: bash + run: | + ./scripts/github_workflows.sh diff --git a/.github/workflows/rolling.yaml b/.github/workflows/rolling.yaml new file mode 100644 index 0000000..074a34d --- /dev/null +++ b/.github/workflows/rolling.yaml @@ -0,0 +1,33 @@ +# This is workflow for rolling distribution +name: rolling + +# Because of rcl_logging interface, rcl_logging_syslog has each distribution branch. +on: + push: + branches: [ "rolling" ] + pull_request: + branches: [ "rolling" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + # each job goes for each ros supported distribution. + # each job description absorb the distribution dependency as much as possible, + # so that build/test verification script can be agnostic from distribution dependency. + + build: + runs-on: ubuntu-latest + container: + image: ros:rolling + env: + ROS_DISTRO: rolling + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Build and Test with ROS rolling + shell: bash + run: | + ./scripts/github_workflows.sh diff --git a/scripts/github_workflows.sh b/scripts/github_workflows.sh new file mode 100755 index 0000000..64db323 --- /dev/null +++ b/scripts/github_workflows.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +##################################################################### +# rcl_logging_syslog rcl logging implementation via rsyslog/syslog. +# +# This script builds and tests it within ros distro public docker images. +# +# To avoid updating and modifying the files under `.github/workflows`, +# this scripts should be adjusted workflow process accordingly. +# And `.github/workflows` just calls this script in the workflow pipeline. +# This allows us to maintain the workflow process easier for contributors. +# +##################################################################### + +######################## +# Function Definitions # +######################## + +function mark { + export $1=`pwd`; +} + +function exit_trap() { + # shellcheck disable=SC2317 # Don't warn about unreachable commands in this function + if [ $? != 0 ]; then + echo "Command [$BASH_COMMAND] is failed" + exit 1 + fi +} + +function install_prerequisites () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: update and install dependent packages." + apt update && apt upgrade -y + apt install -y git + # TODO(@fujitatomoya) probably we should use rosdep to install dependencies to build + apt install -y ros-rolling-mimick-vendor ros-rolling-performance-test-fixture ros-rolling-test-msgs + #apt install -y ros-${ROS_DISTRO}-desktop --no-install-recommends + cd $there +} + +function setup_colcon_env () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: set up colcon build environment." + mkdir -p ${COLCON_WORKSPACE}/src + # fetch rcl repository in local file system to build with rcl_logging_syslog. + # currently no dynamic loading is supported with rcl_logging, so we need to build rcl together. + # see more details for https://github.com/ros2/rcl/issues/1178 + git clone -b ${ROS_DISTRO} https://github.com/ros2/rcl.git ${COLCON_WORKSPACE}/src/rcl + # move rcl_logging_syslog directory to colcon workspace + cd ${COLCON_WORKSPACE} + cp -rf $there ${COLCON_WORKSPACE}/src +} + +function setup_rsyslog () { + # this is required basically only for container environment. + # for security reason, container does not have system service or daemon processes. + # just for the test with rsyslog, it installs rsyslog and start the rsyslog daemon. + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: install and setup rsyslogd." + apt update && apt upgrade -y + apt install -y rsyslog + # permission setting for rsyslog file sink for the test. + mkdir -p /var/log/ros + chown syslog:adm /var/log/ros + # copy the rsyslogd configuration file for the test + cd ${COLCON_WORKSPACE} + cp ./src/rcl_logging_syslog/config/ros2-test.conf /etc/rsyslog.d/ + rsyslogd -N1 + # start the rsyslogd daemon in the background process. + /usr/sbin/rsyslogd -n -iNONE & +} + +function build_colcon_package () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: build rcl and rcl_logging_syslog packages." + source /opt/ros/${ROS_DISTRO}/setup.bash + cd ${COLCON_WORKSPACE} + export RCL_LOGGING_IMPLEMENTATION=rcl_logging_syslog + colcon build --symlink-install --cmake-clean-cache --packages-select rcl_logging_syslog rcl +} + +function test_colcon_package () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: test rcl_logging_syslog packages." + # source local workspace projects + cd ${COLCON_WORKSPACE} + source ./install/local_setup.bash + # initiate the colcon test + colcon test --event-handlers console_direct+ --packages-select rcl_logging_syslog +} + +######## +# Main # +######## + +export DEBIAN_FRONTEND=noninteractive +export COLCON_WORKSPACE=/tmp/colcon_ws + +# mark the working space root directory, so that we can come back anytime with `cd $there` +mark there + +# set the trap on error +trap exit_trap ERR + +# call install functions in sequence +install_prerequisites +setup_colcon_env +setup_rsyslog +build_colcon_package +test_colcon_package + +exit 0