mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
docker/install: Add tests for installing from image
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
de390e0872
commit
b143889d3e
@ -19,7 +19,7 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {Install} from '../../src/docker/install';
|
import {Install, 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';
|
||||||
|
|
||||||
@ -40,8 +40,11 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
|||||||
process.env = originalEnv;
|
process.env = originalEnv;
|
||||||
});
|
});
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each(['v26.1.4'])(
|
test.each([
|
||||||
'install docker %s', async (version) => {
|
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
|
||||||
|
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
|
||||||
|
])(
|
||||||
|
'install docker %s', async (source) => {
|
||||||
if (process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) {
|
if (process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) {
|
||||||
// Remove containerd first on ubuntu runners to make sure it takes
|
// Remove containerd first on ubuntu runners to make sure it takes
|
||||||
// ones packaged with docker
|
// ones packaged with docker
|
||||||
@ -55,11 +58,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
|||||||
}
|
}
|
||||||
await expect((async () => {
|
await expect((async () => {
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: {
|
source: source,
|
||||||
type: 'archive',
|
|
||||||
version: version,
|
|
||||||
channel: 'stable',
|
|
||||||
},
|
|
||||||
runDir: tmpDir,
|
runDir: tmpDir,
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
||||||
|
@ -21,7 +21,7 @@ import path from 'path';
|
|||||||
import * as rimraf from 'rimraf';
|
import * as rimraf from 'rimraf';
|
||||||
import osm = require('os');
|
import osm = require('os');
|
||||||
|
|
||||||
import {Install} from '../../src/docker/install';
|
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
|
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
|
||||||
|
|
||||||
@ -29,22 +29,39 @@ afterEach(function () {
|
|||||||
rimraf.sync(tmpDir);
|
rimraf.sync(tmpDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const archive = (version: string, channel: string): InstallSourceArchive => {
|
||||||
|
return {
|
||||||
|
type: 'archive',
|
||||||
|
version: version,
|
||||||
|
channel: channel
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const image = (tag: string): InstallSourceImage => {
|
||||||
|
return {
|
||||||
|
type: 'image',
|
||||||
|
tag: tag
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
describe('download', () => {
|
describe('download', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
['v19.03.14', 'linux'],
|
[archive('v19.03.14', 'stable'), 'linux'],
|
||||||
['v20.10.22', 'linux'],
|
[archive('v20.10.22', 'stable'), 'linux'],
|
||||||
['v20.10.22', 'darwin'],
|
[archive('v20.10.22', 'stable'), 'darwin'],
|
||||||
['v20.10.22', 'win32'],
|
[archive('v20.10.22', 'stable'), 'win32'],
|
||||||
|
|
||||||
|
[image('master'), 'linux'],
|
||||||
|
[image('master'), 'win32'],
|
||||||
|
|
||||||
|
[image('27.3.1'), 'linux'],
|
||||||
|
[image('27.3.1'), 'win32'],
|
||||||
])(
|
])(
|
||||||
'acquires %p of docker (%s)', async (version, platformOS) => {
|
'acquires %p of docker (%s)', async (source, platformOS) => {
|
||||||
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
|
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: {
|
source: source,
|
||||||
type: 'archive',
|
|
||||||
version: version,
|
|
||||||
channel: 'stable',
|
|
||||||
},
|
|
||||||
runDir: tmpDir,
|
runDir: tmpDir,
|
||||||
});
|
});
|
||||||
const toolPath = await install.download();
|
const toolPath = await install.download();
|
||||||
|
Loading…
Reference in New Issue
Block a user