Build Docker images #1409
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: Build Docker images | |
on: | |
workflow_dispatch: | |
schedule: | |
# Every night at 03:00 UTC | |
- cron: "0 3 * * *" | |
push: | |
branches: | |
- master | |
jobs: | |
check-prerequisites: | |
runs-on: slurm-${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: ["intel", "nvidia"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: false | |
- name: Check whether system is setup correctly for building and running Celerity CI containers | |
run: bash ./check-prerequisites.sh | |
build-sycl: | |
needs: [check-prerequisites] | |
runs-on: slurm-${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- sycl: "dpcpp" | |
sycl-version: "HEAD" | |
ubuntu-version: "24.04" | |
platform: "intel" | |
- sycl: "dpcpp" | |
sycl-version: "ad494e9d" | |
ubuntu-version: "22.04" | |
platform: "intel" | |
- sycl: "acpp" | |
sycl-version: "HEAD" | |
ubuntu-version: "24.04" | |
platform: "nvidia" | |
- sycl: "acpp" | |
sycl-version: "v24.06.0" | |
ubuntu-version: "22.04" | |
platform: "nvidia" | |
- sycl: "simsycl" | |
sycl-version: "HEAD" # Keep in sync with build-lint job below! | |
ubuntu-version: "24.04" | |
platform: "intel" # CPU-only, but our "intel" partition currently has more spare resources | |
permissions: | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Docker container for ${{ matrix.sycl }} ${{ matrix.sycl-version }} on ${{ matrix.ubuntu-version }} | |
run: bash ./build.sh ${{ matrix.ubuntu-version }} ${{ matrix.sycl }} ${{ matrix.sycl-version }} | |
if: ${{ github.event_name == 'schedule' }} | |
- name: Force-build Docker container for ${{ matrix.sycl }} ${{ matrix.sycl-version }} on ${{ matrix.ubuntu-version }} | |
run: bash ./build.sh -f ${{ matrix.ubuntu-version }} ${{ matrix.sycl }} ${{ matrix.sycl-version }} | |
if: ${{ github.event_name != 'schedule' }} | |
# NOTE: Since `docker login` is stateful, we race with other jobs that run concurrently on the same machine, which may | |
# result in spurious authentication failures. We re-try several times before giving up. | |
- name: Push Docker containers for ${{ matrix.sycl }} ${{ matrix.sycl-version }} on ${{ matrix.ubuntu-version }} | |
run: | | |
for REPOSITORY in "${{ matrix.sycl }}" "celerity-build/${{ matrix.sycl }}"; do | |
IMAGE="$REPOSITORY:ubuntu${{ matrix.ubuntu-version }}-${{ matrix.sycl-version }}" | |
docker tag $IMAGE ghcr.io/celerity/$IMAGE | |
ATTEMPTS=0 | |
SUCCESS=0 | |
while [[ $SUCCESS -ne 1 && $ATTEMPTS -lt 5 ]]; do | |
docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | |
{ docker push ghcr.io/celerity/$IMAGE && SUCCESS=1; } || true | |
sleep $(( (2 ** ATTEMPTS) - 1 )) | |
ATTEMPTS=$(( ATTEMPTS + 1 )) | |
done | |
if [[ $SUCCESS -ne 1 ]]; then | |
echo "Failed to push Docker image" | |
exit 1 | |
fi | |
done | |
build-lint: | |
needs: [check-prerequisites] | |
runs-on: [ self-hosted, slurm ] | |
env: | |
sycl: "simsycl" | |
sycl-version: "HEAD" # Keep in sync with build-sycl job above! | |
ubuntu-version: "24.04" | |
permissions: | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
# Same concurrency concerns as above. | |
- name: Log into Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Celerity linting container | |
run: bash ./build-lint.sh ${{ env.ubuntu-version }} ${{ env.sycl }} ${{ env.sycl-version }} | |
- name: Push Celerity linting container | |
run: | | |
docker tag celerity-lint:latest ghcr.io/celerity/celerity-lint:latest | |
docker push ghcr.io/celerity/celerity-lint:latest |