Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop Math.random usage #163

Merged
merged 1 commit into from
Dec 6, 2024
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
3 changes: 2 additions & 1 deletion __tests__/action_failed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`);
Expand Down
7 changes: 4 additions & 3 deletions __tests__/action_succeeded.localcloud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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`);

Expand Down Expand Up @@ -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`);

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cachehit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cachemiss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cacherestorefailure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
Loading