forked from moby/buildkit
-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (192 loc) · 6.04 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# reusable workflow
name: .test
on:
workflow_call:
inputs:
cache_scope:
required: true
type: string
pkgs:
required: true
type: string
kinds:
required: true
type: string
tags:
required: false
type: string
codecov_flags:
required: false
type: string
includes:
required: false
type: string
env:
required: false
type: string
env:
GO_VERSION: "1.21"
SETUP_BUILDX_VERSION: "latest"
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest"
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
pkgs: ${{ steps.set.outputs.pkgs }}
kinds: ${{ steps.set.outputs.kinds }}
tags: ${{ steps.set.outputs.tags }}
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Deps
run: |
npm install js-yaml
-
name: Set outputs
id: set
uses: actions/github-script@v6
with:
script: |
const yaml = require('js-yaml');
await core.group(`Set pkgs matrix`, async () => {
const pkgs = `${{ inputs.pkgs }}`.trim().split(/\r?\n/);
core.info(JSON.stringify(pkgs, null, 2));
core.setOutput('pkgs', JSON.stringify(pkgs));
});
await core.group(`Set kinds matrix`, async () => {
const kinds = `${{ inputs.kinds }}`.trim().split(/\r?\n/);
core.info(JSON.stringify(kinds, null, 2));
core.setOutput('kinds', JSON.stringify(kinds));
});
await core.group(`Set tags matrix`, async () => {
const tags = `${{ inputs.tags }}`.trim().split(/\r?\n/);
core.info(JSON.stringify(tags, null, 2));
core.setOutput('tags', JSON.stringify(tags));
});
await core.group(`Set includes`, async () => {
const includes = yaml.load(`${{ inputs.includes }}`.trim());
core.info(JSON.stringify(includes, null, 2));
core.setOutput('includes', JSON.stringify(includes ?? []));
});
-
name: Build
uses: docker/bake-action@v4
with:
targets: integration-tests-base
set: |
*.cache-from=type=gha,scope=${{ inputs.cache_scope }}
*.cache-to=type=gha,scope=${{ inputs.cache_scope }}
run:
runs-on: ubuntu-22.04
needs:
- prepare
env:
TESTFLAGS: "-v --parallel=6 --timeout=30m"
GOTESTSUM_FORMAT: "standard-verbose"
TEST_IMAGE_BUILD: "0"
TEST_IMAGE_ID: "buildkit-tests"
strategy:
fail-fast: false
matrix:
worker:
- containerd
- containerd-rootless
- containerd-1.6
- containerd-snapshotter-stargz
- oci
- oci-rootless
- oci-snapshotter-stargz
pkg: ${{ fromJson(needs.prepare.outputs.pkgs) }}
kind: ${{ fromJson(needs.prepare.outputs.kinds) }}
tags: ${{ fromJson(needs.prepare.outputs.tags) }}
include: ${{ fromJson(needs.prepare.outputs.includes) }}
steps:
-
name: Environment variables
run: |
for l in "${{ inputs.env }}"; do
echo "${l?}" >> $GITHUB_ENV
done
-
name: Checkout
uses: actions/checkout@v4
-
name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build test image
uses: docker/bake-action@v4
with:
targets: integration-tests
set: |
*.cache-from=type=gha,scope=${{ inputs.cache_scope }}
*.output=type=docker,name=${{ env.TEST_IMAGE_ID }}
env:
BUILDKITD_TAGS: ${{ matrix.tags }}
-
name: Test
continue-on-error: ${{ matrix.tags == 'nydus' }}
run: |
export TEST_REPORT_SUFFIX=-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.kind }}-${{ matrix.worker }}-${{ matrix.tags }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')
if [ -n "${{ matrix.tags }}" ]; then
TESTFLAGS="${TESTFLAGS} --tags=${{ matrix.tags }}"
fi
if [ -n "${{ matrix.worker }}" ]; then
export TESTFLAGS="${TESTFLAGS} --run=//worker=${{ matrix.worker }}$"
fi
./hack/test ${{ matrix.kind }}
env:
TEST_COVERAGE: 1
TESTPKGS: ${{ matrix.pkg }}
SKIP_INTEGRATION_TESTS: ${{ matrix.skip-integration-tests }}
CACHE_FROM: type=gha,scope=${{ inputs.cache_scope }}
-
name: Send to Codecov
if: always()
uses: codecov/codecov-action@v3
with:
directory: ./bin/testreports
flags: ${{ matrix.codecov_flags }}
-
name: Generate annotations
if: always()
uses: crazy-max/.github/.github/actions/gotest-annotations@5af0882e0496d2f7e98a53ae4048e3d86682496f
with:
directory: ./bin/testreports
-
name: Upload test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: ./bin/testreports
-
name: Dump context
if: failure()
uses: crazy-max/ghaction-dump-context@v2