Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions __tests__/buildx/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,39 +119,64 @@ describe('getDownloadVersion', () => {
expect(version.key).toEqual('official');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/buildx-releases.json'
});
});

it('returns official v0.10.1 download version', async () => {
const version = await Install.getDownloadVersion('v0.10.1');
expect(version.key).toEqual('official');
expect(version.version).toEqual('v0.10.1');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/buildx-releases.json'
});
});

it('returns cloud latest download version', async () => {
const version = await Install.getDownloadVersion('cloud:latest');
expect(version.key).toEqual('cloud');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/buildx-lab-releases.json'
});
});

it('returns cloud v0.11.2-desktop.2 download version', async () => {
const version = await Install.getDownloadVersion('cloud:v0.11.2-desktop.2');
expect(version.key).toEqual('cloud');
expect(version.version).toEqual('v0.11.2-desktop.2');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/buildx-lab-releases.json'
});
});

it('returns cloud for lab version', async () => {
const version = await Install.getDownloadVersion('lab:latest');
expect(version.key).toEqual('cloud');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/buildx-lab-releases.json'
});
});

it('unknown repo', async () => {
Expand Down Expand Up @@ -187,6 +212,6 @@ describe('getRelease', () => {

it('unknown release', async () => {
const version = await Install.getDownloadVersion('foo');
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'));
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Buildx release foo in releases JSON'));
});
});
30 changes: 25 additions & 5 deletions __tests__/compose/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,48 @@ describe('getDownloadVersion', () => {
expect(version.key).toEqual('official');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/compose-releases.json'
});
});
it('returns official v2.24.3 download version', async () => {
const version = await Install.getDownloadVersion('v2.24.3');
expect(version.key).toEqual('official');
expect(version.version).toEqual('v2.24.3');
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/compose-releases.json'
});
});
it('returns cloud latest download version', async () => {
const version = await Install.getDownloadVersion('cloud:latest');
expect(version.key).toEqual('cloud');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-lab-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/compose-lab-releases.json'
});
});
it('returns cloud v2.27.1-desktop.1 download version', async () => {
const version = await Install.getDownloadVersion('cloud:v2.27.1-desktop.1');
expect(version.key).toEqual('cloud');
expect(version.version).toEqual('v2.27.1-desktop.1');
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-lab-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/compose-lab-releases.json'
});
});
it('unknown repo', async () => {
await expect(Install.getDownloadVersion('foo:bar')).rejects.toThrow(new Error('Cannot find compose version for foo:bar'));
Expand Down Expand Up @@ -152,6 +172,6 @@ describe('getRelease', () => {
});
it('unknown release', async () => {
const version = await Install.getDownloadVersion('foo');
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Compose release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json'));
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Compose release foo in releases JSON'));
});
});
14 changes: 3 additions & 11 deletions __tests__/docker/install.test.itg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import path from 'path';

import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
import {Docker} from '../../src/docker/docker';
import {Regctl} from '../../src/regclient/regctl';
import {Install as RegclientInstall} from '../../src/regclient/install';
import {Undock} from '../../src/undock/undock';
import {Install as UndockInstall} from '../../src/undock/install';
import {Exec} from '../../src/exec';

Expand All @@ -48,9 +46,7 @@ describe('root', () => {
source: source,
runDir: tmpDir(),
contextName: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
regctl: new Regctl(),
undock: new Undock()
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
});
await expect(tryInstall(install)).resolves.not.toThrow();
}, 30 * 60 * 1000);
Expand All @@ -70,9 +66,7 @@ describe('rootless', () => {
runDir: tmpDir(),
contextName: 'foo',
daemonConfig: `{"debug":true}`,
rootless: true,
regctl: new Regctl(),
undock: new Undock()
rootless: true
});
await expect(
tryInstall(install, async () => {
Expand All @@ -97,9 +91,7 @@ describe('tcp', () => {
runDir: tmpDir(),
contextName: 'foo',
daemonConfig: `{"debug":true}`,
localTCPPort: 2378,
regctl: new Regctl(),
undock: new Undock()
localTCPPort: 2378
});
await expect(
tryInstall(install, async () => {
Expand Down
8 changes: 2 additions & 6 deletions __tests__/docker/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import * as rimraf from 'rimraf';
import osm = require('os');

import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
import {Regctl} from '../../src/regclient/regctl';
import {Undock} from '../../src/undock/undock';

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

Expand Down Expand Up @@ -66,9 +64,7 @@ describe('download', () => {
jest.spyOn(osm, 'arch').mockImplementation(() => 'x64');
const install = new Install({
source: source,
runDir: tmpDir,
regctl: new Regctl(),
undock: new Undock()
runDir: tmpDir
});
const toolPath = await install.download();
expect(fs.existsSync(toolPath)).toBe(true);
Expand Down Expand Up @@ -99,7 +95,7 @@ describe('getRelease', () => {
});

it('unknown release', async () => {
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Docker release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json'));
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Docker release foo in releases JSON'));
});
});

Expand Down
25 changes: 24 additions & 1 deletion __tests__/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
import {describe, expect, jest, it, beforeEach, afterEach, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
Expand Down Expand Up @@ -43,6 +43,29 @@ describe('context', () => {
});
});

describe('releases', () => {
// prettier-ignore
test.each([
['.github/buildx-lab-releases.json'],
['.github/buildx-releases.json'],
['.github/compose-lab-releases.json'],
['.github/compose-releases.json'],
['.github/docker-releases.json'],
['.github/regclient-releases.json'],
['.github/undock-releases.json'],
])('returns %p', async (path: string) => {
const github = new GitHub();
const releases = await github.releases('App', {
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: path
});
expect(releases).toBeDefined();
expect(Object.keys(releases).length).toBeGreaterThan(0);
});
});

describe('serverURL', () => {
const originalEnv = process.env;
beforeEach(() => {
Expand Down
16 changes: 13 additions & 3 deletions __tests__/regclient/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,23 @@ describe('getDownloadVersion', () => {
const version = await Install.getDownloadVersion('latest');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/regclient-releases.json'
});
});
it('returns v0.8.1 download version', async () => {
const version = await Install.getDownloadVersion('v0.8.1');
expect(version.version).toEqual('v0.8.1');
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/regclient-releases.json'
});
});
});

Expand All @@ -115,6 +125,6 @@ describe('getRelease', () => {
});
it('unknown release', async () => {
const version = await Install.getDownloadVersion('foo');
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find regclient release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json'));
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find regclient release foo in releases JSON'));
});
});
16 changes: 13 additions & 3 deletions __tests__/undock/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,23 @@ describe('getDownloadVersion', () => {
const version = await Install.getDownloadVersion('latest');
expect(version.version).toEqual('latest');
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/undock-releases.json'
});
});
it('returns v0.6.0 download version', async () => {
const version = await Install.getDownloadVersion('v0.6.0');
expect(version.version).toEqual('v0.6.0');
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json');
expect(version.contentOpts).toEqual({
owner: 'docker',
repo: 'actions-toolkit',
ref: 'main',
path: '.github/undock-releases.json'
});
});
});

Expand All @@ -120,6 +130,6 @@ describe('getRelease', () => {
});
it('unknown release', async () => {
const version = await Install.getDownloadVersion('foo');
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Undock release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json'));
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Undock release foo in releases JSON'));
});
});
Loading
Loading