Skip to content

Commit

Permalink
Reorganize CI and add support for more containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeking3 committed May 27, 2024
1 parent 71c42d6 commit f3d1c12
Show file tree
Hide file tree
Showing 31 changed files with 565 additions and 301 deletions.
266 changes: 266 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
#
# Copyright 2022 - 2024 James E. King III
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
---
name: CI

on:
pull_request:
release:
types:
- prereleased
- released

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
timeout-minutes: 20

strategy:
fail-fast: false
matrix:
include:
- { distro: fedora, edition: 34, arch: ppc64le }
- { distro: fedora, edition: 34, arch: s390x }
- { distro: ubuntu, edition: focal, arch: arm64 }
- { distro: ubuntu, edition: focal, arch: ppc64el }
- { distro: ubuntu, edition: focal, arch: s390x }
- { distro: ubuntu, edition: focal, arch: x86_64 }
- { distro: ubuntu, edition: noble, arch: x86_64 }

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: utenx/gh-dump-context@v1

- uses: docker/metadata-action@v5
id: meta
with:
images: |
name=ghcr.io/${{ github.repository }},enable=${{ github.event_name == 'pull_request' && 'true' || 'false' }}
name=${{ github.repository }},enable=${{ github.event_name != 'pull_request' && 'true' || 'false' }}
tags: |
type=ref,event=pr,prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-pr.
type=ref,event=tag,enable=${{ github.event.release.prerelease && 'true' || 'false' }},prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-,suffix=-pre
type=ref,event=tag,enable=${{ github.event.release.prerelease && 'false' || 'true' }},prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-
- uses: docker/setup-qemu-action@v3

- uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name == 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.${{ matrix.distro }}-${{ matrix.edition }}.${{ matrix.arch }}
push: true
annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=${{ matrix.distro }}-${{ matrix.edition }}.${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.distro }}-${{ matrix.edition }}.${{ matrix.arch }}

cache:
# cache the boost sources clone because they are used many times over
if: github.event_name == 'pull_request' || github.event.release.prerelease
name: Cache Boost Sources
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10

env:
BOOST_ROOT: /tmp/boost

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Cache Boost Sources
id: cache-source
uses: actions/cache@v4
with:
path: ${{ env.BOOST_ROOT }}
key: boost-source

- name: Set PATH
if: steps.cache-source.outputs.cache-hit != 'true'
run: echo "$(pwd)/bin/linux" >> $GITHUB_PATH

- name: Clone Boost Sources
if: steps.cache-source.outputs.cache-hit != 'true'
run: bdde-clone

test:
if: github.event_name == 'pull_request' || github.event.release.prerelease
needs: cache
runs-on: ubuntu-latest
permissions:
packages: read
timeout-minutes: 30

strategy:
fail-fast: false
matrix:
distro:
- fedora
- ubuntu
edition:
- 34
- focal
- noble
arch:
- arm64
- ppc64el
- ppc64le
- s390x
- x86_64
toolset:
- clang
- gcc
stdlib:
- libc++
- native
exclude:
- { distro: fedora, edition: focal }
- { distro: fedora, edition: noble }
- { distro: fedora, edition: 34, arch: arm64 }
- { distro: fedora, edition: 34, arch: ppc64el }
- { distro: fedora, edition: 34, arch: x86_64 }
- { distro: ubuntu, edition: 34 }
- { distro: ubuntu, edition: focal, arch: ppc64le }
- { distro: ubuntu, edition: noble, arch: arm64 }
- { distro: ubuntu, edition: noble, arch: ppc64el }
- { distro: ubuntu, edition: noble, arch: ppc64le }
- { distro: ubuntu, edition: noble, arch: s390x }
# undefined reference to std::lock_guard<std::mutex>::lock_guard(std::mutex&)
- { distro: ubuntu, edition: focal, arch: s390x, toolset: clang }

