forked from snakepacker/python
-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (165 loc) · 6.99 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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'