forked from jupyter/docker-stacks
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (99 loc) · 3.96 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
name: Download parent image, build a new one and test it; then upload the image, tags and manifests to GitHub artifacts
env:
OWNER: ${{ github.repository_owner }}
on:
workflow_call:
inputs:
parentImage:
description: Parent image name
required: true
type: string
image:
description: Image name
required: true
type: string
platform:
description: Image platform
required: true
type: string
runsOn:
description: GitHub Actions Runner image
required: true
type: string
jobs:
build-test-upload:
runs-on: ${{ inputs.runsOn }}
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v3
- name: Create dev environment 📦
uses: ./.github/actions/create-dev-env
with:
platform: ${{ inputs.platform }}
# 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 prun`
- 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.parentImage != '' }}
uses: ./.github/actions/load-image
with:
image: ${{ inputs.parentImage }}
platform: ${{ inputs.platform }}
- name: Pull ubuntu:22.04 image 📥
if: ${{ inputs.parentImage == '' }}
run: docker pull ubuntu:22.04
shell: bash
- name: Build image 🛠
run: docker build --rm --force-rm --tag ${{ env.OWNER }}/${{ inputs.image }} ${{ inputs.image }}/
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 }} --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/ --owner ${{ env.OWNER }}
shell: bash
- name: Upload tags file 💾
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-tags
path: /tmp/jupyter/tags/${{ inputs.platform }}-${{ 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-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --owner ${{ env.OWNER }}
shell: bash
- name: Upload manifest file 💾
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-manifest
path: /tmp/jupyter/manifests/${{ inputs.platform }}-${{ inputs.image }}-*.md
retention-days: 3
- name: Upload build history line 💾
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.image }}-${{ inputs.platform }}-history_line
path: /tmp/jupyter/hist_lines/${{ inputs.platform }}-${{ inputs.image }}-*.txt
retention-days: 3
- name: Save image as a tar for later use 💾
run: |
mkdir -p /tmp/jupyter/images/
docker save ${{ env.OWNER }}/${{ inputs.image }} | zstd > /tmp/jupyter/images/${{ inputs.image }}-${{ inputs.platform }}.tar.zst
shell: bash
- name: Upload image as artifact 💾
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.image }}-${{ inputs.platform }}
path: /tmp/jupyter/images/${{ inputs.image }}-${{ inputs.platform }}.tar.zst
retention-days: 3