diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8548992dd..b6adb1170 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,6 +72,8 @@ jobs: - {ROS_DISTRO: melodic, AFTER_SCRIPT: 'rosenv rosrun industrial_ci run_travis', ADDITIONAL_DEBS: "ros-melodic-rosbash"} - {ROS_DISTRO: melodic, ROS_REPO: main} + - {ROS_DISTRO: noetic, TEST: debians, TARGET_WORKSPACE: ". industrial_ci/mockups/industrial_ci_testpkg"} + # Format tests - {ROS_DISTRO: indigo, TARGET_WORKSPACE: 'industrial_ci/mockups/format_tests/cpp/LLVM', CLANG_FORMAT_CHECK: 'LLVM', CLANG_FORMAT_VERSION: 3.8} - {ROS_DISTRO: kinetic, TARGET_WORKSPACE: 'industrial_ci/mockups/format_tests/cpp/LLVM', CLANG_FORMAT_CHECK: 'LLVM'} @@ -136,6 +138,7 @@ jobs: - {ROS_DISTRO: melodic, UBUNTU: 18.04} - {ROS_DISTRO: noetic, UBUNTU: 20.04} - {ROS_DISTRO: noetic, PRERELEASE: true, UBUNTU: 20.04} + - {ROS_DISTRO: noetic, UBUNTU: 20.04, TEST: debians, TARGET_WORKSPACE: ". industrial_ci/mockups/industrial_ci_testpkg"} - {ROS_DISTRO: foxy, UBUNTU: 20.04} - {ROS_DISTRO: galactic, PRERELEASE: true, UBUNTU: 20.04} runs-on: ubuntu-${{matrix.env.UBUNTU}} diff --git a/industrial_ci/src/folding/quiet.sh b/industrial_ci/src/folding/quiet.sh new file mode 100644 index 000000000..abdfce5df --- /dev/null +++ b/industrial_ci/src/folding/quiet.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright (c) 2019, Mathias Lüdtke +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function ici_start_fold() { + ici_error "ici_start_fold is not implemented" +} + +function ici_end_fold() { + ici_error "ici_end_fold is not implemented" +} + +function ici_cmd { + _ici_guard ici_label ici_quiet "$@" +} + +function ici_filter { + shift + ici_quiet "$@" +} + +function ici_step { + shift + _ici_guard ici_quiet "$@" +} diff --git a/industrial_ci/src/isolation/docker.sh b/industrial_ci/src/isolation/docker.sh index 95e900699..4a05bad1c 100644 --- a/industrial_ci/src/isolation/docker.sh +++ b/industrial_ci/src/isolation/docker.sh @@ -144,7 +144,7 @@ function ici_run_cmd_in_docker() { # detect user inside container local image - image=$(docker inspect --format='{{.Config.Image}}' "$cid") + image=$(ici_guard docker inspect --format='{{.Config.Image}}' "$cid") local docker_query=() # shellcheck disable=SC2016 IFS=" " read -r -a docker_query <<< "$(docker run --rm --entrypoint '/bin/sh' "$image" -c 'echo "$(id -u) $(id -g) $HOME"')" diff --git a/industrial_ci/src/tests/debians.sh b/industrial_ci/src/tests/debians.sh new file mode 100644 index 000000000..a4861807e --- /dev/null +++ b/industrial_ci/src/tests/debians.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +# Copyright (c) 2021, Mathias Lüdtke +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Based on https://github.com/ros-industrial/industrial_ci/issues/697#issuecomment-876293987 + + +function make_repo() { + local repo=$1; shift + ici_guard rm -rf "$repo" + ici_guard mkdir -p "$repo" + ici_guard touch "$repo/Packages" +} + +function update_repo() ( + local repo=$1; shift + ici_guard cd "$repo" && ici_guard dpkg-scanpackages . > Packages +) + +function use_repo() ( + local repo=$1; shift + ici_guard ici_asroot rm -f /etc/apt/apt.conf.d/docker-clean + echo "deb [trusted=yes] file://$repo ./" | >/dev/null ici_guard ici_asroot tee /etc/apt/sources.list.d/ici_debians.list + echo -e 'Package: *\nPin: origin ""\nPin-Priority: 1000' | >/dev/null ici_guard ici_asroot tee /etc/apt/preferences.d/ici_debians + ici_guard ici_asroot apt-get -o APT::Sandbox::User=root update -qq +) + +function forward_mounts() { + ici_forward_mount WORKSPACE rw + ici_forward_mount "$WORKSPACE/archives" rw /var/cache/apt/archives + if [ -n "${DOCKER_PORT:-}" ]; then + ici_forward_variable DOCKER_HOST "$DOCKER_PORT" + elif [ -e /var/run/docker.sock ]; then + ici_forward_mount /var/run/docker.sock rw + fi +} + +function prepare_debians() { + export WORKSPACE; WORKSPACE=$(mktemp -d) + ici_guard mkdir "$WORKSPACE/archives" + forward_mounts +} + +function build_debian() ( + local pkg_path=$1; shift + local repo=$1; shift + use_repo "$repo" + + ici_guard cd "$pkg_path" + ici_cmd ici_filter "Setting up" ici_asroot apt-get build-dep -y -qq . + ici_cmd ici_quiet dpkg-buildpackage -b -uc -us + ici_guard mv ../*.deb "$repo" +) + +function isolate_build_debian() ( + local pkg_path=$1; shift + local repo=$1; shift + for hook in $(env | grep -o '^\(BEFORE\|AFTER\)_[^=]*'); do + unset "$hook" + done + export _FOLDING_TYPE=quiet + DOCKER_PULL=false ici_isolate debians build_debian "$pkg_path" "$repo" || return +) + +function build_package() { + local pkg_path=$1; shift + local repo=$1; shift + + use_repo "$repo" + ici_install_pkgs_for_command dpkg-buildpackage dpkg-dev + + ( ici_guard cd "$pkg_path" && ici_cmd bloom-generate rosdebian --ros-distro="$ROS_DISTRO" --debian-inc="ici~"; ) || return + # https://github.com/ros-infrastructure/bloom/pull/643 + echo 11 > "$pkg_path"/debian/compat + + isolate_build_debian "$pkg_path" "$repo" || return + update_repo "$repo" +} + +function test_install_packages() { + local repo=$1; shift + ( ici_guard cd "$repo" && ici_apt_install ./*.deb; ) +} + +function run_debians() { + ici_guard source "${ICI_SRC_PATH}/isolation/docker.sh" + forward_mounts + + export BUILDER=colcon + ici_source_builder + ici_step "${BUILDER}_setup" builder_setup + ici_step "setup_bloom" ici_install_pkgs_for_command bloom-generate python3-bloom debhelper + ici_step "setup_dpkg_dev" ici_install_pkgs_for_command dpkg-scanpackages dpkg-dev + ici_step "setup_docker" ici_install_pkgs_for_command docker docker.io + ici_step "setup_rosdep" ici_setup_rosdep + + local repo="$WORKSPACE/repository" + make_repo "$repo" + + for name in upstream target downstream; do + local sources=() + local current="$WORKSPACE/${name}_ws/src" + ici_parse_env_array sources "${name^^}_WORKSPACE" + if [ -n "${sources[*]}" ]; then + ici_step "prepare_${name}_sourcespace" ici_prepare_sourcespace "$current" "${sources[@]}" + + while read -r -a pkg; do + ici_step "build_${pkg[0]}" build_package "$current/${pkg[1]}" "$repo" + done < <(ici_guard cd "$current" && ici_guard colcon list -t) + fi + done + + ici_step "test_install_packages" test_install_packages "$repo" + + ici_log "Debian packages:" + ici_redirect find "$repo" -name '*.deb' -exec basename {} \; +}