From c036907caa697b8d7f1ef651c9f2474e6c296443 Mon Sep 17 00:00:00 2001 From: Manuel Segarra-Abad Date: Wed, 3 Aug 2022 14:35:54 +0300 Subject: [PATCH 1/3] Remove foxy build --- .github/workflows/main.yaml | 8 +-- Dockerfile.build_env | 49 -------------- packaging/build_deps.sh | 43 ------------ packaging/package.sh | 129 ------------------------------------ packaging/rosdep.sh | 36 ---------- packaging/rosdep.yaml | 3 - underlay.repos | 0 7 files changed, 3 insertions(+), 265 deletions(-) delete mode 100644 Dockerfile.build_env delete mode 100755 packaging/build_deps.sh delete mode 100755 packaging/package.sh delete mode 100755 packaging/rosdep.sh delete mode 100644 packaging/rosdep.yaml delete mode 100644 underlay.repos diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 88241ce0..3b8ad339 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,21 +9,19 @@ on: jobs: tii-px4-msgs-deb: runs-on: ubuntu-latest - strategy: - matrix: - ros2_distro: [foxy, galactic] steps: - name: Checkout PX4-msgs uses: actions/checkout@v2 with: path: PX4-msgs - name: Run px4-msgs docker build + env: + ROS: 1 + PACKAGE_NAME: px4_msgs run: | set -eux mkdir bin pushd PX4-msgs - export ROS=1 - export ROS_DISTRO=${{ matrix.ros2_distro }} ./build.sh ../bin/ popd - name: Upload build diff --git a/Dockerfile.build_env b/Dockerfile.build_env deleted file mode 100644 index db41be25..00000000 --- a/Dockerfile.build_env +++ /dev/null @@ -1,49 +0,0 @@ -# fog-sw BUILDER -ARG ROS_DISTRO="galactic" -FROM ros:${ROS_DISTRO}-ros-base as fog-sw-builder - -ARG UID=1000 -ARG GID=1000 -ARG BUILD_NUMBER -ARG COMMIT_ID -ARG GIT_VER -ARG PACKAGE_NAME -# Install build dependencies -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - curl \ - python3-bloom \ - fakeroot \ - dh-make \ - libboost-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN groupadd -g $GID builder && \ - useradd -m -u $UID -g $GID -g builder builder && \ - usermod -aG sudo builder && \ - echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -RUN echo "deb [trusted=yes] https://ssrc.jfrog.io/artifactory/ssrc-debian-public-remote focal fog-sw" >> /etc/apt/sources.list - -RUN apt-get update && apt-get install -y --no-install-recommends \ - ros-$ROS_DISTRO-rmw-fastrtps-cpp \ - ros-$ROS_DISTRO-rmw-fastrtps-shared-cpp \ - ros-$ROS_DISTRO-rmw-implementation \ - ros-$ROS_DISTRO-rosidl-typesupport-fastrtps-cpp \ - ros-$ROS_DISTRO-rosidl-typesupport-fastrtps-c \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /$PACKAGE_NAME/packaging - -COPY packaging/rosdep.yaml packaging/rosdep.sh /$PACKAGE_NAME/packaging/ -COPY underlay.repos package.xml /$PACKAGE_NAME/ - -RUN /$PACKAGE_NAME/packaging/rosdep.sh /$PACKAGE_NAME - -RUN chown -R builder:builder /$PACKAGE_NAME - -USER builder - -VOLUME /$PACKAGE_NAME/sources -WORKDIR /$PACKAGE_NAME/sources - -RUN rosdep update diff --git a/packaging/build_deps.sh b/packaging/build_deps.sh deleted file mode 100755 index 8160c140..00000000 --- a/packaging/build_deps.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -mod_dir=${1} - -cd ${mod_dir} - -echo "[INFO] Get package dependencies." -# Dependencies from fog-sw repo -if [ -e ${mod_dir}/ros2_ws/src ]; then - echo "[INFO] Use dependencies from fog_sw." - pushd ${mod_dir}/ros2_ws > /dev/null - source /opt/ros/${ROS_DISTRO}/setup.bash -else - echo "[INFO] Use dependencies from local repository." - mkdir -p ${mod_dir}/deps_ws/src - pushd ${mod_dir}/deps_ws > /dev/null - vcs import src < ${mod_dir}/underlay.repos - rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO} - source /opt/ros/${ROS_DISTRO}/setup.bash -fi - -rosdep_out=$(rosdep check -v --from-paths src 2>&1 | grep "resolving for resources" ) -ALL_PKGS=$(echo $rosdep_out | sed 's/.*\[\(.*\)\].*/\1/' | tr ',' '\n' | tr -d ' ') -echo "[INFO] All packages: $(echo $ALL_PKGS|tr '\n' ' ')" -PKGS_TO_BUILD="" -pushd src > /dev/null - -for pkg_name in ${ALL_PKGS}; do - echo "[INFO] Check if package ${pkg_name} is in the list of packages to build." - pkg_name=$(echo ${pkg_name} | sed 's/\/$//') - if ! ros2 pkg list | grep ${pkg_name} 1> /dev/null 2>&1; then - PKGS_TO_BUILD="${PKGS_TO_BUILD} ${pkg_name}" - fi -done - -echo "[INFO] Packages to build: $PKGS_TO_BUILD" -popd > /dev/null - -echo "[INFO] Build package dependencies." -colcon build --packages-select ${PKGS_TO_BUILD} -popd > /dev/null diff --git a/packaging/package.sh b/packaging/package.sh deleted file mode 100755 index 73337481..00000000 --- a/packaging/package.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -usage() { - echo " -Usage: $(basename "$0") [-h] [-b nbr] [-d dist] - -- Generate debian package from fog_sw module. -Params: - -h Show help text. - -b Build number. This will be tha last digit of version string (x.x.N). - -d Distribution string in debian changelog. - -g Git commit hash. - -v Git version string -" - exit 0 -} - -check_arg() { - if [ "$(echo $1 | cut -c1)" = "-" ]; then - return 1 - else - return 0 - fi -} - -error_arg() { - echo "$0: option requires an argument -- $1" - usage -} - -mod_dir="$(realpath $(dirname $0)/..)" -build_nbr=0 -distr="" -version="" -git_commit_hash="" -git_version_string="" - -while getopts "hb:d:g:v:" opt -do - case $opt in - h) - usage - ;; - b) - check_arg $OPTARG && build_nbr=$OPTARG || error_arg $opt - ;; - d) - check_arg $OPTARG && distr=$OPTARG || error_arg $opt - ;; - g) - check_arg $OPTARG && git_commit_hash=$OPTARG || error_arg $opt - ;; - v) - check_arg $OPTARG && git_version_string=$OPTARG || error_arg $opt - ;; - \?) - usage - ;; - esac -done - -if [[ "$git_commit_hash" == "0" || -z "$git_commit_hash" ]]; then - git_commit_hash="$(git rev-parse HEAD)" -fi -if [[ "$git_version_string" == "0" || -z "$git_version_string" ]]; then - git_version_string="$(git log --date=format:%Y%m%d --pretty=~git%cd.%h -n 1)" -fi - -## Remove trailing '/' mark in module dir, if exists -mod_dir=$(echo $mod_dir | sed 's/\/$//') - -## Debug prints -echo -echo "[INFO] mod_dir: ${mod_dir}." -echo "[INFO] build_nbr: ${build_nbr}." -echo "[INFO] distr: ${distr}." -echo "[INFO] git_commit_hash: ${git_commit_hash}." -echo "[INFO] git_version_string: ${git_version_string}." - -cd $mod_dir - -## Generate package -echo "[INFO] Creating deb package..." -### ROS2 Packaging - -### Create version string -version=$(grep "" package.xml | sed 's/[^>]*>\([^<"]*\).*/\1/') - -echo "[INFO] Version: ${version}." - -#title="$version ($(date +%Y-%m-%d))" -#cat << EOF_CHANGELOG > CHANGELOG.rst -#$title -#$(printf '%*s' "${#title}" | tr ' ' "-") -#* commit: ${git_commit_hash} -#EOF_CHANGELOG - -# Extract not satisfied dependencies from output, check if they are exist in ../underlay.repos -if rosdep check --from-paths ${mod_dir} 1> /dev/null 2>&1; then - echo "[INFO] Dependencies are satisfied." -else - echo "[INFO] System dependencies have not been satisfied. Running rosdep install.." - echo "[INFO] Building dependencies using underlay.repos." - ${mod_dir}/packaging/build_deps.sh ${mod_dir} -fi - -if [ -e ${mod_dir}/ros2_ws ]; then - # From fog-sw repo. - source ${mod_dir}/ros2_ws/install/setup.bash -fi -if [ -e ${mod_dir}/deps_ws ]; then - source ${mod_dir}/deps_ws/install/setup.bash -fi - -bloom-generate rosdebian --os-name ubuntu --os-version focal --ros-distro ${ROS_DISTRO} --place-template-files \ - && sed -i "s/@(DebianInc)@(Distribution)/@(DebianInc)/" debian/changelog.em \ - && [ ! "$distr" = "" ] && sed -i "s/@(Distribution)/${distr}/" debian/changelog.em || : \ - && bloom-generate rosdebian --os-name ubuntu --os-version focal --ros-distro ${ROS_DISTRO} --process-template-files -i ${build_nbr}${git_version_string} \ - && sed -i 's/^\tdh_shlibdeps.*/& --dpkg-shlibdeps-params=--ignore-missing-info/g' debian/rules \ - && sed -i "s/\=\([0-9]*\.[0-9]*\.[0-9]*\*\)//g" debian/control \ - && fakeroot debian/rules clean \ - && fakeroot debian/rules binary || exit 1 - -echo "[INFO] Move debian packages to volume." -mv ${mod_dir}/../*.deb ${mod_dir}/../*.ddeb ${mod_dir} - -echo "[INFO] Done." -exit 0 diff --git a/packaging/rosdep.sh b/packaging/rosdep.sh deleted file mode 100755 index b5b29ca7..00000000 --- a/packaging/rosdep.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -eu - -## for installing additional non-ROS2 dependencies to debian package generated by bloom -if [ ! -e /etc/ros/rosdep/sources.list.d/20-default.list ]; then - echo "[INFO] Initialize rosdep" - sudo rosdep init -fi - -mod_dir=$(echo ${1} | sed 's/\/$//') -yamlpath=${mod_dir}/packaging/rosdep.yaml -# Find ROS_DISTRO text in the yaml file and replace it with env variable -if [ -e ${yamlpath} ]; then - echo "[INFO] Replace ROS_DISTRO in rosdep.yaml" - sudo sed -i "s/ROS_DISTRO/${ROS_DISTRO}/g" ${yamlpath} -fi - -echo "[INFO] Add module specific dependencies" -cat $yamlpath -mkdir -p /etc/ros/rosdep/sources.list.d -echo "yaml file://${yamlpath}" > /etc/ros/rosdep/sources.list.d/51-fogsw-module.list - -echo "[INFO] Updating rosdep" -rosdep update - -apt update -echo "[INFO] Running rosdep install.." -ls ${mod_dir} -if rosdep install --from-paths ${mod_dir} -r -y --rosdistro ${ROS_DISTRO} 1> /dev/null 2>&1; then - echo "[INFO] rosdep install finished successfully." -else - echo "[ERROR] Some dependencies missing." -fi - -exit 0 diff --git a/packaging/rosdep.yaml b/packaging/rosdep.yaml deleted file mode 100644 index ae29f4ff..00000000 --- a/packaging/rosdep.yaml +++ /dev/null @@ -1,3 +0,0 @@ -rosidl_default_generators: - ubuntu: [ros-ROS_DISTRO-rosidl-default-generators] - diff --git a/underlay.repos b/underlay.repos deleted file mode 100644 index e69de29b..00000000 From 7446687317760f18922a85189816356120905d21 Mon Sep 17 00:00:00 2001 From: Manuel Segarra-Abad Date: Wed, 3 Aug 2022 14:36:55 +0300 Subject: [PATCH 2/3] Use fog-ros-baseimage builder --- Dockerfile | 14 ++++++++++++++ build.sh | 35 ++++++----------------------------- 2 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f67858c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/tiiuae/fog-ros-baseimage:builder-3dcb78d + +ARG BUILD_NUMBER + +COPY . /main_ws/src/ + +# this: +# 1) builds the application +# 2) packages the application as .deb in /main_ws/ + +RUN /packaging/build.sh -b ${BUILD_NUMBER} + +RUN mkdir -p /output_dir +RUN cp /main_ws/ros-*-px4-msgs_*_amd64.deb /output_dir/ diff --git a/build.sh b/build.sh index 81afcfdc..bf0ad98d 100755 --- a/build.sh +++ b/build.sh @@ -3,38 +3,15 @@ set -euxo pipefail output_dir=$1 - -git_commit_hash=${2:-$(git rev-parse HEAD)} - -git_version_string=${3:-$(git log --date=format:%Y%m%d --pretty=~git%cd.%h -n 1)} - +git_commit_hash=${2:-$(git rev-parse --short HEAD)} build_number=${GITHUB_RUN_NUMBER:=0} -ros_distro=${ROS_DISTRO:=foxy} - -iname=${PACKAGE_NAME:=px4-msgs} - -iversion=${PACKAGE_VERSION:=latest} - docker build \ - --build-arg UID=$(id -u) \ - --build-arg GID=$(id -g) \ - --build-arg ROS_DISTRO=${ros_distro} \ - --build-arg PACKAGE_NAME=${iname} \ - --pull \ - -f Dockerfile.build_env -t "${iname}_build:${iversion}" . - -docker run \ - --rm \ - -v $(pwd):/${iname}/sources \ - ${iname}_build:${iversion} \ - ./packaging/package.sh \ - -b ${build_number} \ - -g ${git_commit_hash} \ - -v ${git_version_string} + --build-arg BUILD_NUMBER=${build_number} \ + -t "ghcr.io/tiiuae/tii-px4-msgs:sha-${git_commit_hash}" . -mkdir -p ${output_dir} -cp *.deb *.ddeb ${output_dir} -rm -Rf *.deb *.ddeb +container_id=$(docker create ghcr.io/tiiuae/tii-px4-msgs:sha-${git_commit_hash}) +docker cp ${container_id}:/output_dir/. ${output_dir} +docker rm -v ${container_id} exit 0 From 6c58b451f1c60de3c9e9923d72c15f54dcf3595c Mon Sep 17 00:00:00 2001 From: Manuel Segarra-Abad Date: Wed, 3 Aug 2022 15:42:33 +0300 Subject: [PATCH 3/3] Simplify actions and use not public name for docker image --- .github/workflows/build.yml | 33 --------------------------------- .github/workflows/main.yaml | 3 --- build.sh | 5 ++--- 3 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 669f290f..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build package - -# CI runs over all branches that do not contain 'ros1' in the name -on: - push: - branches: - - 'master' - - 'ros2' - pull_request: - branches-ignore: - - '**ros1**' - -defaults: - run: - shell: bash - -jobs: - build: - name: "Build" - runs-on: ubuntu-20.04 - container: px4io/px4-dev-ros2-${{ matrix.ros2_distro }}:2021-05-31 - strategy: - matrix: - ros2_distro: [dashing, eloquent, foxy, galactic, rolling] - steps: - - uses: actions/checkout@v2 - - name: build - run: | - source /opt/ros/${{ matrix.ros2_distro }}/setup.bash - mkdir -p ~/colcon_ws/src - cd ~/colcon_ws - ln -s ${GITHUB_WORKSPACE} src/px4_msgs - colcon build --cmake-args --symlink-install --event-handlers console_direct+ diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3b8ad339..194dd3cc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -15,9 +15,6 @@ jobs: with: path: PX4-msgs - name: Run px4-msgs docker build - env: - ROS: 1 - PACKAGE_NAME: px4_msgs run: | set -eux mkdir bin diff --git a/build.sh b/build.sh index bf0ad98d..e81c28ff 100755 --- a/build.sh +++ b/build.sh @@ -3,14 +3,13 @@ set -euxo pipefail output_dir=$1 -git_commit_hash=${2:-$(git rev-parse --short HEAD)} build_number=${GITHUB_RUN_NUMBER:=0} docker build \ --build-arg BUILD_NUMBER=${build_number} \ - -t "ghcr.io/tiiuae/tii-px4-msgs:sha-${git_commit_hash}" . + -t "tii-px4-msgs:px4-msgs" . -container_id=$(docker create ghcr.io/tiiuae/tii-px4-msgs:sha-${git_commit_hash}) +container_id=$(docker create tii-px4-msgs:px4-msgs) docker cp ${container_id}:/output_dir/. ${output_dir} docker rm -v ${container_id}