diff --git a/__tests__/action_failed.test.ts b/__tests__/action_failed.test.ts index 0ea3802..8411d59 100644 --- a/__tests__/action_failed.test.ts +++ b/__tests__/action_failed.test.ts @@ -9,6 +9,7 @@ import * as core from '@actions/core'; import * as getcmake from '../src/get-cmake'; import path = require('path'); import { ToolsGetter } from '../src/get-cmake'; +import * as crypto from 'crypto'; // 10 minutes jest.setTimeout(10 * 60 * 1000) @@ -36,7 +37,7 @@ var coreError = jest.spyOn(core, 'error').mockImplementation(() => {}); var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir'); test('testing get-cmake action failure', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.exitCode process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`); diff --git a/__tests__/action_succeeded.localcloud.test.ts b/__tests__/action_succeeded.localcloud.test.ts index bd31d09..955d238 100644 --- a/__tests__/action_succeeded.localcloud.test.ts +++ b/__tests__/action_succeeded.localcloud.test.ts @@ -3,6 +3,7 @@ // SPDX short identifier: MIT import * as os from 'os'; +import * as crypto from 'crypto'; import * as toolcache from '@actions/tool-cache'; import * as core from '@actions/core'; import * as path from 'path' @@ -46,7 +47,7 @@ var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir'); var toolsFind = jest.spyOn(toolcache, 'find'); test('testing get-cmake action success with cloud/local cache enabled', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`); @@ -78,7 +79,7 @@ test('testing get-cmake action success with cloud/local cache enabled', async () }); test('testing get-cmake action success with local or cloud cache hits', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`); @@ -121,7 +122,7 @@ test('testing get-cmake action store and restore local cache', async () => { toolsCacheDir.mockRestore(); toolsFind.mockRestore(); - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`); let downloadMock = undefined; diff --git a/__tests__/cachehit.test.ts b/__tests__/cachehit.test.ts index fd87963..2410982 100644 --- a/__tests__/cachehit.test.ts +++ b/__tests__/cachehit.test.ts @@ -8,6 +8,7 @@ import * as os from 'os'; import { ToolsGetter } from '../src/get-cmake'; import * as cache from '@actions/cache'; import path = require('path'); +import * as crypto from 'crypto'; // 10 minutes jest.setTimeout(10 * 60 * 1000) @@ -24,7 +25,7 @@ const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation(( const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0); test('testing get-cmake with cache-hit...', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); const getter: ToolsGetter = new ToolsGetter(); diff --git a/__tests__/cachemiss.test.ts b/__tests__/cachemiss.test.ts index 0ddec76..7721a09 100644 --- a/__tests__/cachemiss.test.ts +++ b/__tests__/cachemiss.test.ts @@ -9,6 +9,7 @@ import { ToolsGetter } from '../src/get-cmake'; import * as cache from '@actions/cache'; import * as core from '@actions/core'; import path = require('path'); +import * as crypto from 'crypto'; // 10 minutes jest.setTimeout(10 * 60 * 1000) @@ -27,7 +28,7 @@ const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation(( const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0); test('testing get-cmake with cache-miss...', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); const getter: ToolsGetter = new ToolsGetter(); await getter.run(); diff --git a/__tests__/cacherestorefailure.test.ts b/__tests__/cacherestorefailure.test.ts index 1bd53cc..983131a 100644 --- a/__tests__/cacherestorefailure.test.ts +++ b/__tests__/cacherestorefailure.test.ts @@ -8,6 +8,7 @@ import * as os from 'os'; import { ToolsGetter } from '../src/get-cmake'; import * as cache from '@actions/cache'; import path = require('path'); +import * as crypto from 'crypto'; // 10 minutes jest.setTimeout(10 * 60 * 1000) @@ -24,7 +25,7 @@ jest.spyOn(cache, 'restoreCache').mockImplementation(() => { const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0); test('testing get-cmake with restoreCache failure', async () => { - const testId = Math.random(); + const testId = crypto.randomBytes(16).toString('hex'); process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`); const getter: ToolsGetter = new ToolsGetter();