fix: change from using env to os module
This commit is contained in:
parent
2c3ea16a59
commit
8454a14c98
|
@ -2,20 +2,15 @@ import * as core from '@actions/core';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
|
import osm from 'os';
|
||||||
|
|
||||||
import * as utils from '../src/cache-utils';
|
import * as utils from '../src/cache-utils';
|
||||||
import {restoreCache} from '../src/cache-restore';
|
import {restoreCache} from '../src/cache-restore';
|
||||||
|
|
||||||
describe('cache-restore', () => {
|
describe('cache-restore', () => {
|
||||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
if (!process.env.RUNNER_OS) {
|
const platform = 'Linux';
|
||||||
process.env.RUNNER_OS = 'Linux';
|
const arch = 'arm64';
|
||||||
}
|
|
||||||
if (!process.env.RUNNER_ARCH) {
|
|
||||||
process.env.RUNNER_ARCH = 'X64';
|
|
||||||
}
|
|
||||||
const platform = process.env.RUNNER_OS;
|
|
||||||
const arch = process.env.RUNNER_ARCH;
|
|
||||||
const commonPath = '/some/random/path';
|
const commonPath = '/some/random/path';
|
||||||
const npmCachePath = `${commonPath}/npm`;
|
const npmCachePath = `${commonPath}/npm`;
|
||||||
const pnpmCachePath = `${commonPath}/pnpm`;
|
const pnpmCachePath = `${commonPath}/pnpm`;
|
||||||
|
@ -56,6 +51,8 @@ describe('cache-restore', () => {
|
||||||
let getCommandOutputSpy: jest.SpyInstance;
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
let restoreCacheSpy: jest.SpyInstance;
|
let restoreCacheSpy: jest.SpyInstance;
|
||||||
let hashFilesSpy: jest.SpyInstance;
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
let platformSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// core
|
// core
|
||||||
|
@ -106,6 +103,13 @@ describe('cache-restore', () => {
|
||||||
|
|
||||||
// cache-utils
|
// cache-utils
|
||||||
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
|
|
||||||
|
// os
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => arch);
|
||||||
|
|
||||||
|
platformSpy = jest.spyOn(osm, 'platform');
|
||||||
|
platformSpy.mockImplementation(() => platform);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Validate provided package manager', () => {
|
describe('Validate provided package manager', () => {
|
||||||
|
|
|
@ -92567,7 +92567,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||||
}
|
}
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = os_1.default.platform();
|
||||||
const arch = os_1.default.arch();
|
const arch = os_1.default.arch();
|
||||||
const cachePaths = yield (0, cache_utils_1.getCacheDirectories)(packageManagerInfo, cacheDependencyPath);
|
const cachePaths = yield (0, cache_utils_1.getCacheDirectories)(packageManagerInfo, cacheDependencyPath);
|
||||||
core.saveState(constants_1.State.CachePaths, cachePaths);
|
core.saveState(constants_1.State.CachePaths, cachePaths);
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const restoreCache = async (
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||||
}
|
}
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = os.platform();
|
||||||
const arch = os.arch();
|
const arch = os.arch();
|
||||||
|
|
||||||
const cachePaths = await getCacheDirectories(
|
const cachePaths = await getCacheDirectories(
|
||||||
|
|
Loading…
Reference in New Issue