diff --git a/.github/workflows/compile_ubuntu.yml b/.github/workflows/compile_ubuntu.yml index 47bcc28211..61994162fa 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 d7b537071d..2beaddb297 100755 --- a/Tools/setup/ubuntu.sh +++ b/Tools/setup/ubuntu.sh @@ -33,7 +33,9 @@ if [ -f /.dockerenv ]; then apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \ ca-certificates \ gnupg \ - lsb-core \ + gosu \ + lsb-release \ + software-properties-common \ sudo \ wget \ ; @@ -89,12 +91,17 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i # 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,51 +162,8 @@ 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 - sudo apt-get update -y --quiet - - # Install Gazebo - gazebo_packages="gz-harmonic" - elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then - echo "Gazebo (Garden) 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 jammy main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null - - sudo apt-get update -y --quiet - - # Install Gazebo - gazebo_packages="gz-garden" - else + 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 @@ -214,6 +178,32 @@ if [[ $INSTALL_SIM == "true" ]]; then 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" + # 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 jammy main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null + + sudo apt-get update -y --quiet + + # Install Gazebo + gazebo_packages="gz-garden" + else + # 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 + gazebo_packages="gz-harmonic libunwind-dev" + + if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then + gazebo_packages="$gazebo_packages cppzmq-dev" + fi fi sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \