mirror of
https://github.com/actions/setup-node.git
synced 2024-12-25 23:30:59 +08:00
60edb5dd54
Some checks failed
Basic validation / Basic validation (push) Failing after 1s
Check dist / Check dist/ (push) Failing after 1s
CodeQL analysis / CodeQL analysis (push) Failing after 1s
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, ubuntu-latest) (push) Failing after 4s
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, ubuntu-latest) (push) Failing after 4s
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, ubuntu-latest) (push) Failing after 4s
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, ubuntu-latest) (push) Failing after 12s
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, ubuntu-latest) (push) Failing after 11s
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, ubuntu-latest) (push) Failing after 11s
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, ubuntu-latest) (push) Failing after 11s
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, ubuntu-latest) (push) Failing after 11s
e2e-cache / Test yarn subprojects (12) (push) Failing after 12s
e2e-cache / Test yarn subprojects (14) (push) Failing after 12s
e2e-cache / Test yarn subprojects (16) (push) Failing after 12s
e2e-cache / Test yarn subprojects all locally managed (12) (push) Failing after 11s
e2e-cache / Test yarn subprojects all locally managed (14) (push) Failing after 11s
e2e-cache / Test yarn subprojects all locally managed (16) (push) Failing after 11s
e2e-cache / Test yarn subprojects some locally managed (12) (push) Failing after 11s
e2e-cache / Test yarn subprojects some locally managed (14) (push) Failing after 10s
e2e-cache / Test yarn subprojects some locally managed (16) (push) Failing after 12s
Licensed / Licensed (push) Failing after 3s
proxy / test-proxy (push) Failing after 7s
proxy / test-bypass-proxy (push) Failing after 34s
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, ubuntu-latest) (push) Successful in 5m15s
e2e-cache / Test yarn subprojects managed by git (14) (push) Failing after 5m4s
e2e-cache / Test yarn subprojects managed by git (16) (push) Failing after 5m4s
versions / lts-syntax (lts/*, ubuntu-latest) (push) Failing after 26s
versions / lts-syntax (lts/-1, ubuntu-latest) (push) Failing after 27s
versions / lts-syntax (lts/dubnium, ubuntu-latest) (push) Failing after 24s
versions / lts-syntax (lts/erbium, ubuntu-latest) (push) Failing after 23s
versions / lts-syntax (lts/fermium, ubuntu-latest) (push) Failing after 25s
versions / v8-canary-syntax (20.0.0-v8-canary, ubuntu-latest) (push) Successful in 28s
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, ubuntu-latest) (push) Successful in 28s
versions / v8-canary-syntax (20-v8-canary, ubuntu-latest) (push) Failing after 1m45s
versions / local-cache (12, ubuntu-latest) (push) Successful in 7m28s
versions / nightly-syntax (17-nightly, ubuntu-latest) (push) Successful in 2m45s
versions / local-cache (14, ubuntu-latest) (push) Failing after 7m55s
versions / local-cache (10, ubuntu-latest) (push) Failing after 12m33s
versions / rc-syntax (18.0.0-rc.2, ubuntu-latest) (push) Successful in 27s
versions / nightly-syntax (18.0.0-nightly, ubuntu-latest) (push) Successful in 5m55s
versions / nightly-syntax (16.0.0-nightly20210420a0261d231c, ubuntu-latest) (push) Failing after 7m55s
versions / manifest (12.16.0, ubuntu-latest) (push) Successful in 2m45s
versions / manifest (14.2.0, ubuntu-latest) (push) Successful in 1m49s
versions / manifest (10.15, ubuntu-latest) (push) Successful in 6m1s
e2e-cache / Test yarn subprojects managed by git (12) (push) Failing after 19m20s
versions / rc-syntax (16.0.0-rc.1, ubuntu-latest) (push) Failing after 10m12s
versions / rc-syntax (19.0.0-rc.0, ubuntu-latest) (push) Failing after 7m56s
versions / version-file (.tool-versions, ubuntu-latest) (push) Failing after 3m3s
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, ubuntu-latest) (push) Failing after 25m51s
versions / version-file (.tool-versions-node, ubuntu-latest) (push) Successful in 1m9s
versions / version-file (.nvmrc, ubuntu-latest) (push) Failing after 7m58s
versions / manifest (16.3.0, ubuntu-latest) (push) Failing after 12m33s
versions / check-latest (10, ubuntu-latest) (push) Successful in 13m34s
versions / version-file-volta (ubuntu-latest) (push) Failing after 7m57s
versions / old-versions (ubuntu-latest) (push) Successful in 19s
versions / node-dist (13, ubuntu-latest) (push) Failing after 3m3s
versions / node-latest-aliases (current, ubuntu-latest) (push) Successful in 29s
versions / node-latest-aliases (latest, ubuntu-latest) (push) Successful in 29s
versions / node-latest-aliases (node, ubuntu-latest) (push) Successful in 29s
versions / version-file (package.json, ubuntu-latest) (push) Failing after 10m18s
versions / node-dist (11, ubuntu-latest) (push) Failing after 7m54s
versions / version-file-volta-extends (ubuntu-latest) (push) Failing after 12m31s
versions / check-latest (14, ubuntu-latest) (push) Successful in 23m17s
versions / check-latest (12, ubuntu-latest) (push) Successful in 29m39s
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, ubuntu-latest) (push) Successful in 57m29s
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (12, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (14, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }}) (16, windows-latest) (push) Has been cancelled
versions / local-cache (10, macos-latest) (push) Has been cancelled
versions / local-cache (10, windows-latest) (push) Has been cancelled
versions / local-cache (12, macos-latest) (push) Has been cancelled
versions / local-cache (12, windows-latest) (push) Has been cancelled
versions / local-cache (14, macos-latest) (push) Has been cancelled
versions / local-cache (14, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, macos-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, macos-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, macos-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/erbium, macos-latest) (push) Has been cancelled
versions / lts-syntax (lts/erbium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, macos-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, windows-latest) (push) Has been cancelled
versions / nightly-syntax (16.0.0-nightly20210420a0261d231c, macos-latest) (push) Has been cancelled
versions / nightly-syntax (16.0.0-nightly20210420a0261d231c, windows-latest) (push) Has been cancelled
versions / nightly-syntax (17-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (17-nightly, windows-latest) (push) Has been cancelled
versions / nightly-syntax (18.0.0-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (18.0.0-nightly, windows-latest) (push) Has been cancelled
versions / rc-syntax (16.0.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (16.0.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (18.0.0-rc.2, macos-latest) (push) Has been cancelled
versions / rc-syntax (18.0.0-rc.2, windows-latest) (push) Has been cancelled
versions / rc-syntax (19.0.0-rc.0, macos-latest) (push) Has been cancelled
versions / rc-syntax (19.0.0-rc.0, windows-latest) (push) Has been cancelled
versions / manifest (10.15, macos-latest) (push) Has been cancelled
versions / manifest (10.15, windows-latest) (push) Has been cancelled
versions / manifest (12.16.0, macos-latest) (push) Has been cancelled
versions / manifest (12.16.0, windows-latest) (push) Has been cancelled
versions / manifest (14.2.0, macos-latest) (push) Has been cancelled
versions / manifest (14.2.0, windows-latest) (push) Has been cancelled
versions / manifest (16.3.0, macos-latest) (push) Has been cancelled
versions / manifest (16.3.0, windows-latest) (push) Has been cancelled
versions / check-latest (10, macos-latest) (push) Has been cancelled
versions / check-latest (10, windows-latest) (push) Has been cancelled
versions / check-latest (12, macos-latest) (push) Has been cancelled
versions / check-latest (12, windows-latest) (push) Has been cancelled
versions / check-latest (14, macos-latest) (push) Has been cancelled
versions / check-latest (14, windows-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest) (push) Has been cancelled
versions / version-file (.nvmrc, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, windows-latest) (push) Has been cancelled
versions / version-file (package.json, macos-latest) (push) Has been cancelled
versions / version-file (package.json, windows-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest) (push) Has been cancelled
versions / version-file-volta (windows-latest) (push) Has been cancelled
versions / version-file-volta-extends (macos-latest) (push) Has been cancelled
versions / version-file-volta-extends (windows-latest) (push) Has been cancelled
versions / node-dist (11, macos-latest) (push) Has been cancelled
versions / node-dist (11, windows-latest) (push) Has been cancelled
versions / node-dist (13, macos-latest) (push) Has been cancelled
versions / node-dist (13, windows-latest) (push) Has been cancelled
versions / old-versions (macos-latest) (push) Has been cancelled
versions / old-versions (windows-latest) (push) Has been cancelled
versions / arch (push) Has been cancelled
versions / node-latest-aliases (current, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (current, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (node, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (node, windows-latest) (push) Has been cancelled
* add support for arm64 Windows * revert 7z to exe * add comment --------- Co-authored-by: aparnajyothi-y <147696841+aparnajyothi-y@users.noreply.github.com>
284 lines
9.1 KiB
TypeScript
284 lines
9.1 KiB
TypeScript
import * as core from '@actions/core';
|
|
import * as exec from '@actions/exec';
|
|
import * as tc from '@actions/tool-cache';
|
|
import * as cache from '@actions/cache';
|
|
import * as io from '@actions/io';
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import osm from 'os';
|
|
|
|
import each from 'jest-each';
|
|
|
|
import * as main from '../src/main';
|
|
import * as util from '../src/util';
|
|
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
|
|
|
|
describe('main tests', () => {
|
|
let inputs = {} as any;
|
|
let os = {} as any;
|
|
|
|
let infoSpy: jest.SpyInstance;
|
|
let warningSpy: jest.SpyInstance;
|
|
let inSpy: jest.SpyInstance;
|
|
let setOutputSpy: jest.SpyInstance;
|
|
let startGroupSpy: jest.SpyInstance;
|
|
let endGroupSpy: jest.SpyInstance;
|
|
|
|
let whichSpy: jest.SpyInstance;
|
|
|
|
let existsSpy: jest.SpyInstance;
|
|
|
|
let getExecOutputSpy: jest.SpyInstance;
|
|
|
|
let getNodeVersionFromFileSpy: jest.SpyInstance;
|
|
let cnSpy: jest.SpyInstance;
|
|
let findSpy: jest.SpyInstance;
|
|
let isCacheActionAvailable: jest.SpyInstance;
|
|
|
|
let setupNodeJsSpy: jest.SpyInstance;
|
|
|
|
beforeEach(() => {
|
|
inputs = {};
|
|
|
|
// node
|
|
os = {};
|
|
console.log('::stop-commands::stoptoken');
|
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
|
infoSpy = jest.spyOn(core, 'info');
|
|
infoSpy.mockImplementation(() => {});
|
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
setOutputSpy.mockImplementation(() => {});
|
|
warningSpy = jest.spyOn(core, 'warning');
|
|
warningSpy.mockImplementation(() => {});
|
|
startGroupSpy = jest.spyOn(core, 'startGroup');
|
|
startGroupSpy.mockImplementation(() => {});
|
|
endGroupSpy = jest.spyOn(core, 'endGroup');
|
|
endGroupSpy.mockImplementation(() => {});
|
|
inSpy = jest.spyOn(core, 'getInput');
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
whichSpy = jest.spyOn(io, 'which');
|
|
|
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
|
|
|
findSpy = jest.spyOn(tc, 'find');
|
|
|
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
|
|
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
|
cnSpy.mockImplementation(line => {
|
|
// uncomment to debug
|
|
process.stderr.write('write:' + line + '\n');
|
|
});
|
|
|
|
setupNodeJsSpy = jest.spyOn(OfficialBuilds.prototype, 'setupNodeJs');
|
|
setupNodeJsSpy.mockImplementation(() => {});
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.resetAllMocks();
|
|
jest.clearAllMocks();
|
|
//jest.restoreAllMocks();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
console.log('::stoptoken::');
|
|
jest.restoreAllMocks();
|
|
}, 100000);
|
|
|
|
describe('getNodeVersionFromFile', () => {
|
|
each`
|
|
contents | expected
|
|
${'12'} | ${'12'}
|
|
${'12.3'} | ${'12.3'}
|
|
${'12.3.4'} | ${'12.3.4'}
|
|
${'v12.3.4'} | ${'12.3.4'}
|
|
${'lts/erbium'} | ${'lts/erbium'}
|
|
${'lts/*'} | ${'lts/*'}
|
|
${'nodejs 12.3.4'} | ${'12.3.4'}
|
|
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
|
|
${''} | ${''}
|
|
${'unknown format'} | ${'unknown format'}
|
|
${' 14.1.0 '} | ${'14.1.0'}
|
|
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
|
|
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
|
|
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
|
${'{}'} | ${null}
|
|
`.it('parses "$contents"', ({contents, expected}) => {
|
|
const existsSpy = jest.spyOn(fs, 'existsSync');
|
|
existsSpy.mockImplementation(() => true);
|
|
|
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
|
readFileSpy.mockImplementation(filePath => {
|
|
if (
|
|
typeof filePath === 'string' &&
|
|
path.basename(filePath) === 'package.json'
|
|
) {
|
|
// Special case for volta.extends
|
|
return '{"volta": {"node": "18.0.0"}}';
|
|
}
|
|
|
|
return contents;
|
|
});
|
|
|
|
expect(util.getNodeVersionFromFile('file')).toBe(expected);
|
|
});
|
|
});
|
|
|
|
describe('printEnvDetailsAndSetOutput', () => {
|
|
it.each([
|
|
[{node: '12.0.2', npm: '6.3.3', yarn: '1.22.11'}],
|
|
[{node: '16.0.2', npm: '7.3.3', yarn: '2.22.11'}],
|
|
[{node: '14.0.1', npm: '8.1.0', yarn: '3.2.1'}],
|
|
[{node: '17.0.2', npm: '6.3.3', yarn: ''}]
|
|
])('Tools versions %p', async obj => {
|
|
getExecOutputSpy.mockImplementation(async command => {
|
|
if (Reflect.has(obj, command) && !obj[command]) {
|
|
return {
|
|
stdout: '',
|
|
stderr: `${command} does not exist`,
|
|
exitCode: 1
|
|
};
|
|
}
|
|
|
|
return {stdout: obj[command], stderr: '', exitCode: 0};
|
|
});
|
|
|
|
whichSpy.mockImplementation(cmd => {
|
|
return `some/${cmd}/path`;
|
|
});
|
|
|
|
await util.printEnvDetailsAndSetOutput();
|
|
|
|
expect(setOutputSpy).toHaveBeenCalledWith('node-version', obj['node']);
|
|
Object.getOwnPropertyNames(obj).forEach(name => {
|
|
if (!obj[name]) {
|
|
expect(infoSpy).toHaveBeenCalledWith(
|
|
`[warning]${name} does not exist`
|
|
);
|
|
}
|
|
expect(infoSpy).toHaveBeenCalledWith(`${name}: ${obj[name]}`);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('node-version-file flag', () => {
|
|
beforeEach(() => {
|
|
delete inputs['node-version'];
|
|
inputs['node-version-file'] = '.nvmrc';
|
|
|
|
getNodeVersionFromFileSpy = jest.spyOn(util, 'getNodeVersionFromFile');
|
|
});
|
|
|
|
afterEach(() => {
|
|
getNodeVersionFromFileSpy.mockRestore();
|
|
});
|
|
|
|
it('does not read node-version-file if node-version is provided', async () => {
|
|
// Arrange
|
|
inputs['node-version'] = '12';
|
|
|
|
// Act
|
|
await main.run();
|
|
|
|
// Assert
|
|
expect(inputs['node-version']).toBeDefined();
|
|
expect(inputs['node-version-file']).toBeDefined();
|
|
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
|
expect(warningSpy).toHaveBeenCalledWith(
|
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
|
);
|
|
});
|
|
|
|
it('does not read node-version-file if node-version-file is not provided', async () => {
|
|
// Arrange
|
|
delete inputs['node-version-file'];
|
|
|
|
// Act
|
|
await main.run();
|
|
|
|
// Assert
|
|
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('reads node-version-file', async () => {
|
|
// Arrange
|
|
const expectedVersionSpec = '14';
|
|
getNodeVersionFromFileSpy.mockImplementation(() => expectedVersionSpec);
|
|
|
|
// Act
|
|
await main.run();
|
|
|
|
// Assert
|
|
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
|
expect(infoSpy).toHaveBeenCalledWith(
|
|
`Resolved ${inputs['node-version-file']} as ${expectedVersionSpec}`
|
|
);
|
|
}, 10000);
|
|
|
|
it('should throw an error if node-version-file is not accessible', async () => {
|
|
// Arrange
|
|
inputs['node-version-file'] = 'non-existing-file';
|
|
const versionFilePath = path.join(
|
|
__dirname,
|
|
'data',
|
|
inputs['node-version-file']
|
|
);
|
|
|
|
// Act
|
|
await main.run();
|
|
|
|
// Assert
|
|
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
|
expect(cnSpy).toHaveBeenCalledWith(
|
|
`::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}`
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('cache on GHES', () => {
|
|
it('Should throw an error, because cache is not supported', async () => {
|
|
inputs['node-version'] = '12';
|
|
inputs['cache'] = 'npm';
|
|
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
|
isCacheActionAvailable.mockImplementation(() => false);
|
|
|
|
await main.run();
|
|
|
|
expect(warningSpy).toHaveBeenCalledWith(
|
|
`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.`
|
|
);
|
|
});
|
|
|
|
it('Should throw an internal error', async () => {
|
|
inputs['node-version'] = '12';
|
|
inputs['cache'] = 'npm';
|
|
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
process.env['GITHUB_SERVER_URL'] = '';
|
|
isCacheActionAvailable.mockImplementation(() => false);
|
|
|
|
await main.run();
|
|
|
|
expect(warningSpy).toHaveBeenCalledWith(
|
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
|
);
|
|
});
|
|
});
|
|
});
|