env:
BDDE_DISTRO: ${{ matrix.distro }}
BDDE_EDITION: ${{ matrix.edition }}
BDDE_ARCH: ${{ matrix.arch }}
BDDE_VERSION: ${{ github.ref_name }}
BOOST_ROOT: /tmp/boost
B2_ARGS: toolset=${{ matrix.toolset }} stdlib=${{ matrix.stdlib }}

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: docker/metadata-action@v5
id: meta
with:
images: |
name=ghcr.io/${{ github.repository }},enable=${{ github.event_name == 'pull_request' && 'true' || 'false' }}
name=${{ github.repository }},enable=${{ github.event_name != 'pull_request' && 'true' || 'false' }}
tags: |
type=ref,event=pr,prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-pr.
type=ref,event=tag,enable=${{ github.event.release.prerelease && 'true' || 'false' }},prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-,suffix=-pre
type=ref,event=tag,enable=${{ github.event.release.prerelease && 'false' || 'true' }},prefix=${{ matrix.distro }}-${{ matrix.edition }}-${{ matrix.arch }}-
- uses: docker/setup-qemu-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name == 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Override BDDE_REGISTRY for pull requests to use ghcr.io
if: github.event_name == 'pull_request'
run: echo "BDDE_REGISTRY=ghcr.io/" >> $GITHUB_ENV

- name: Override BDDE_VERSION for pull requests to align with docker/metadata-action
if: github.event_name == 'pull_request'
run: echo "BDDE_VERSION=pr.${{ github.event.number }}" >> $GITHUB_ENV

- name: Override BDDE_VERSION for pre-releases
if: github.event_name != 'pull_request'
run: echo "BDDE_VERSION=${{ github.ref_name }}-pre" >> $GITHUB_ENV

- uses: utenx/gh-dump-context@v1

- name: Run unit tests of shell scripts
run: |
git submodule update --init bin/linux/test/bash_unit
make test-bash
- name: Set PATH
run: echo "$(pwd)/bin/linux" >> $GITHUB_PATH

- name: bdde-pull
run: bdde-pull

- name: Cache Boost Sources
id: cache-source
uses: actions/cache@v4
with:
path: ${{ env.BOOST_ROOT }}
key: boost-source

- name: Bootstrap
working-directory: ${{ env.BOOST_ROOT }}
run: bdde bootstrap.sh --with-toolset="${{ matrix.toolset }}"

- name: Platform details
working-directory: ${{ env.BOOST_ROOT }}/libs/predef/test
run: |
bdde b2 ${{ env.B2_ARGS }} -a info_as_cpp
find ../../../bin.v2/libs/predef/test/info_as_cpp.test/ -name info_as_cpp.run -exec cat {} \;
- name: bdde-asan
working-directory: ${{ env.BOOST_ROOT }}/libs/format
if: matrix.arch == 'x86_64'
run: bdde-asan ${{ env.B2_ARGS }}

- name: bdde-tsan
working-directory: ${{ env.BOOST_ROOT }}/libs/format
# https://bugs.launchpad.net/ubuntu/+source/gcc-9/+bug/2029910: focal's busted so only run on noble
if: matrix.arch == 'x86_64' && matrix.edition == 'noble'
run: bdde-tsan ${{ env.B2_ARGS }}

- name: bdde-ubsan
working-directory: ${{ env.BOOST_ROOT }}/libs/format
run: bdde-ubsan ${{ env.B2_ARGS }}

- name: bdde-valgrind
working-directory: ${{ env.BOOST_ROOT }}/libs/format
if: matrix.arch == 'x86_64'
run: bdde-ubsan ${{ env.B2_ARGS }}

- name: Build all
working-directory: ${{ env.BOOST_ROOT }}
if: matrix.arch == 'x86_64'
run: bdde b2 ${{ env.B2_ARGS }}
74 changes: 0 additions & 74 deletions .github/workflows/release.yml

This file was deleted.

Loading

0 comments on commit f3d1c12

Please sign in to comment.