Skip to content

Commit 9e42346

Browse files
committed
ci: split docker install integration tests
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 51fe518 commit 9e42346

File tree

2 files changed

+79
-29
lines changed

2 files changed

+79
-29
lines changed

.github/workflows/test.yml

+41-15
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
prepare-itg:
6161
runs-on: ubuntu-latest
6262
outputs:
63-
matrix: ${{ steps.tests.outputs.matrix }}
63+
includes: ${{ steps.set.outputs.includes }}
6464
steps:
6565
-
6666
name: Checkout
@@ -80,14 +80,43 @@ jobs:
8080
name: Install
8181
run: yarn install
8282
-
83-
name: Create matrix
84-
id: tests
85-
run: |
86-
declare -a tests
87-
for test in $(yarn run test:itg-list); do
88-
tests+=("${test#$(pwd)/__tests__/}")
89-
done
90-
echo "matrix=$(echo ${tests[@]} | jq -cR 'split(" ")')" >>${GITHUB_OUTPUT}
83+
name: Create includes
84+
id: set
85+
uses: actions/github-script@v7
86+
with:
87+
script: |
88+
let tests = [];
89+
await core.group(`Get tests`, async () => {
90+
const res = await exec.getExecOutput('yarn', ['run', 'test:itg-list'], {
91+
silent: true,
92+
ignoreReturnCode: true
93+
});
94+
if (res.stderr.length > 0 && res.exitCode != 0) {
95+
throw new Error(res.stderr);
96+
}
97+
for (const test of res.stdout.trim().split('\n')) {
98+
tests.push(test.replace(/^.*__tests__\//, ''));
99+
}
100+
core.info(`tests: ${JSON.stringify(tests)}`);
101+
});
102+
await core.group(`Set includes`, async () => {
103+
let includes = [];
104+
for (const os of ['ubuntu-latest', 'macos-13', 'windows-latest']) {
105+
for (const test of tests) {
106+
if (os === 'macos-13' && test === 'docker/install.test.itg.ts') {
107+
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: '27.3.1' });
108+
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'master' });
109+
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'latest' });
110+
includes.push({ os: os, test: test, docker_install_type: 'archive', docker_install_version: 'v26.1.4' });
111+
includes.push({ os: os, test: test, docker_install_type: 'archive', docker_install_version: 'latest' });
112+
} else {
113+
includes.push({ os: os, test: test });
114+
}
115+
}
116+
}
117+
core.info(`includes: ${JSON.stringify(includes)}`);
118+
core.setOutput('includes', JSON.stringify(includes));
119+
});
91120
-
92121
name: Show matrix
93122
run: |
@@ -100,12 +129,7 @@ jobs:
100129
strategy:
101130
fail-fast: false
102131
matrix:
103-
test: ${{ fromJson(needs.prepare-itg.outputs.matrix) }}
104-
os:
105-
- ubuntu-latest
106-
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
107-
- macos-13
108-
- windows-latest
132+
include: ${{ fromJson(needs.prepare-itg.outputs.includes) }}
109133
steps:
110134
-
111135
name: Checkout
@@ -158,6 +182,8 @@ jobs:
158182
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159183
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
160184
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }}
185+
DOCKER_INSTALL_TYPE: ${{ matrix.docker_install_type }}
186+
DOCKER_INSTALL_VERSION: ${{ matrix.docker_install_version }}
161187
-
162188
name: Check coverage
163189
run: |

__tests__/docker/install.test.itg.ts

+38-14
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@ import fs from 'fs';
1919
import os from 'os';
2020
import path from 'path';
2121

22-
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
22+
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
2323
import {Docker} from '../../src/docker/docker';
2424
import {Exec} from '../../src/exec';
2525

2626
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
2727

28-
describe('install', () => {
28+
describe('root', () => {
2929
// prettier-ignore
30-
test.each([
31-
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
32-
{type: 'image', tag: 'master'} as InstallSourceImage,
33-
{type: 'image', tag: 'latest'} as InstallSourceImage,
34-
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
35-
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive,
36-
])(
30+
test.each(getSources(true))(
3731
'install docker %s', async (source) => {
3832
await ensureNoSystemContainerd();
3933
const install = new Install({
@@ -48,16 +42,12 @@ describe('install', () => {
4842

4943
describe('rootless', () => {
5044
// prettier-ignore
51-
test.each([
52-
{type: 'image', tag: 'latest'} as InstallSourceImage,
53-
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive,
54-
])(
45+
test.each(getSources(false))(
5546
'install %s', async (source) => {
5647
// Skip on non linux
5748
if (os.platform() !== 'linux') {
5849
return;
5950
}
60-
6151
await ensureNoSystemContainerd();
6252
const install = new Install({
6353
source: source,
@@ -109,3 +99,37 @@ async function ensureNoSystemContainerd() {
10999
});
110100
}
111101
}
102+
103+
function getSources(root: boolean): Array<InstallSource> {
104+
const dockerInstallType = process.env.DOCKER_INSTALL_TYPE;
105+
const dockerInstallVersion = process.env.DOCKER_INSTALL_VERSION;
106+
if (dockerInstallType && dockerInstallVersion) {
107+
if (dockerInstallType === 'archive') {
108+
// prettier-ignore
109+
return [
110+
{ type: dockerInstallType, version: dockerInstallVersion, channel: 'stable'} as InstallSourceArchive
111+
];
112+
} else {
113+
// prettier-ignore
114+
return [
115+
{ type: dockerInstallType, tag: dockerInstallVersion} as InstallSourceImage
116+
];
117+
}
118+
}
119+
if (root) {
120+
// prettier-ignore
121+
return [
122+
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
123+
{type: 'image', tag: 'master'} as InstallSourceImage,
124+
{type: 'image', tag: 'latest'} as InstallSourceImage,
125+
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
126+
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive
127+
];
128+
} else {
129+
// prettier-ignore
130+
return [
131+
{type: 'image', tag: 'latest'} as InstallSourceImage,
132+
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive
133+
];
134+
}
135+
}

0 commit comments

Comments
 (0)