Skip to content

Commit 90edc05

Browse files
authored
Merge pull request moby#3237 from crazy-max/ci-split-build-worklfow
ci: move frontend integration tests and build to a dedicated workflow
2 parents 46e4e7e + 97d3b59 commit 90edc05

File tree

9 files changed

+633
-477
lines changed

9 files changed

+633
-477
lines changed

.github/workflows/.test.yml

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# reusable workflow
2+
name: .test
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
cache_scope:
8+
required: true
9+
type: string
10+
pkgs:
11+
required: true
12+
type: string
13+
kinds:
14+
required: true
15+
type: string
16+
tags:
17+
required: false
18+
type: string
19+
codecov_flags:
20+
required: false
21+
type: string
22+
includes:
23+
required: false
24+
type: string
25+
env:
26+
required: false
27+
type: string
28+
29+
env:
30+
GO_VERSION: "1.19"
31+
SETUP_BUILDX_VERSION: "latest"
32+
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest"
33+
TESTFLAGS: "-v --parallel=6 --timeout=30m"
34+
35+
jobs:
36+
prepare:
37+
runs-on: ubuntu-20.04
38+
outputs:
39+
pkgs: ${{ steps.set.outputs.pkgs }}
40+
kinds: ${{ steps.set.outputs.kinds }}
41+
tags: ${{ steps.set.outputs.tags }}
42+
includes: ${{ steps.set.outputs.includes }}
43+
steps:
44+
-
45+
name: Checkout
46+
uses: actions/checkout@v3
47+
-
48+
name: Expose GitHub Runtime
49+
uses: crazy-max/ghaction-github-runtime@v2
50+
-
51+
name: Set up QEMU
52+
uses: docker/setup-qemu-action@v2
53+
-
54+
name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v2
56+
with:
57+
version: ${{ env.SETUP_BUILDX_VERSION }}
58+
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
59+
buildkitd-flags: --debug
60+
-
61+
name: Deps
62+
run: |
63+
npm install js-yaml
64+
-
65+
name: Set outputs
66+
id: set
67+
uses: actions/github-script@v6
68+
with:
69+
script: |
70+
const yaml = require('js-yaml');
71+
await core.group(`Set pkgs matrix`, async () => {
72+
const pkgs = `${{ inputs.pkgs }}`.trim().split(/\r?\n/);
73+
core.info(JSON.stringify(pkgs, null, 2));
74+
core.setOutput('pkgs', JSON.stringify(pkgs));
75+
});
76+
await core.group(`Set kinds matrix`, async () => {
77+
const kinds = `${{ inputs.kinds }}`.trim().split(/\r?\n/);
78+
core.info(JSON.stringify(kinds, null, 2));
79+
core.setOutput('kinds', JSON.stringify(kinds));
80+
});
81+
await core.group(`Set tags matrix`, async () => {
82+
const tags = `${{ inputs.tags }}`.trim().split(/\r?\n/);
83+
core.info(JSON.stringify(tags, null, 2));
84+
core.setOutput('tags', JSON.stringify(tags));
85+
});
86+
await core.group(`Set includes`, async () => {
87+
const includes = yaml.load(`${{ inputs.includes }}`.trim());
88+
core.info(JSON.stringify(includes, null, 2));
89+
core.setOutput('includes', JSON.stringify(includes ?? []));
90+
});
91+
-
92+
name: Build
93+
run: |
94+
./hack/build_ci_first_pass integration-tests
95+
env:
96+
CACHE_FROM: type=gha,scope=${{ inputs.cache_scope }}
97+
CACHE_TO: type=gha,scope=${{ inputs.cache_scope }}
98+
99+
run:
100+
runs-on: ubuntu-20.04
101+
needs:
102+
- prepare
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
pkg: ${{ fromJson(needs.prepare.outputs.pkgs) }}
107+
kind: ${{ fromJson(needs.prepare.outputs.kinds) }}
108+
tags: ${{ fromJson(needs.prepare.outputs.tags) }}
109+
include: ${{ fromJson(needs.prepare.outputs.includes) }}
110+
worker:
111+
- containerd
112+
- containerd-rootless
113+
- containerd-1.6
114+
- containerd-snapshotter-stargz
115+
- oci
116+
- oci-rootless
117+
- oci-snapshotter-stargz
118+
steps:
119+
-
120+
name: Environment variables
121+
run: |
122+
for l in "${{ inputs.env }}"; do
123+
echo "${l?}" >> $GITHUB_ENV
124+
done
125+
-
126+
name: Checkout
127+
uses: actions/checkout@v3
128+
-
129+
name: Expose GitHub Runtime
130+
uses: crazy-max/ghaction-github-runtime@v2
131+
-
132+
name: Set up QEMU
133+
uses: docker/setup-qemu-action@v2
134+
-
135+
name: Set up Docker Buildx
136+
uses: docker/setup-buildx-action@v2
137+
with:
138+
version: ${{ env.SETUP_BUILDX_VERSION }}
139+
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
140+
buildkitd-flags: --debug
141+
-
142+
name: Test
143+
continue-on-error: ${{ matrix.tags == 'nydus' }}
144+
run: |
145+
if [ -n "${{ matrix.tags }}" ]; then
146+
TESTFLAGS="${TESTFLAGS} --tags=${{ matrix.tags }}"
147+
export BUILDKITD_TAGS="${{ matrix.tags }}"
148+
fi
149+
if [ -n "${{ matrix.worker }}" ]; then
150+
export TESTFLAGS="${TESTFLAGS} --run=//worker=${{ matrix.worker }}$"
151+
fi
152+
./hack/test ${{ matrix.kind }}
153+
mv ./coverage/coverage.txt ./coverage/coverage-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.kind }}-${{ matrix.worker }}-${{ matrix.tags }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]').txt
154+
env:
155+
TEST_COVERAGE: 1
156+
TESTPKGS: ${{ matrix.pkg }}
157+
SKIP_INTEGRATION_TESTS: ${{ matrix.skip-integration-tests }}
158+
CACHE_FROM: type=gha,scope=${{ inputs.cache_scope }}
159+
-
160+
name: Upload coverage file
161+
continue-on-error: ${{ matrix.tags == 'nydus' }}
162+
uses: actions/upload-artifact@v3
163+
with:
164+
name: coverage
165+
path: ./coverage
166+
167+
upload-coverage:
168+
runs-on: ubuntu-20.04
169+
needs:
170+
- run
171+
steps:
172+
-
173+
name: Checkout
174+
uses: actions/checkout@v3
175+
-
176+
name: Download coverage files
177+
uses: actions/download-artifact@v3
178+
with:
179+
name: coverage
180+
path: ./coverage
181+
-
182+
name: List coverage files
183+
id: files
184+
uses: actions/github-script@v6
185+
with:
186+
result-encoding: string
187+
script: |
188+
return require('fs').readdirSync('./coverage', {withFileTypes: true})
189+
.filter(item => !item.isDirectory())
190+
.map(item => `./coverage/${item.name}`)
191+
.join(',');
192+
-
193+
name: Send to Codecov
194+
uses: codecov/codecov-action@v3
195+
with:
196+
files: ${{ steps.files.outputs.result }}
197+
flags: ${{ matrix.codecov_flags }}

0 commit comments

Comments
 (0)