From 62946f138cb1b7d2a8e4d33b3f6d774965969055 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Sat, 2 Sep 2023 11:12:18 -0700 Subject: [PATCH] add build script issued in ros docker containers. Signed-off-by: Tomoya Fujita --- .github/workflows/build.yml | 10 +++-- scripts/build-verification.sh | 73 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100755 scripts/build-verification.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a0245c..e2ac599 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,10 @@ on: # 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 verification script can be agnostic from distribution dependency. + rolling-build: runs-on: ubuntu-latest container: @@ -25,7 +29,7 @@ jobs: - name: Build with ROS rolling shell: bash run: | - echo $ROS_DISTRO + ./scripts/build-verification.sh iron-build: runs-on: ubuntu-latest @@ -39,7 +43,7 @@ jobs: - name: Build with ROS iron shell: bash run: | - echo $ROS_DISTRO + ./scripts/build-verification.sh humble-build: runs-on: ubuntu-latest @@ -53,4 +57,4 @@ jobs: - name: Build with ROS humble shell: bash run: | - echo $ROS_DISTRO + ./scripts/build-verification.sh diff --git a/scripts/build-verification.sh b/scripts/build-verification.sh new file mode 100755 index 0000000..afd5b7f --- /dev/null +++ b/scripts/build-verification.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +##################################################################### +# ROS 2 Persistent Parameter Server +# +# This script builds parameter server within ros docker images. +# +# To avoid updating and modifying the files under `.github/workflows`, +# this scripts should be adjusted building process accordingly. +# And `.github/workflows` just calls this script in the workflow pipeline. +# This allows us to maintain the workflow process easier for contributers. +# +##################################################################### + +######################## +# Function Definitions # +######################## + +function mark { + export $1=`pwd`; +} + +function exit_trap() { + 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 ros-${ROS_DISTRO}-desktop ros-${ROS_DISTRO}-rmw-cyclonedds-cpp --no-install-recommends + cd $there +} + +function setup_build_colcon_env () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: set up colcon build environement." + mkdir -p ${COLCON_WORKSPACE}/src + cd ${COLCON_WORKSPACE} + cp -rf $there ${COLCON_WORKSPACE}/src +} + +function build_parameter_server () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: uninstall SRT Prometheus Exporter." + source /opt/ros/${ROS_DISTRO}/setup.bash + cd ${COLCON_WORKSPACE} + # TODO: test project should be integrated with `colcon test`. + colcon build --symlink-install --packages-select parameter_server ros2_persistent_parameter_server_test +} + +######## +# 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_build_colcon_env +build_parameter_server + +exit 0 \ No newline at end of file