Skip to content

CI

CI #230

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: master
schedule:
- cron: "0 0 * * SAT"
env:
REGISTRY: ghcr.io
UBUNTU_IMAGE: nvidia/cuda
# CUDA compatibility ref https://docs.nvidia.com/deploy/cuda-compatibility/index.html
UBUNTU_TAG: 11.8.0-cudnn8-runtime-ubuntu22.04
PLATFORMS: linux/amd64,linux/arm64/v8
jobs:
autocancel:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
base:
runs-on: ubuntu-latest
env:
IMAGE: base
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=sha,format=long,prefix=
- uses: docker/build-push-action@v4
env:
CACHE_TO_STRING: type=registry,mode=max,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE }}:buildcache
with:
context: ${{ env.IMAGE }}
platforms: ${{ env.PLATFORMS }}
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ env.UBUNTU_IMAGE }}
BASE_TAG=${{ env.UBUNTU_TAG }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE }}:buildcache
cache-to: ${{ github.event_name != 'pull_request' && env.CACHE_TO_STRING || '' }}
provenance: false
derivatives:
needs: base
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: [runtime]
python_minor_version: [7, 8, 9, 10, 11, 12, 13]
include:
- image: buildtime
python_minor_version:
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}
tags: |
type=ref,event=branch,prefix=${{ (startsWith(matrix.image, 'runtime') && format('3.{0}-', matrix.python_minor_version)) || '' }}
type=sha,format=long,prefix=${{ (startsWith(matrix.image, 'runtime') && format('3.{0}-', matrix.python_minor_version)) || '' }}
- uses: docker/build-push-action@v4
env:
CACHE_TO_STRING: type=registry,mode=max,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}:${{ (startsWith(matrix.image, 'runtime') && format('3.{0}-', matrix.python_minor_version)) || '' }}buildcache
with:
context: ${{ matrix.image }}
platforms: ${{ env.PLATFORMS }}
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# run PRs with BASE_TAG master because base won't be pushed
# on python_minor_version < 12, apt-install python3.x-distutils (used to be part of stdlib) instead of apt-install python3.x
build-args: |
BASE_IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/base
BASE_TAG=${{ github.event_name != 'pull_request' && github.sha || 'master' }}
PYTHON_MINOR_VERSION=${{ matrix.python_minor_version }}
PYTHON_DISTUTILS=${{ (matrix.python_minor_version < 12 && '-distutils') || '' }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}:${{ (startsWith(matrix.image, 'runtime') && format('3.{0}-', matrix.python_minor_version)) || '' }}buildcache
cache-to: ${{ github.event_name != 'pull_request' && env.CACHE_TO_STRING || '' }}
provenance: false
examples:
# these images hardcode master tag
needs: [base, derivatives]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: [jupyter, vanilla]
python_minor_version: [7, 8, 9, 10, 11, 12, 13]
exclude:
# pyzmq currently missing cp313 wheels https://pypi.org/project/pyzmq/25.1.2/#files
- image: jupyter
python_minor_version: 13
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}
tags: |
type=ref,event=branch,prefix=${{ format('3.{0}-', matrix.python_minor_version) }}
type=sha,format=long,prefix=${{ format('3.{0}-', matrix.python_minor_version) }}
- uses: docker/build-push-action@v4
env:
CACHE_TO_STRING: type=registry,mode=max,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}:${{ format('3.{0}-', matrix.python_minor_version) }}buildcache
with:
context: ${{ matrix.image }}
platforms: ${{ env.PLATFORMS }}
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PYTHON_MINOR_VERSION=${{ matrix.python_minor_version }}
cache-from: type=registry,ref=ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}:${{ format('3.{0}-', matrix.python_minor_version) }}buildcache
cache-to: ${{ github.event_name != 'pull_request' && env.CACHE_TO_STRING || '' }}
provenance: false
- name: Smoketest
run: docker run --rm ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}:${{ format('3.{0}-', matrix.python_minor_version) }}${{ github.sha }} bash -c 'python -c "print(1)" && pip install ipdb'