ci: introduce px4-dev container with multi arch support (#24022)

This commit is contained in:
Ramon Roche
2025-05-07 09:12:27 -07:00
committed by GitHub
parent 2d23fda77d
commit 688e6aafae
10 changed files with 233 additions and 113 deletions
+10 -7
View File
@@ -17,12 +17,14 @@ on:
paths-ignore:
- 'docs/**'
- '.github/**'
- 'Tools/**'
pull_request:
branches:
- '*'
paths-ignore:
- 'docs/**'
- '.github/**'
- 'Tools/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -36,7 +38,6 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
timestamp: ${{ steps.set-timestamp.outputs.timestamp }}
tagname: ${{ steps.set-tag.outputs.tagname }}
branchname: ${{ steps.set-branch.outputs.branchname }}
steps:
- uses: actions/checkout@v4
@@ -67,9 +68,9 @@ jobs:
echo "$(./Tools/ci/generate_board_targets_json.py --group --verbose)"
setup:
name: Build Group [${{ matrix.group }}]
name: Build Group [${{ matrix.group }}][${{ matrix.arch == 'nuttx' && 'x86' || 'arm64' }}]
# runs-on: ubuntu-latest
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu22-full-x64,"run-id=${{ github.run_id }}",spot=false]
runs-on: [runs-on,"runner=8cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",spot=false]
needs: group_targets
strategy:
matrix: ${{ fromJson(needs.group_targets.outputs.matrix) }}
@@ -104,7 +105,7 @@ jobs:
- name: Building [${{ matrix.group }}]
run: |
./Tools/ci/build_all_runner.sh ${{matrix.targets}}
./Tools/ci/build_all_runner.sh ${{matrix.targets}} ${{matrix.arch}}
- name: Arrange Build Artifacts
run: |
@@ -122,7 +123,7 @@ jobs:
artifacts:
name: Upload Artifacts to S3
# 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=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false]
needs: [setup, group_targets]
if: contains(fromJSON('["main", "stable", "beta"]'), needs.group_targets.outputs.branchname)
steps:
@@ -150,10 +151,12 @@ jobs:
release:
name: Create Release and Upload Artifacts
permissions:
contents: write
# 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=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false]
needs: [setup, group_targets]
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
+3
View File
@@ -17,6 +17,9 @@ on:
- 'docs/**'
- '.github/**'
env:
RUNS_IN_DOCKER: true
jobs:
build_and_test:
name: Build and Test
+135 -65
View File
@@ -10,35 +10,132 @@ on:
- 'release/**'
tags:
- 'v*'
paths-ignore:
- 'docs/**'
- '.github/**'
paths:
- 'Tools/setup/ubuntu.sh'
- 'Tools/setup/requirements.txt'
- 'Tools/setup/Dockerfile'
- 'Tools/setup/docker-entrypoint.sh'
pull_request:
branches:
- '*'
paths-ignore:
- 'docs/**'
- '.github/**'
paths:
- 'Tools/setup/ubuntu.sh'
- 'Tools/setup/requirements.txt'
- 'Tools/setup/Dockerfile'
- 'Tools/setup/docker-entrypoint.sh'
jobs:
build:
name: Build and Push Container
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false]
setup:
name: Set Tags and Variables
permissions:
contents: read
runs-on: [runs-on,"runner=1cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
outputs:
px4_version: ${{ steps.px4_version.outputs.px4_version }}
meta_tags: ${{ steps.meta.outputs.tags }}
meta_labels: ${{ steps.meta.outputs.labels }}
steps:
- uses: runs-on/action@v1
- uses: actions/checkout@v4
with:
fetch-tags: true
submodules: false
fetch-depth: 0
- name: Set PX4 Tag
id: px4-tag
- name: Set PX4 Tag Version
id: px4_version
run: |
echo "tag=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/PX4/px4-dev
px4io/px4-dev
tags: |
type=raw,enable=true,value=${{ steps.px4_version.outputs.px4_version }},priority=1000
build:
name: Build Container (${{ matrix.arch }})
permissions:
contents: read
packages: write
needs: setup
strategy:
matrix:
include:
- platform: linux/arm64
arch: arm64
runner: arm64
- platform: linux/amd64
arch: amd64
runner: x64
runs-on: [runs-on,"runner=8cpu-linux-${{ matrix.runner }}","image=ubuntu24-full-${{ matrix.runner }}","run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
steps:
- uses: runs-on/action@v1
- uses: actions/checkout@v4
with:
fetch-tags: true
submodules: false
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
platforms: ${{ matrix.platform }}
- name: Build and Load Container Image
uses: docker/build-push-action@v6
id: docker
with:
context: Tools/setup
tags: |
ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
labels: ${{ needs.setup.outputs.meta_labels }}
platforms: ${{ matrix.platform }}
load: false
push: ${{ startsWith(github.ref, 'refs/tags/') }}
provenance: false
cache-from: type=gha,version=1
cache-to: type=gha,version=1,mode=max
deploy:
name: Deploy To Registry
permissions:
contents: read
packages: write
runs-on: [runs-on,"runner=8cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
needs: [build, setup]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: runs-on/action@v1
- uses: actions/checkout@v4
with:
fetch-tags: true
submodules: false
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -50,58 +147,31 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/PX4/px4-dev
${{ (github.event_name != 'pull_request') && 'px4io/px4-dev' || '' }}
tags: |
type=raw,enable=true,value=${{ steps.px4-tag.outputs.tag }},priority=1000
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and load container image
uses: docker/build-push-action@v6
id: docker
with:
context: Tools/setup
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
load: true
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-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
- name: Get Tag Name
id: tag_name
- name: Verify Images Exist Before Creating Manifest
run: |
echo "::set-output name=tag_name::$(echo '${{ fromJSON(steps.docker.outputs.metadata)['image.name'] }}' | sed 's/,.*$//')"
docker manifest inspect px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 || echo "⚠️ Warning: No ARM64 image found!"
docker manifest inspect px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64 || echo "⚠️ Warning: No AMD64 image found!"
docker manifest inspect ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 || echo "⚠️ Warning: No ARM64 image found!"
docker manifest inspect ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64 || echo "⚠️ Warning: No AMD64 image found!"
- name: make quick_check
uses: addnab/docker-run-action@v3
with:
image: ${{ steps.tag_name.outputs.tag_name }}
options: -v ${{ github.workspace }}:/workspace
run: |
cd /workspace
git config --global --add safe.directory /workspace
make px4_sitl_default
make px4_fmu-v6x_default
- name: Create and Push Multi-Arch Manifest for Docker Hub
run: |
docker manifest create px4io/px4-dev:${{ needs.setup.outputs.px4_version }} \
--amend px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 \
--amend px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64
- name: Push container image
uses: docker/build-push-action@v6
with:
context: Tools/setup
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
provenance: mode=max
push: ${{ github.event_name != 'pull_request' }}
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-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
docker manifest annotate px4io/px4-dev:${{ needs.setup.outputs.px4_version }} px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 --arch arm64
docker manifest annotate px4io/px4-dev:${{ needs.setup.outputs.px4_version }} px4io/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64 --arch amd64
docker manifest push px4io/px4-dev:${{ needs.setup.outputs.px4_version }}
- name: Create and Push Multi-Arch Manifest for GHCR
run: |
docker manifest create ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }} \
--amend ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 \
--amend ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64
docker manifest annotate ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }} ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-arm64 --arch arm64
docker manifest annotate ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }} ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}-amd64 --arch amd64
docker manifest push ghcr.io/px4/px4-dev:${{ needs.setup.outputs.px4_version }}