-
Notifications
You must be signed in to change notification settings - Fork 36
95 lines (89 loc) · 2.59 KB
/
.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
# reusable workflow
name: .test
on:
workflow_call:
inputs:
image:
required: true
type: string
base:
required: true
type: string
allow-failure:
required: false
type: boolean
default: false
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.generate.outputs.targets }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: List targets
id: generate
uses: actions/github-script@v7
with:
script: |
const base = `${{ inputs.base }}`;
await core.group(`Validating definition`, async () => {
const res = await exec.getExecOutput('docker', ['buildx', 'bake', 'test', '--print'], {
ignoreReturnCode: true,
silent: true
});
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr);
}
def = JSON.parse(res.stdout.trim());
core.info(JSON.stringify(def, null, 2));
});
const targets = [];
for (const target of Object.keys(def.target)) {
switch (base) {
case 'alpine':
if (target !== 'test-apt') {
targets.push(target);
}
break;
case 'debian':
if (target !== 'test-apk') {
targets.push(target);
}
break;
case 'rhel':
if (target === 'test-info') {
targets.push(target);
}
break;
default:
targets.push(target);
}
}
await core.group(`Set output`, async () => {
core.info(`targets: ${JSON.stringify(targets)}`);
core.setOutput('targets', JSON.stringify(targets));
});
test:
runs-on: ubuntu-latest
continue-on-error: ${{ inputs.allow-failure }}
needs:
- prepare
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps:
-
name: Test
uses: docker/bake-action@v6
with:
provenance: false
targets: ${{ matrix.target }}
set: |
test-${{ inputs.base }}.args.TEST_BASE_IMAGE=${{ inputs.image }}
env:
TEST_BASE_TYPE: ${{ inputs.base }}
DOCKER_BUILD_SUMMARY: false