-
Notifications
You must be signed in to change notification settings - Fork 41
236 lines (229 loc) · 8.65 KB
/
test.yml
File metadata and controls
236 lines (229 loc) · 8.65 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:
paths-ignore:
- '.github/*-releases.json'
env:
NODE_VERSION: "24"
BUILDX_VERSION: "v0.33.0"
BUILDKIT_IMAGE: "moby/buildkit:v0.29.0"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
node_version:
- 24
- 20
steps:
-
name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
name: Test
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
with:
source: .
targets: test-coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_VERSION: ${{ matrix.node_version }}
DOCKER_BUILD_SUMMARY: false
-
name: Check coverage
run: |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
echo "RUN_CODECOV=true" >> $GITHUB_ENV
else
echo "RUN_CODECOV=false" >> $GITHUB_ENV
fi
shell: bash
-
name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
if: env.RUN_CODECOV == 'true' && matrix.node_version == env.NODE_VERSION
with:
files: ./coverage/clover.xml
flags: unit
token: ${{ secrets.CODECOV_TOKEN }}
prepare-itg:
runs-on: ubuntu-latest
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
name: Enable corepack
run: |
corepack enable
yarn --version
-
name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
-
name: Install
run: yarn install
-
name: Create includes
id: set
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
let tests = [];
await core.group(`Get tests`, async () => {
const res = await exec.getExecOutput('yarn', ['run', 'test:itg-list'], {
silent: true,
ignoreReturnCode: true
});
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr);
}
for (const test of res.stdout.trim().split('\n')) {
tests.push(test.replace(/^.*__tests__\//, ''));
}
core.info(`tests: ${JSON.stringify(tests)}`);
});
await core.group(`Set includes`, async () => {
let includes = [];
for (const os of ['ubuntu-latest', 'ubuntu-24.04-arm', 'macos-26-large', 'windows-latest']) {
for (const test of tests) {
if (test === 'docker/install.test.itg.ts') {
if (os !== 'windows-latest') {
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: '27.3.1' });
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'master' });
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'image', docker_install_version: 'latest' });
}
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v26.1.4' });
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'latest' });
includes.push({ os: os, test: test, test_name: 'root', docker_install_type: 'archive', docker_install_version: 'v29.0.0-rc.1', docker_install_channel: 'test' });
if (os === 'ubuntu-latest') {
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'image', docker_install_version: 'latest' });
includes.push({ os: os, test: test, test_name: 'rootless', docker_install_type: 'archive', docker_install_version: 'latest' });
}
if (os !== 'windows-latest') {
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'image', docker_install_version: 'latest' });
}
includes.push({ os: os, test: test, test_name: 'tcp', docker_install_type: 'archive', docker_install_version: 'latest' });
} else {
includes.push({ os: os, test: test });
}
}
}
core.info(`includes: ${JSON.stringify(includes)}`);
core.setOutput('includes', JSON.stringify(includes));
});
-
name: Show matrix
run: |
echo ${{ steps.tests.outputs.matrix }}
test-itg:
runs-on: ${{ matrix.os }}
needs:
- prepare-itg
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare-itg.outputs.includes) }}
permissions:
contents: read
id-token: write # needed for signing with GitHub OIDC Token
packages: write # needed for pushing to GitHub Container Registry
steps:
-
name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@04d248b84655b509d8c44dc1d6f990c879747487 # v4.0.0
-
# FIXME: Needs to setup node twice on Windows: https://github.com/actions/setup-node/issues/1357#issuecomment-3254613964
name: Setup Node
if: startsWith(matrix.os, 'windows')
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.NODE_VERSION }}
package-manager-cache: false
-
name: Enable corepack
run: |
corepack enable
yarn --version
-
name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
-
name: Set up Docker Buildx
if: startsWith(matrix.os, 'ubuntu')
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
version: ${{ env.BUILDX_VERSION }}
driver: docker
-
name: Set up container builder
if: startsWith(matrix.os, 'ubuntu')
id: builder
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
version: ${{ env.BUILDX_VERSION }}
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
use: false
-
name: Install
run: yarn install
-
name: Test
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const testName = `${{ matrix.test_name }}`;
let args = ['test:itg-coverage'];
if (testName) {
args.push(`--testNamePattern=^${testName} `);
}
args.push(`__tests__/${{ matrix.test }}`, `--coverage.reportsDirectory=./coverage`);
await exec.exec('yarn', args);
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }}
DOCKER_INSTALL_TYPE: ${{ matrix.docker_install_type }}
DOCKER_INSTALL_VERSION: ${{ matrix.docker_install_version }}
DOCKER_INSTALL_CHANNEL: ${{ matrix.docker_install_channel }}
-
name: Check coverage
run: |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
echo "RUN_CODECOV=true" >> $GITHUB_ENV
else
echo "RUN_CODECOV=false" >> $GITHUB_ENV
fi
shell: bash
-
name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
if: env.RUN_CODECOV == 'true'
with:
files: ./coverage/clover.xml
flags: itg
token: ${{ secrets.CODECOV_TOKEN }}