-
Notifications
You must be signed in to change notification settings - Fork 14
78 lines (69 loc) · 2.79 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
---
name: Build a new image and then upload the image, tags and manifests to GitHub artifacts
env:
OWNER: ${{ github.repository_owner }}
FORCE_COLOR: 1
on:
workflow_call:
inputs:
image:
description: Image name
required: true
type: string
architecture:
description: Image architecture, e.g. amd64, arm64
required: true
type: string
runsOn:
description: GitHub Actions Runner image
required: true
type: string
jobs:
build-test-upload:
runs-on: ${{ inputs.runsOn }}
continue-on-error: true
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
- name: Create dev environment 📦
uses: ./.github/actions/create-dev-env
with:
architecture: ${{ inputs.architecture }}
# 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: ${{ startsWith(inputs.runsOn, 'ubuntu') }}
run: |
docker kill $(docker ps --quiet) || true
docker rm $(docker ps --all --quiet) || true
docker system prune --all --force
rm -rf /tmp/aiidalab/
shell: bash
- name: Build image 🛠
working-directory: docker
run: docker buildx bake --set qe.platform=linux/${{ inputs.architecture }} -f docker-bake.hcl -f build.json --load
env:
# Use buildx
DOCKER_BUILDKIT: 1
# Full logs for CI build
BUILDKIT_PROGRESS: plain
shell: bash
- name: Run tests ✅
uses: ./.github/actions/integration-tests
with:
architecture: ${{ inputs.architecture }}
runsOn: ${{ inputs.runsOn }}
- name: Save image as a tar for later use 💾
run: |
mkdir -p /tmp/aiidalab/
docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar
shell: bash
if: always()
- name: Upload image as artifact 💾
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.architecture }}
path: /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar
retention-days: 3
if: always()