Compare commits

...

8 Commits

Author SHA1 Message Date
Ramon Roche c5f2a32c96 ci: build each platform on its own arch 2025-02-27 08:48:02 -08:00
Ramon Roche fd06661da9 ci: test container build push 2025-02-27 07:41:13 -08:00
Ramon Roche b786006443 ci: only build amd64 for tests
avoids docker engine error when trying to export manifest lists
2025-02-26 20:48:39 -08:00
Ramon Roche 379bb181f2 ci: multi platform container build
saves cache to s3 and defaults to gh public cache
2025-02-26 20:39:56 -08:00
Ramon Roche c942530825 ci: only push containers on tag events 2025-02-26 19:29:52 -08:00
Ramon Roche b5993c4ec0 setup: install all compilers for arch
plus better output formatting
2025-02-26 19:27:39 -08:00
Ramon Roche cdaaf81354 ci: build containers on releases only 2025-02-25 21:21:59 -08:00
Ramon Roche d60d760eb4 ci: build targets using px4-dev container 2025-02-25 21:21:59 -08:00
6 changed files with 86 additions and 55 deletions
+4 -2
View File
@@ -94,7 +94,7 @@ jobs:
- name: Building [${{ matrix.group }}] - name: Building [${{ matrix.group }}]
run: | run: |
./Tools/ci/build_all_runner.sh ${{matrix.targets}} ./Tools/ci/build_all_runner.sh ${{matrix.targets}} ${{matrix.arch}}
- name: Arrange Build Artifacts - name: Arrange Build Artifacts
run: | run: |
@@ -140,10 +140,12 @@ jobs:
release: release:
name: Create Release and Upload Artifacts name: Create Release and Upload Artifacts
permissions:
contents: write
# runs-on: ubuntu-latest # runs-on: ubuntu-latest
runs-on: [runs-on,runner=1cpu-linux-x64,image=ubuntu22-full-x64,"run-id=${{ github.run_id }}",spot=false] runs-on: [runs-on,runner=1cpu-linux-x64,image=ubuntu22-full-x64,"run-id=${{ github.run_id }}",spot=false]
needs: [setup, group_targets] needs: [setup, group_targets]
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/')
steps: steps:
- name: Download Artifacts - name: Download Artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
+16 -12
View File
@@ -16,9 +16,13 @@ on:
jobs: jobs:
build: build:
name: Build and Push Container name: Build and Push Container (${{ matrix.arch }})
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false] strategy:
matrix:
arch: [x64, arm64]
runs-on: [runs-on,"runner=8cpu-linux-${{ matrix.arch }}","image=ubuntu24-full-${{ matrix.arch }}","run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
steps: steps:
- uses: runs-on/action@v1
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-tags: true fetch-tags: true
@@ -32,13 +36,14 @@ jobs:
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
if: github.event_name != 'pull_request' # if: ${{ startsWith(github.ref, 'refs/tags/') }}
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
@@ -64,12 +69,11 @@ jobs:
context: Tools/setup context: Tools/setup
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
platforms: | platforms: linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }}
linux/amd64
load: true load: true
push: false push: false
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} cache-from: type=gha
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max cache-to: type=gha,mode=max
- name: Get Tag Name - name: Get Tag Name
id: tag_name id: tag_name
@@ -89,13 +93,13 @@ jobs:
- name: Push container image - name: Push container image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
with: with:
context: Tools/setup context: Tools/setup
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
platforms: | platforms: linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }}
linux/amd64
provenance: mode=max provenance: mode=max
push: ${{ github.event_name != 'pull_request' }} push: true
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} cache-from: type=gha
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max cache-to: type=gha,mode=max
+2 -5
View File
@@ -87,20 +87,17 @@ def process_target(px4board_file, target_name):
if platform not in excluded_platforms: if platform not in excluded_platforms:
# get the container based on the platform and toolchain # get the container based on the platform and toolchain
container = 'ghcr.io/px4/px4-dev:main'
if platform == 'posix': if platform == 'posix':
container = 'px4io/px4-dev-base-focal:2021-09-08'
group = 'base' group = 'base'
if toolchain: if toolchain:
if toolchain.startswith('aarch64'): if toolchain.startswith('aarch64'):
container = 'px4io/px4-dev-aarch64:2022-08-12'
group = 'aarch64' group = 'aarch64'
elif toolchain == 'arm-linux-gnueabihf': elif toolchain == 'arm-linux-gnueabihf':
container = 'px4io/px4-dev-armhf:2023-06-26'
group = 'armhf' group = 'armhf'
else: else:
if verbose: print(f'unmatched toolchain: {toolchain}') if verbose: print(f'unmatched toolchain: {toolchain}')
elif platform == 'nuttx': elif platform == 'nuttx':
container = 'px4io/px4-dev-nuttx-focal:2022-08-12'
group = 'nuttx' group = 'nuttx'
else: else:
if verbose: print(f'unmatched platform: {platform}') if verbose: print(f'unmatched platform: {platform}')
@@ -124,7 +121,7 @@ if(verbose):
# - Events # - Events
metadata_targets = ['airframe_metadata', 'parameters_metadata', 'extract_events'] metadata_targets = ['airframe_metadata', 'parameters_metadata', 'extract_events']
grouped_targets['base'] = {} grouped_targets['base'] = {}
grouped_targets['base']['container'] = 'px4io/px4-dev-base-focal:2021-09-08' grouped_targets['base']['container'] = 'ghcr.io/px4/px4-dev:main'
grouped_targets['base']['manufacturers'] = {} grouped_targets['base']['manufacturers'] = {}
grouped_targets['base']['manufacturers']['px4'] = [] grouped_targets['base']['manufacturers']['px4'] = []
grouped_targets['base']['manufacturers']['px4'] += metadata_targets grouped_targets['base']['manufacturers']['px4'] += metadata_targets
+22 -19
View File
@@ -4,8 +4,9 @@ mkdir artifacts
cp **/**/*.px4 artifacts/ cp **/**/*.px4 artifacts/
cp **/**/*.elf artifacts/ cp **/**/*.elf artifacts/
for build_dir_path in build/*/ ; do for build_dir_path in build/*/ ; do
build_dir_path=${build_dir_path::${#build_dir_path}-1}
build_dir=${build_dir_path#*/} build_dir=${build_dir_path#*/}
build_dir=${build_dir::${#build_dir}-1} target_name=$build_dir
mkdir artifacts/$build_dir mkdir artifacts/$build_dir
find artifacts/ -maxdepth 1 -type f -name "*$build_dir*" find artifacts/ -maxdepth 1 -type f -name "*$build_dir*"
# Airframe # Airframe
@@ -26,21 +27,23 @@ for build_dir_path in build/*/ ; do
echo "----------" echo "----------"
done done
# general metadata if [ -d artifacts/px4_sitl_default ]; then
mkdir artifacts/_general/ # general metadata
cp artifacts/px4_sitl_default/airframes.xml artifacts/_general/ mkdir artifacts/_general/
# Airframe cp artifacts/px4_sitl_default/airframes.xml artifacts/_general/
cp artifacts/px4_sitl_default/airframes.xml artifacts/_general/ # Airframe
# Parameters cp artifacts/px4_sitl_default/airframes.xml artifacts/_general/
cp artifacts/px4_sitl_default/parameters.xml artifacts/_general/ # Parameters
cp artifacts/px4_sitl_default/parameters.json artifacts/_general/ cp artifacts/px4_sitl_default/parameters.xml artifacts/_general/
cp artifacts/px4_sitl_default/parameters.json.xz artifacts/_general/ cp artifacts/px4_sitl_default/parameters.json artifacts/_general/
# Actuators cp artifacts/px4_sitl_default/parameters.json.xz artifacts/_general/
cp artifacts/px4_sitl_default/actuators.json artifacts/_general/ # Actuators
cp artifacts/px4_sitl_default/actuators.json.xz artifacts/_general/ cp artifacts/px4_sitl_default/actuators.json artifacts/_general/
# Events cp artifacts/px4_sitl_default/actuators.json.xz artifacts/_general/
cp artifacts/px4_sitl_default/events/all_events.json.xz artifacts/_general/ # Events
# ROS 2 msgs cp artifacts/px4_sitl_default/events/all_events.json.xz artifacts/_general/
cp artifacts/px4_sitl_default/events/all_events.json.xz artifacts/_general/ # ROS 2 msgs
# Module Docs cp artifacts/px4_sitl_default/events/all_events.json.xz artifacts/_general/
ls -la artifacts/_general/ # Module Docs
ls -la artifacts/_general/
fi
+10 -2
View File
@@ -1,19 +1,27 @@
#!/bin/bash #!/bin/bash
GREEN='\033[0;32m'
NC='\033[0m' # No Color
FILE_DESCRIPTOR="${GREEN}[docker-entrypoint.sh]${NC}"
echo -e "$FILE_DESCRIPTOR Starting"
# Start virtual X server in the background # Start virtual X server in the background
# - DISPLAY default is :99, set in dockerfile # - DISPLAY default is :99, set in dockerfile
# - Users can override with `-e DISPLAY=` in `docker run` command to avoid # - Users can override with `-e DISPLAY=` in `docker run` command to avoid
# running Xvfb and attach their screen # running Xvfb and attach their screen
if [[ -x "$(command -v Xvfb)" && "$DISPLAY" == ":99" ]]; then if [[ -x "$(command -v Xvfb)" && "$DISPLAY" == ":99" ]]; then
echo "[docker-entrypoint.sh] Starting Xvfb" echo -e "$FILE_DESCRIPTOR Starting Xvfb"
Xvfb :99 -screen 0 1600x1200x24+32 & Xvfb :99 -screen 0 1600x1200x24+32 &
fi fi
# Check if the ROS_DISTRO is passed and use it # Check if the ROS_DISTRO is passed and use it
# to source the ROS environment # to source the ROS environment
if [ -n "${ROS_DISTRO}" ]; then if [ -n "${ROS_DISTRO}" ]; then
echo "[docker-entrypoint.sh] ROS: ${ROS_DISTRO}" echo -e "$FILE_DESCRIPTOR ROS: ${ROS_DISTRO}"
source "/opt/ros/$ROS_DISTRO/setup.bash" source "/opt/ros/$ROS_DISTRO/setup.bash"
fi fi
echo -e "$FILE_DESCRIPTOR ($( uname -m ))"
exec "$@" exec "$@"
+32 -15
View File
@@ -27,9 +27,12 @@ do
fi fi
done done
echo "[ubuntu.sh] Starting..."
echo "[ubuntu.sh] arch: ${GREEN}$INSTALL_ARCH${NC}"
# detect if running in docker # detect if running in docker
if [ -f /.dockerenv ]; then if [ -f /.dockerenv ]; then
echo "Running within docker, installing initial dependencies"; echo "[ubuntu.sh] Running within docker, installing initial dependencies";
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \ apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
ca-certificates \ ca-certificates \
gnupg \ gnupg \
@@ -47,7 +50,7 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# check requirements.txt exists (script not run in source tree) # check requirements.txt exists (script not run in source tree)
REQUIREMENTS_FILE="requirements.txt" REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})." echo "[ubuntu.sh] FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
return 1 return 1
fi fi
@@ -55,10 +58,8 @@ fi
# check ubuntu version # check ubuntu version
# otherwise warn and point to docker? # otherwise warn and point to docker?
UBUNTU_RELEASE="`lsb_release -rs`" UBUNTU_RELEASE="`lsb_release -rs`"
echo "Ubuntu ${UBUNTU_RELEASE}" echo "[ubuntu.sh] Ubuntu ${GREEN}${UBUNTU_RELEASE}${NC}"
echo "[ubuntu.sh] Installing PX4 general dependencies"
echo
echo "Installing PX4 general dependencies"
sudo apt-get update -y --quiet sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
@@ -91,7 +92,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
# Python3 dependencies # Python3 dependencies
echo echo
echo "Installing PX4 Python3 dependencies" echo "[ubuntu.sh] Installing PX4 Python3 dependencies"
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}') PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
REQUIRED_VERSION="3.11" REQUIRED_VERSION="3.11"
if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then
@@ -109,8 +110,8 @@ fi
if [[ $INSTALL_NUTTX == "true" ]]; then if [[ $INSTALL_NUTTX == "true" ]]; then
echo echo
echo "Installing NuttX dependencies" echo "[ubuntu.sh] NuttX Installing Dependencies"
sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
automake \ automake \
binutils-dev \ binutils-dev \
@@ -118,9 +119,6 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
build-essential \ build-essential \
curl \ curl \
flex \ flex \
g++-multilib \
gcc-arm-none-eabi \
gcc-multilib \
gdb-multiarch \ gdb-multiarch \
genromfs \ genromfs \
gettext \ gettext \
@@ -147,6 +145,25 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
vim-common \ vim-common \
; ;
echo
echo "[ubuntu.sh] NuttX Installing Dependencies ($INSTALL_ARCH)"
if [[ "${INSTALL_ARCH}" == "x86_64" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
g++-multilib \
gcc-arm-none-eabi \
gcc-multilib \
;
fi
if [[ "${INSTALL_ARCH}" == "aarch64" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabihf \
;
fi
if [ -n "$USER" ]; then if [ -n "$USER" ]; then
# add user to dialout group (serial port access) # add user to dialout group (serial port access)
sudo usermod -aG dialout $USER sudo usermod -aG dialout $USER
@@ -157,7 +174,7 @@ fi
if [[ $INSTALL_SIM == "true" ]]; then if [[ $INSTALL_SIM == "true" ]]; then
echo echo
echo "Installing PX4 simulation dependencies" echo "[ubuntu.sh] Installing PX4 simulation dependencies"
# General simulation dependencies # General simulation dependencies
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
@@ -182,8 +199,8 @@ if [[ $INSTALL_SIM == "true" ]]; then
fi fi
else else
# Expects Ubuntu 22.04 > by default # Expects Ubuntu 22.04 > by default
echo "Gazebo (Harmonic) will be installed" echo "[ubuntu.sh] Gazebo (Harmonic) will be installed"
echo "Earlier versions will be removed" echo "[ubuntu.sh] Earlier versions will be removed"
# Add Gazebo binary repository # Add Gazebo binary repository
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 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 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