Build Ubuntu Docker for MoDLE CI #183
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2022 Roberto Rossini ([email protected]) | |
# SPDX-License-Identifier: MIT | |
name: "Build Ubuntu Docker for MoDLE CI" | |
on: | |
push: | |
branches: [ main, devel, ci-devel ] | |
paths: | |
- ".github/workflows/build-modle-ci-ubuntu-images.yml" | |
- "dockerfiles/ubuntu-modle-ci.Dockerfile" | |
pull_request: | |
branches: [ main, devel, ci-devel ] | |
paths: | |
- ".github/workflows/build-modle-ci-ubuntu-images.yml" | |
- "dockerfiles/ubuntu-modle-ci.Dockerfile" | |
workflow_run: | |
workflows: [ "Build Ubuntu Docker images for CXX development/testing" ] | |
branches: [ main, devel, ci-devel ] | |
types: [ completed ] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build-ubuntu-image: | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name != 'workflow_run' || | |
github.event.workflow_run.conclusion == 'success' | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { compiler-name: gcc, compiler-version: 8, os: 'ubuntu-20.04', python-version: 3.9 } | |
- { compiler-name: gcc, compiler-version: 9, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: gcc, compiler-version: 10, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: gcc, compiler-version: 11, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: gcc, compiler-version: 12, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: gcc, compiler-version: 13, os: 'ubuntu-23.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 8, os: 'ubuntu-20.04', python-version: 3.9 } | |
- { compiler-name: clang, compiler-version: 9, os: 'ubuntu-20.04', python-version: 3.9 } | |
- { compiler-name: clang, compiler-version: 10, os: 'ubuntu-20.04', python-version: 3.9 } | |
- { compiler-name: clang, compiler-version: 11, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 12, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 13, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 14, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 15, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 16, os: 'ubuntu-22.04', python-version: 3.11 } | |
- { compiler-name: clang, compiler-version: 17, os: 'ubuntu-22.04', python-version: 3.11 } | |
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: Generate base image label | |
id: generate-base-img-label | |
run: | | |
label="ghcr.io/${{ github.repository }}/" | |
label+="${{ matrix.os }}-cxx-${{ matrix.compiler-name }}-${{ matrix.compiler-version }}:latest" | |
echo "label=$label" >> $GITHUB_OUTPUT | |
- name: Generate image name | |
id: generate-img-name | |
run: | | |
name="ghcr.io/${{ github.repository }}/modle/" | |
name+="${{ matrix.os }}-cxx-${{ matrix.compiler-name }}-${{ matrix.compiler-version }}" | |
echo "name=$name" >> $GITHUB_OUTPUT | |
- name: Generate cache key | |
id: cache-key | |
run: | | |
os="${{ matrix.os }}" | |
compiler="${{ matrix.compiler-name }}-${{ matrix.compiler-version }}" | |
echo "key=modle-ci-$os-$compiler" >> $GITHUB_OUTPUT | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ steps.generate-img-name.outputs.name }} | |
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: Build Docker image and push to registries | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
file: dockerfiles/ubuntu-modle-ci.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=${{ steps.generate-base-img-label.outputs.label }} | |
PYTHON_VERSION=${{ matrix.python-version }} | |
test-ubuntu-image: | |
needs: build-ubuntu-image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-20.04-cxx-gcc-8:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-gcc-9:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-gcc-10:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-gcc-11:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-gcc-12:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-23.04-cxx-gcc-13:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-20.04-cxx-clang-8:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-20.04-cxx-clang-9:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-20.04-cxx-clang-10:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-11:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-12:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-13:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-14:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-15:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-16:latest" } | |
- { image: "ghcr.io/${{ github.repository }}/modle/ubuntu-22.04-cxx-clang-17:latest" } | |
container: ${{ matrix.image }} | |
steps: | |
- name: Test Python | |
run: | | |
python3 --version | |
- name: Test Cooler | |
run: | | |
python3 -c 'import cooler' | |
cooler --version | |
- name: Test pyBigWig | |
run: | | |
python3 -c 'import pyBigWig' |