From 2d72529710ce98ef8ef73195cef8db415ca798e2 Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Wed, 13 Nov 2024 08:14:13 -0800 Subject: [PATCH] ci: test ubuntu 24 * updates ubuntu.sh adding support for ubuntu 24.04 * ubuntu.sh now expects by default any of the last two LTS * runs ci in docker containers --- .github/workflows/compile_ubuntu.yml | 38 +++++++----- Tools/setup/ubuntu.sh | 92 +++++++++++++--------------- 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/.github/workflows/compile_ubuntu.yml b/.github/workflows/compile_ubuntu.yml index 47bcc28211d6..61994162facb 100644 --- a/.github/workflows/compile_ubuntu.yml +++ b/.github/workflows/compile_ubuntu.yml @@ -13,24 +13,34 @@ on: jobs: build_and_test: - name: Build and Test Ubuntu - # strategy: - # fail-fast: false - # matrix: - # version: [ubuntu22, ubuntu24] - runs-on: [runs-on,runner=8cpu-linux-x64,"image=ubuntu22-full-x64","run-id=${{ github.run_id }}"] + name: Build and Test + strategy: + fail-fast: false + matrix: + version: ['ubuntu:22.04', 'ubuntu:24.04'] + runs-on: [runs-on,runner=8cpu-linux-x64,"image=ubuntu24-full-x64","run-id=${{ github.run_id }}"] + container: + image: ${{ matrix.version }} + volumes: + - /github/workspace:/github/workspace steps: + - name: Fix git in container + run: | + # we only need this because we are running the job in a container + # when checkout pulls git it does it in a shared volume + # and file ownership changes between steps + # first we install git since its missing from the base image + # then we mark the directory as safe for other instances + # of git to use. + apt update && apt install git -y + git config --global --add safe.directory $(realpath .) + - uses: actions/checkout@v4 - - name: Install Dependencies + - name: Install Deps, Build, and Make Quick Check run: | + # we need to install dependencies and build on the same step + # given the stateless nature of docker images ./Tools/setup/ubuntu.sh - - - name: Make Quick Check - run: | make quick_check - - # - name: Debug - # if: ${{ failure() }} - # uses: mxschmitt/action-tmate@v3 diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh index d7b537071dcf..4dbaa9300fd9 100755 --- a/Tools/setup/ubuntu.sh +++ b/Tools/setup/ubuntu.sh @@ -31,11 +31,8 @@ done if [ -f /.dockerenv ]; then echo "Running within docker, installing initial dependencies"; apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \ - ca-certificates \ - gnupg \ - lsb-core \ + lsb-release \ sudo \ - wget \ ; fi @@ -62,6 +59,7 @@ sudo apt-get update -y --quiet sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ astyle \ build-essential \ + ca-certificates \ cmake \ cppcheck \ file \ @@ -69,10 +67,13 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i gcc \ gdb \ git \ + gnupg \ + gosu \ lcov \ libssl-dev \ libxml2-dev \ libxml2-utils \ + lsb-release \ make \ ninja-build \ python3 \ @@ -82,19 +83,27 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i python3-wheel \ rsync \ shellcheck \ + software-properties-common \ + sudo \ unzip \ + wget \ zip \ ; # Python3 dependencies echo echo "Installing PX4 Python3 dependencies" -if [ -n "$VIRTUAL_ENV" ]; then - # virtual environments don't allow --user option - python -m pip install -r ${DIR}/requirements.txt +PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}') +REQUIRED_VERSION="3.11" +if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then + python3 -m pip install --break-system-packages -r ${DIR}/requirements.txt else - # older versions of Ubuntu require --user option - python3 -m pip install --user -r ${DIR}/requirements.txt + if [ -n "$VIRTUAL_ENV" ]; then + # virtual environments don't allow --user option + python -m pip install -r ${DIR}/requirements.txt + else + python3 -m pip install --user -r ${DIR}/requirements.txt + fi fi # NuttX toolchain (arm-none-eabi-gcc) @@ -155,39 +164,22 @@ if [[ $INSTALL_SIM == "true" ]]; then bc \ ; - if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then - java_version=11 - elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then - java_version=13 - elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then - java_version=11 - elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then - java_version=11 - else - java_version=14 - fi - # Java (jmavsim) - sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ - ant \ - openjdk-$java_version-jre \ - openjdk-$java_version-jdk \ - libvecmath-java \ - ; - - # Set Java 11 as default - sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version") - # Gazebo / Gazebo classic installation - if [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then - echo "Gazebo (Harmonic) will be installed" - echo "Earlier versions will be removed" - # Add Gazebo binary repository - sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null + if [[ "${UBUNTU_RELEASE}" == "18.04" || "${UBUNTU_RELEASE}" == "20.04" ]]; then + sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' + wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - + # Update list, since new gazebo-stable.list has been added sudo apt-get update -y --quiet - # Install Gazebo - gazebo_packages="gz-harmonic" + # Install Gazebo classic + if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then + gazebo_classic_version=9 + gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev" + else + # default and Ubuntu 20.04 + gazebo_classic_version=11 + gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev" + fi elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then echo "Gazebo (Garden) will be installed" echo "Earlier versions will be removed" @@ -200,19 +192,19 @@ if [[ $INSTALL_SIM == "true" ]]; then # Install Gazebo gazebo_packages="gz-garden" else - sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' - wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - - # Update list, since new gazebo-stable.list has been added + # Expects Ubuntu 22.04 > by default + echo "Gazebo (Harmonic) will be installed" + echo "Earlier versions will be removed" + # Add Gazebo binary repository + sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null sudo apt-get update -y --quiet - # Install Gazebo classic - if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then - gazebo_classic_version=9 - gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev" - else - # default and Ubuntu 20.04 - gazebo_classic_version=11 - gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev" + # Install Gazebo + gazebo_packages="gz-harmonic libunwind-dev" + + if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then + gazebo_packages="$gazebo_packages cppzmq-dev" fi fi