common base tmpDir for tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -23,7 +23,8 @@ import {BuildKit} from '../../src/buildkit/buildkit';
|
|||||||
import {Context} from '../../src/context';
|
import {Context} from '../../src/context';
|
||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
const tmpDir = path.join('/tmp/.docker-actions-toolkit-jest').split(path.sep).join(path.posix.sep);
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest').split(path.sep).join(path.posix.sep);
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import * as exec from '@actions/exec';
|
|||||||
import {Buildx} from '../../src/buildx/buildx';
|
import {Buildx} from '../../src/buildx/buildx';
|
||||||
import {Context} from '../../src/context';
|
import {Context} from '../../src/context';
|
||||||
|
|
||||||
const tmpDir = path.join('/tmp/.docker-actions-toolkit-jest').split(path.sep).join(path.posix.sep);
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import {Buildx} from '../../src/buildx/buildx';
|
|||||||
import {Inputs} from '../../src/buildx/inputs';
|
import {Inputs} from '../../src/buildx/inputs';
|
||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
const tmpDir = path.join('/tmp/.docker-actions-toolkit-jest').split(path.sep).join(path.posix.sep);
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest').split(path.sep).join(path.posix.sep);
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
const metadata = `{
|
const metadata = `{
|
||||||
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
import {describe, expect, it, jest, test, beforeEach} from '@jest/globals';
|
import {describe, expect, it, jest, test, beforeEach} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import osm = require('os');
|
import osm = require('os');
|
||||||
|
|
||||||
@@ -27,7 +26,8 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('install', () => {
|
describe('install', () => {
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'actions-toolkit-'));
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-install-jest').split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
@@ -65,6 +65,12 @@ describe('install', () => {
|
|||||||
},
|
},
|
||||||
100000
|
100000
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('returns latest buildx GitHub release', async () => {
|
||||||
|
const release = await Install.getRelease('latest');
|
||||||
|
expect(release).not.toBeNull();
|
||||||
|
expect(release?.tag_name).not.toEqual('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getRelease', () => {
|
describe('getRelease', () => {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
|
|||||||
|
|
||||||
import {Context} from '../src/context';
|
import {Context} from '../src/context';
|
||||||
|
|
||||||
const tmpDir = path.join('/tmp/.docker-actions-toolkit-jest').split(path.sep).join(path.posix.sep);
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest').split(path.sep).join(path.posix.sep);
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
|
|||||||
@@ -18,10 +18,13 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||||
RUNNER_TEMP: fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-github-runner-')).split(path.sep).join(path.posix.sep),
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep),
|
||||||
RUNNER_TOOL_CACHE: fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-github-tool-cache-')).split(path.sep).join(path.posix.sep)
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep)
|
||||||
}) as {
|
}) as {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ export class Install {
|
|||||||
|
|
||||||
private async download(version: string): Promise<string> {
|
private async download(version: string): Promise<string> {
|
||||||
const targetFile: string = os.platform() == 'win32' ? 'docker-buildx.exe' : 'docker-buildx';
|
const targetFile: string = os.platform() == 'win32' ? 'docker-buildx.exe' : 'docker-buildx';
|
||||||
const downloadUrl = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', version, this.filename(version));
|
const downloadURL = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', version, this.filename(version));
|
||||||
const downloadPath = await tc.downloadTool(downloadUrl);
|
const downloadPath = await tc.downloadTool(downloadURL);
|
||||||
core.debug(`downloadUrl=${downloadUrl}`);
|
core.debug(`downloadURL: ${downloadURL}`);
|
||||||
core.debug(`downloadPath=${downloadPath}`);
|
core.debug(`downloadPath: ${downloadPath}`);
|
||||||
return await tc.cacheFile(downloadPath, targetFile, 'buildx', version);
|
return await tc.cacheFile(downloadPath, targetFile, 'buildx', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user