mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
Merge pull request #496 from crazy-max/ci-split-docker-install-tests
ci: split docker install integration tests
This commit is contained in:
commit
8e475672d0
56
.github/workflows/test.yml
vendored
56
.github/workflows/test.yml
vendored
@ -60,7 +60,7 @@ jobs:
|
|||||||
prepare-itg:
|
prepare-itg:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.tests.outputs.matrix }}
|
includes: ${{ steps.set.outputs.includes }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -80,14 +80,43 @@ jobs:
|
|||||||
name: Install
|
name: Install
|
||||||
run: yarn install
|
run: yarn install
|
||||||
-
|
-
|
||||||
name: Create matrix
|
name: Create includes
|
||||||
id: tests
|
id: set
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
declare -a tests
|
with:
|
||||||
for test in $(yarn run test:itg-list); do
|
script: |
|
||||||
tests+=("${test#$(pwd)/__tests__/}")
|
let tests = [];
|
||||||
done
|
await core.group(`Get tests`, async () => {
|
||||||
echo "matrix=$(echo ${tests[@]} | jq -cR 'split(" ")')" >>${GITHUB_OUTPUT}
|
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', 'macos-13', 'windows-latest']) {
|
||||||
|
for (const test of tests) {
|
||||||
|
if (os === 'macos-13' && test === 'docker/install.test.itg.ts') {
|
||||||
|
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: '27.3.1' });
|
||||||
|
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'master' });
|
||||||
|
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'latest' });
|
||||||
|
includes.push({ os: os, test: test, docker_install_type: 'archive', docker_install_version: 'v26.1.4' });
|
||||||
|
includes.push({ os: os, test: test, 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
|
name: Show matrix
|
||||||
run: |
|
run: |
|
||||||
@ -100,12 +129,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
test: ${{ fromJson(needs.prepare-itg.outputs.matrix) }}
|
include: ${{ fromJson(needs.prepare-itg.outputs.includes) }}
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
|
||||||
- macos-13
|
|
||||||
- windows-latest
|
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -158,6 +182,8 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
|
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
|
||||||
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }}
|
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }}
|
||||||
|
DOCKER_INSTALL_TYPE: ${{ matrix.docker_install_type }}
|
||||||
|
DOCKER_INSTALL_VERSION: ${{ matrix.docker_install_version }}
|
||||||
-
|
-
|
||||||
name: Check coverage
|
name: Check coverage
|
||||||
run: |
|
run: |
|
||||||
|
@ -19,21 +19,15 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||||
import {Docker} from '../../src/docker/docker';
|
import {Docker} from '../../src/docker/docker';
|
||||||
import {Exec} from '../../src/exec';
|
import {Exec} from '../../src/exec';
|
||||||
|
|
||||||
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
|
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
|
||||||
|
|
||||||
describe('install', () => {
|
describe('root', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each(getSources(true))(
|
||||||
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
|
|
||||||
{type: 'image', tag: 'master'} as InstallSourceImage,
|
|
||||||
{type: 'image', tag: 'latest'} as InstallSourceImage,
|
|
||||||
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
|
|
||||||
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive,
|
|
||||||
])(
|
|
||||||
'install docker %s', async (source) => {
|
'install docker %s', async (source) => {
|
||||||
await ensureNoSystemContainerd();
|
await ensureNoSystemContainerd();
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
@ -48,16 +42,12 @@ describe('install', () => {
|
|||||||
|
|
||||||
describe('rootless', () => {
|
describe('rootless', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each(getSources(false))(
|
||||||
{type: 'image', tag: 'latest'} as InstallSourceImage,
|
|
||||||
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive,
|
|
||||||
])(
|
|
||||||
'install %s', async (source) => {
|
'install %s', async (source) => {
|
||||||
// Skip on non linux
|
// Skip on non linux
|
||||||
if (os.platform() !== 'linux') {
|
if (os.platform() !== 'linux') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ensureNoSystemContainerd();
|
await ensureNoSystemContainerd();
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: source,
|
source: source,
|
||||||
@ -109,3 +99,37 @@ async function ensureNoSystemContainerd() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSources(root: boolean): Array<InstallSource> {
|
||||||
|
const dockerInstallType = process.env.DOCKER_INSTALL_TYPE;
|
||||||
|
const dockerInstallVersion = process.env.DOCKER_INSTALL_VERSION;
|
||||||
|
if (dockerInstallType && dockerInstallVersion) {
|
||||||
|
if (dockerInstallType === 'archive') {
|
||||||
|
// prettier-ignore
|
||||||
|
return [
|
||||||
|
{ type: dockerInstallType, version: dockerInstallVersion, channel: 'stable'} as InstallSourceArchive
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
// prettier-ignore
|
||||||
|
return [
|
||||||
|
{ type: dockerInstallType, tag: dockerInstallVersion} as InstallSourceImage
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (root) {
|
||||||
|
// prettier-ignore
|
||||||
|
return [
|
||||||
|
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
|
||||||
|
{type: 'image', tag: 'master'} as InstallSourceImage,
|
||||||
|
{type: 'image', tag: 'latest'} as InstallSourceImage,
|
||||||
|
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
|
||||||
|
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
// prettier-ignore
|
||||||
|
return [
|
||||||
|
{type: 'image', tag: 'latest'} as InstallSourceImage,
|
||||||
|
{type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user