-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (85 loc) · 3.24 KB
/
docker-multistage-test.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
---
name: "Test multistage docker images (multi -flavours, -versions, -architectures)"
on:
workflow_call:
###
### Variables
###
inputs:
matrix:
description: 'The build matrix'
required: true
type: string
stage:
description: 'The stage to build (Examples: base, mods, prod or work).'
required: true
type: string
artifact_prefix:
description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).'
required: true
type: string
has_refs:
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).'
required: true
type: boolean
jobs:
# -----------------------------------------------------------------------------------------------
# JOB: BUILD
# -----------------------------------------------------------------------------------------------
test:
name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }} (${{ matrix.ARCH }}) ${{ matrix.REFS }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(inputs.matrix) }}
steps:
# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: "[SETUP] Checkout repository (current)"
uses: actions/checkout@v3
with:
fetch-depth: 0
if: ${{ !inputs.has_refs }}
- name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})"
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ matrix.REFS }}
if: ${{ inputs.has_refs }}
- name: "[SETUP] Setup QEMU environment"
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: "[SETUP] Set artifact names"
id: set-artifact-name
run: |
VERSION="${{ matrix.VERSION }}"
ARCH="$( echo "${{ matrix.ARCH }}" | sed 's|/|-|g' )"
NAME_CURR="${{ inputs.artifact_prefix }}-${VERSION}-${ARCH}-${{ inputs.stage }}"
echo "curr=${NAME_CURR}" >> $GITHUB_OUTPUT
# ------------------------------------------------------------
# Artifact Import
# ------------------------------------------------------------
###
### Download and import previously built image
###
- name: "[Artifact Load] Download previously built image"
uses: cytopia/download-artifact-retry-action@v0.1.5
with:
name: ${{ steps.set-artifact-name.outputs.curr }}
- name: "[Artifact Load] Import previously built image"
uses: cytopia/shell-command-retry-action@v0.1.6
with:
command: |
make load INFILE=${{ steps.set-artifact-name.outputs.curr }}
# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: Test
uses: cytopia/shell-command-retry-action@v0.1.6
with:
command: |
make test VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }}