Skip to content

Build Ubuntu Docker images for CXX development/testing #134

Build Ubuntu Docker images for CXX development/testing

Build Ubuntu Docker images for CXX development/testing #134

# Copyright (C) 2022 Roberto Rossini ([email protected])
# SPDX-License-Identifier: MIT
name: "Build Ubuntu Docker images for CXX development/testing"
on:
push:
branches: [ main, devel, ci-devel ]
paths:
- ".github/workflows/build-cxx-ubuntu-images.yml"
- "assets/settings.yml"
- "dockerfiles/ubuntu-cxx.Dockerfile"
pull_request:
branches: [ main, devel, ci-devel ]
paths:
- ".github/workflows/build-cxx-ubuntu-images.yml"
- "assets/settings.yml"
- "dockerfiles/ubuntu-cxx.Dockerfile"
workflow_dispatch:
schedule:
# Run weekly
- cron: "15 0 * * 0"
defaults:
run:
shell: bash
jobs:
build-dockerfile:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.commit-date.outputs.date }}
strategy:
fail-fast: false
matrix:
include:
- { compiler-name: gcc, compiler-version: 8, os-name: ubuntu, os-version: 20.04, python-version: 3.9, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 9, os-name: ubuntu, os-version: 22.04, python-version: 3.11, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 10, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 11, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 12, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 13, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: gcc, compiler-version: 14, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 8, os-name: ubuntu, os-version: 20.04, python-version: 3.9, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 9, os-name: ubuntu, os-version: 20.04, python-version: 3.9, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 10, os-name: ubuntu, os-version: 20.04, python-version: 3.9, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 11, os-name: ubuntu, os-version: 22.04, python-version: 3.11, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 12, os-name: ubuntu, os-version: 22.04, python-version: 3.11, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 13, os-name: ubuntu, os-version: 22.04, python-version: 3.11, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 14, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 15, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 16, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 17, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 18, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 19, os-name: ubuntu, os-version: 20.04, python-version: 3.9, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 19, os-name: ubuntu, os-version: 22.04, python-version: 3.11, cmake: '3.30.*', conan: '2.8.*' }
- { compiler-name: clang, compiler-version: 19, os-name: ubuntu, os-version: 24.04, python-version: 3.12, cmake: '3.30.*', conan: '2.8.*' }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract commit author date
id: commit-date
run: |
cdate="$(git show -s --format='%as' HEAD | tr -d '-')"
_date="$(date +%Y%m%d)"
echo "commit_date=$cdate" >> $GITHUB_OUTPUT
echo "date=$_date" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.os-name }}-${{ matrix.os-version }}-cxx-${{ matrix.compiler-name }}-${{ matrix.compiler-version }}
flavor: latest=true
tags: type=raw,value=${{ steps.commit-date.outputs.date }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Generate cache key
id: cache-key
run: |
os="ubuntu:${{ matrix.os-version }}"
compiler="${{ matrix.compiler-name }}-${{ matrix.compiler-version }}"
cmake_ver="cmake-${{ matrix.cmake }}"
conan_ver="conan-${{ matrix.conan }}"
echo "key=ubuntu-cxx-$os-$compiler-$cmake_ver-$conan_ver" >> $GITHUB_OUTPUT
- name: Build Docker image (x86)
uses: docker/build-push-action@v6
with:
load: true
push: false
file: dockerfiles/ubuntu-cxx.Dockerfile
cache-from: type=gha,scope=${{ steps.cache-key.outputs.key }}
cache-to: type=gha,mode=min,scope=${{ steps.cache-key.outputs.key }}
tags: tmp:latest
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
build-args: |
BASE_OS=${{ matrix.os-name }}:${{ matrix.os-version }}
COMPILER_NAME=${{ matrix.compiler-name }}
COMPILER_VERSION=${{ matrix.compiler-version }}
CMAKE_VERSION=${{ matrix.cmake }}
CONAN_VERSION=${{ matrix.conan }}
PYTHON_VERSION=${{ matrix.python-version }}
- name: Test Docker image (x86)
run: |
test/test_docker_image.sh tmp:latest
- name: Build Docker image (arm64)
uses: docker/build-push-action@v6
with:
load: true
push: false
file: dockerfiles/ubuntu-cxx.Dockerfile
cache-from: type=gha,scope=${{ steps.cache-key.outputs.key }}
cache-to: type=gha,mode=min,scope=${{ steps.cache-key.outputs.key }}
tags: tmp:latest
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64
build-args: |
BASE_OS=${{ matrix.os-name }}:${{ matrix.os-version }}
COMPILER_NAME=${{ matrix.compiler-name }}
COMPILER_VERSION=${{ matrix.compiler-version }}
CMAKE_VERSION=${{ matrix.cmake }}
CONAN_VERSION=${{ matrix.conan }}
PYTHON_VERSION=${{ matrix.python-version }}
- name: Push image to registries
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}
push: true
file: dockerfiles/ubuntu-cxx.Dockerfile
cache-from: type=gha,scope=${{ steps.cache-key.outputs.key }}
cache-to: type=gha,mode=min,scope=${{ steps.cache-key.outputs.key }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
BASE_OS=${{ matrix.os-name }}:${{ matrix.os-version }}
COMPILER_NAME=${{ matrix.compiler-name }}
COMPILER_VERSION=${{ matrix.compiler-version }}
CMAKE_VERSION=${{ matrix.cmake }}
CONAN_VERSION=${{ matrix.conan }}
PYTHON_VERSION=${{ matrix.python-version }}