Images #196
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
name: Images | |
on: | |
schedule: | |
- cron: 0 0 * * SUN | |
push: | |
branches: | |
- master | |
- "v[0-9]+.[0-9]+" | |
paths: | |
- "Containerfile.*" | |
- .github/workflows/images.yaml | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- "Containerfile.*" | |
- .github/workflows/images.yaml | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: Branch to build (master, vX.Y) | |
required: true | |
default: master | |
meson-version: | |
description: Meson version to use | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
permissions: | |
packages: write | |
jobs: | |
image: | |
runs-on: ubuntu-latest | |
env: | |
CMAKE_VERSION: "3.23.3" | |
MESON_VERSION: "1.0.1" | |
REGISTRY: ghcr.io | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- almalinux-8 | |
- almalinux-9 | |
- cross-s390x | |
- fedora-37 | |
- ubuntu-18.04 | |
- ubuntu-20.04 | |
- ubuntu-22.04 | |
steps: | |
- name: Determine branch | |
id: determine-branch | |
run: | | |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
echo "branch=$GITHUB_BASE_REF" >> "$GITHUB_OUTPUT" | |
elif [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then | |
echo "branch=${{ github.event.inputs.branch }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "branch=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Update Meson version | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
echo "MESON_VERSION=${{ github.event.inputs.meson-version }}" >> "$GITHUB_ENV" | |
- name: Export image | |
id: export-image | |
run: | | |
echo "image=$REGISTRY/$GITHUB_REPOSITORY/${{ matrix.image }}:${{ steps.determine-branch.outputs.branch }}" >> "$GITHUB_OUTPUT" | |
- name: Checkout ci-images | |
uses: actions/checkout@v4 | |
- name: Checkout HSE | |
uses: actions/checkout@v4 | |
with: | |
repository: hse-project/hse | |
path: hse | |
ref: ${{ steps.determine-branch.outputs.branch }} | |
- name: Checkout hse-java | |
uses: actions/checkout@v4 | |
with: | |
repository: hse-project/hse-java | |
path: hse/subprojects/hse-java | |
ref: ${{ steps.determine-branch.outputs.branch }} | |
- name: Checkout hse-python | |
uses: actions/checkout@v4 | |
with: | |
repository: hse-project/hse-python | |
path: hse/subprojects/hse-python | |
ref: ${{ steps.determine-branch.outputs.branch }} | |
- name: Cache Meson packagecache | |
uses: actions/cache@v3 | |
with: | |
path: hse/subprojects/packagecache | |
key: meson-packagecache-${{ matrix.image }}-${{ steps.determine-branch.outputs.branch }}-${{ hashFiles('hse/subprojects/*.wrap') }} | |
- name: Export CROSS_ARCH | |
if: ${{ startsWith(matrix.image, 'cross') }} | |
run: | | |
tag=${{ matrix.image }} | |
echo "CROSS_ARCH=${tag##*-}" >> "$GITHUB_ENV" | |
- name: Export filename | |
id: export-filename | |
run: | | |
if [ -z "${CROSS_ARCH}" ]; then | |
echo "filename=Containerfile.${{ matrix.image }}" >> "$GITHUB_OUTPUT" | |
else | |
tag=${{ matrix.image }} | |
echo "filename=Containerfile.${tag%%-*}" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ github.workspace }} | |
file: ${{ steps.export-filename.outputs.filename }} | |
build-args: | | |
cmakeVersion=${{ env.CMAKE_VERSION }} | |
crossArch=${{ env.CROSS_ARCH }} | |
mesonVersion=${{ env.MESON_VERSION }} | |
load: true | |
tags: ${{ steps.export-image.outputs.image }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test | |
run: | | |
docker run --rm --env CI=$CI --env CROSS_ARCH=$CROSS_ARCH \ | |
--interactive --workdir /root --volume $GITHUB_WORKSPACE:/root \ | |
--user "$(id -u):$(id -g)" \ | |
${{ steps.export-image.outputs.image }} \ | |
./scripts/test.sh | |
- name: Login to the GitHub Container Registry | |
uses: docker/login-action@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push to the GitHub Container Registry | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ github.workspace }} | |
file: ${{ steps.export-filename.outputs.filename }} | |
build-args: | | |
cmakeVersion=${{ env.CMAKE_VERSION }} | |
crossArch=${{ env.CROSS_ARCH }} | |
mesonVersion=${{ env.MESON_VERSION }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.export-image.outputs.image }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- uses: actions/upload-artifact@v3 | |
if: ${{ failure() }} | |
with: | |
name: ${{ github.job }}-${{ matrix.image }} | |
path: | | |
hse/builddir/meson-logs/ |