mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
chore: remove path sep conversion
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
2038d87306
commit
ed087e5b0d
@ -24,8 +24,8 @@ import {Context} from '../../src/context';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest');
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
if (!fs.existsSync(tmpDir)) {
|
if (!fs.existsSync(tmpDir)) {
|
||||||
@ -50,7 +50,7 @@ describe('resolve', () => {
|
|||||||
['debug = true', false, 'debug = true', null],
|
['debug = true', false, 'debug = true', null],
|
||||||
[`notfound.toml`, true, '', new Error('config file notfound.toml not found')],
|
[`notfound.toml`, true, '', new Error('config file notfound.toml not found')],
|
||||||
[
|
[
|
||||||
`${path.join(fixturesDir, 'buildkitd.toml').split(path.sep).join(path.posix.sep)}`,
|
`${path.join(fixturesDir, 'buildkitd.toml')}`,
|
||||||
true,
|
true,
|
||||||
`debug = true
|
`debug = true
|
||||||
[registry."docker.io"]
|
[registry."docker.io"]
|
||||||
|
@ -27,8 +27,8 @@ import {Context} from '../../src/context';
|
|||||||
import {Cert} from '../../src/types/buildx';
|
import {Cert} from '../../src/types/buildx';
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
if (!fs.existsSync(tmpDir)) {
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
@ -25,8 +25,8 @@ import {Inputs} from '../../src/buildx/inputs';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest');
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
const metadata = `{
|
const metadata = `{
|
||||||
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
||||||
"containerimage.digest": "sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c"
|
"containerimage.digest": "sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c"
|
||||||
@ -175,7 +175,7 @@ describe('resolveBuildSecret', () => {
|
|||||||
['aaaaaaaa', false, '', '', new Error('aaaaaaaa is not a valid secret')],
|
['aaaaaaaa', false, '', '', new Error('aaaaaaaa is not a valid secret')],
|
||||||
['aaaaaaaa=', false, '', '', new Error('aaaaaaaa= is not a valid secret')],
|
['aaaaaaaa=', false, '', '', new Error('aaaaaaaa= is not a valid secret')],
|
||||||
['=bbbbbbb', false, '', '', new Error('=bbbbbbb is not a valid secret')],
|
['=bbbbbbb', false, '', '', new Error('=bbbbbbb is not a valid secret')],
|
||||||
[`foo=${path.join(fixturesDir, 'secret.txt').split(path.sep).join(path.posix.sep)}`, true, 'foo', 'bar', null],
|
[`foo=${path.join(fixturesDir, 'secret.txt')}`, true, 'foo', 'bar', null],
|
||||||
[`notfound=secret`, true, '', '', new Error('secret file secret not found')]
|
[`notfound=secret`, true, '', '', new Error('secret file secret not found')]
|
||||||
])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error) => {
|
])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error) => {
|
||||||
try {
|
try {
|
||||||
|
@ -23,7 +23,7 @@ import osm = require('os');
|
|||||||
import {Install} from '../../src/buildx/install';
|
import {Install} from '../../src/buildx/install';
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
@ -22,8 +22,8 @@ import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
|
|||||||
import {Context} from '../src/context';
|
import {Context} from '../src/context';
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest');
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
|
||||||
if (!fs.existsSync(tmpDir)) {
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
@ -60,18 +60,18 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('docker cli', () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.printVersion(false).catch(() => {
|
await Docker.printVersion(false).catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
||||||
failOnStdErr: false
|
failOnStdErr: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', () => {
|
it('standalone', async () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.printVersion(true).catch(() => {
|
await Docker.printVersion(true).catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
|
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
|
||||||
|
@ -18,13 +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);
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
process.env = Object.assign({}, process.env, {
|
||||||
TEMP: tmpDir,
|
TEMP: tmpDir,
|
||||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep),
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep)
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
}) as {
|
}) as {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
@ -29,11 +29,11 @@ export class Inputs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getBuildImageIDFilePath(): string {
|
public getBuildImageIDFilePath(): string {
|
||||||
return path.join(this.context.tmpDir(), 'iidfile').split(path.sep).join(path.posix.sep);
|
return path.join(this.context.tmpDir(), 'iidfile');
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBuildMetadataFilePath(): string {
|
public getBuildMetadataFilePath(): string {
|
||||||
return path.join(this.context.tmpDir(), 'metadata-file').split(path.sep).join(path.posix.sep);
|
return path.join(this.context.tmpDir(), 'metadata-file');
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolveBuildImageID(): string | undefined {
|
public resolveBuildImageID(): string | undefined {
|
||||||
|
@ -89,7 +89,7 @@ export class Install {
|
|||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('buildx', vspec);
|
toolPath = tc.find('buildx', vspec);
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
const outputDir = path.join(this.context.tmpDir(), 'build-cache').split(path.sep).join(path.posix.sep);
|
const outputDir = path.join(this.context.tmpDir(), 'build-cache');
|
||||||
const buildCmd = await this.buildCommand(gitContext, outputDir);
|
const buildCmd = await this.buildCommand(gitContext, outputDir);
|
||||||
toolPath = await exec
|
toolPath = await exec
|
||||||
.getExecOutput(buildCmd.command, buildCmd.args, {
|
.getExecOutput(buildCmd.command, buildCmd.args, {
|
||||||
|
@ -27,7 +27,7 @@ export class Context {
|
|||||||
public buildGitContext: string;
|
public buildGitContext: string;
|
||||||
public provenanceBuilderID: string;
|
public provenanceBuilderID: string;
|
||||||
|
|
||||||
private readonly _tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
|
private readonly _tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.gitRef = github.context.ref;
|
this.gitRef = github.context.ref;
|
||||||
|
Loading…
Reference in New Issue
Block a user