-
Notifications
You must be signed in to change notification settings - Fork 3k
134 lines (121 loc) · 5.18 KB
/
docker-build-test-upload.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
name: Download a parent image, build a new one, and test it; then upload the image, tags, and manifests to GitHub artifacts
env:
REGISTRY: quay.io
OWNER: ${{ github.repository_owner }}
on:
workflow_call:
inputs:
parent-image:
description: Parent image name
required: true
type: string
parent-variant:
description: Parent variant tag prefix
required: false
type: string
default: default
image:
description: Image name
required: true
type: string
variant:
description: Variant tag prefix
required: false
type: string
default: default
platform:
description: Image platform
required: true
type: string
runs-on:
description: GitHub Actions Runner image
required: true
type: string
jobs:
build-test-upload:
runs-on: ${{ inputs.runs-on }}
steps:
# Image with CUDA needs extra disk space
- name: Free disk space 🧹
if: contains(inputs.variant, 'cuda') && inputs.platform == 'x86_64'
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
- name: Create dev environment 📦
uses: ./.github/actions/create-dev-env
# Self-hosted runners share a state (whole VM) between runs
# Also, they might have running or stopped containers,
# which are not cleaned up by `docker system prune`
- name: Reset docker state and cleanup artifacts 🗑️
if: inputs.platform != 'x86_64'
run: |
docker kill $(docker ps --quiet) || true
docker rm $(docker ps --all --quiet) || true
docker system prune --all --force
rm -rf /tmp/jupyter/
shell: bash
- name: Load parent built image to Docker 📥
if: inputs.parent-image != ''
uses: ./.github/actions/load-image
with:
image: ${{ inputs.parent-image }}
platform: ${{ inputs.platform }}
variant: ${{ inputs.parent-variant }}
- name: Pull base ubuntu image 📥
if: inputs.parent-image == ''
run: docker pull ubuntu:24.04
shell: bash
- name: Build image 🛠
run: docker build --rm --force-rm --tag ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ inputs.image }} images/${{ inputs.image }}/${{ inputs.variant != 'default' && inputs.variant || '.' }}/ --build-arg REGISTRY=${{ env.REGISTRY }} --build-arg OWNER=${{ env.OWNER }}
env:
DOCKER_BUILDKIT: 1
# Full logs for CI build
BUILDKIT_PROGRESS: plain
shell: bash
- name: Run tests ✅
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }} --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
shell: bash
- name: Write tags file 🏷
run: |
python3 -m tagging.write_tags_file --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }} --variant ${{ inputs.variant }}
shell: bash
- name: Upload tags file 💾
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}-tags
path: /tmp/jupyter/tags/${{ inputs.platform }}-${{ inputs.variant }}-${{ inputs.image }}.txt
retention-days: 3
- name: Write manifest and build history file 🏷
run: python3 -m tagging.write_manifest --short-image-name ${{ inputs.image }} --hist-lines-dir /tmp/jupyter/hist_lines/ --manifests-dir /tmp/jupyter/manifests/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }} --variant ${{ inputs.variant }}
shell: bash
- name: Upload manifest file 💾
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}-manifest
path: /tmp/jupyter/manifests/${{ inputs.platform }}-${{ inputs.variant }}-${{ inputs.image }}-*.md
retention-days: 3
- name: Upload build history line 💾
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}-history_line
path: /tmp/jupyter/hist_lines/${{ inputs.platform }}-${{ inputs.variant }}-${{ inputs.image }}-*.txt
retention-days: 3
- name: Save image as a tar for later use 💾
run: |
mkdir -p /tmp/jupyter/images/
docker save ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ inputs.image }} | zstd > /tmp/jupyter/images/${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}.tar.zst
shell: bash
- name: Upload image as artifact 💾
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}
path: /tmp/jupyter/images/${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}.tar.zst
retention-days: 3