diff --git a/__tests__/buildkit/config.test.ts b/__tests__/buildkit/config.test.ts index c3ac51d..6c71081 100644 --- a/__tests__/buildkit/config.test.ts +++ b/__tests__/buildkit/config.test.ts @@ -24,8 +24,8 @@ import {Context} from '../../src/context'; const fixturesDir = path.join(__dirname, '..', 'fixtures'); // 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 tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest'); +const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => { if (!fs.existsSync(tmpDir)) { @@ -50,7 +50,7 @@ describe('resolve', () => { ['debug = true', false, 'debug = true', null], [`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, `debug = true [registry."docker.io"] diff --git a/__tests__/buildx/buildx.test.ts b/__tests__/buildx/buildx.test.ts index 0e182ea..7f02dcf 100644 --- a/__tests__/buildx/buildx.test.ts +++ b/__tests__/buildx/buildx.test.ts @@ -27,8 +27,8 @@ import {Context} from '../../src/context'; import {Cert} from '../../src/types/buildx'; // 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 tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest'); +const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => { if (!fs.existsSync(tmpDir)) { diff --git a/__tests__/buildx/inputs.test.ts b/__tests__/buildx/inputs.test.ts index 6e16f24..c600778 100644 --- a/__tests__/buildx/inputs.test.ts +++ b/__tests__/buildx/inputs.test.ts @@ -25,8 +25,8 @@ import {Inputs} from '../../src/buildx/inputs'; const fixturesDir = path.join(__dirname, '..', 'fixtures'); // 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 tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest'); +const tmpName = path.join(tmpDir, '.tmpname-jest'); const metadata = `{ "containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd", "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')], ['=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')] ])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error) => { try { diff --git a/__tests__/buildx/install.test.ts b/__tests__/buildx/install.test.ts index d553b65..24c2657 100644 --- a/__tests__/buildx/install.test.ts +++ b/__tests__/buildx/install.test.ts @@ -23,7 +23,7 @@ import osm = require('os'); import {Install} from '../../src/buildx/install'; // 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(() => { jest.clearAllMocks(); diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 8da6469..f9ec49e 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -22,8 +22,8 @@ import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals'; import {Context} from '../src/context'; // 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 tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest'); +const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => { if (!fs.existsSync(tmpDir)) { diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index 75d125d..8823e43 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -60,18 +60,18 @@ describe('isAvailable', () => { }); describe('printVersion', () => { - it('docker cli', () => { + it('docker cli', async () => { const execSpy = jest.spyOn(exec, 'exec'); - Docker.printVersion(false).catch(() => { + await Docker.printVersion(false).catch(() => { // noop }); expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], { failOnStdErr: false }); }); - it('standalone', () => { + it('standalone', async () => { const execSpy = jest.spyOn(exec, 'exec'); - Docker.printVersion(true).catch(() => { + await Docker.printVersion(true).catch(() => { // noop }); expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], { diff --git a/jest.config.ts b/jest.config.ts index d446ddb..49ba111 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -18,13 +18,13 @@ import fs from 'fs'; import os from 'os'; 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, { TEMP: tmpDir, GITHUB_REPOSITORY: 'docker/actions-toolkit', - RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep), - RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep) + RUNNER_TEMP: path.join(tmpDir, 'runner-temp'), + RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache') }) as { [key: string]: string; }; diff --git a/src/buildx/inputs.ts b/src/buildx/inputs.ts index c07ea05..3f9559a 100644 --- a/src/buildx/inputs.ts +++ b/src/buildx/inputs.ts @@ -29,11 +29,11 @@ export class Inputs { } 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 { - 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 { diff --git a/src/buildx/install.ts b/src/buildx/install.ts index 3b8a04b..f8f87ee 100644 --- a/src/buildx/install.ts +++ b/src/buildx/install.ts @@ -89,7 +89,7 @@ export class Install { let toolPath: string; toolPath = tc.find('buildx', vspec); 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); toolPath = await exec .getExecOutput(buildCmd.command, buildCmd.args, { diff --git a/src/context.ts b/src/context.ts index 9c624b0..c0fbba9 100644 --- a/src/context.ts +++ b/src/context.ts @@ -27,7 +27,7 @@ export class Context { public buildGitContext: 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() { this.gitRef = github.context.ref;