mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 17:26:27 +00:00
Show warning instead of failure when cache is not reachable
This commit is contained in:
parent
eeb10cff27
commit
dfc4b745b4
4 changed files with 13 additions and 6 deletions
|
@ -46,7 +46,8 @@ describe('cache-utils', () => {
|
||||||
isFeatureAvailable.mockImplementation(() => false);
|
isFeatureAvailable.mockImplementation(() => false);
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
||||||
|
|
||||||
expect(() => isCacheFeatureAvailable()).toThrowError(
|
isCacheFeatureAvailable();
|
||||||
|
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.'
|
'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.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -644,8 +644,8 @@ describe('setup-node', () => {
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
`::error::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.${osm.EOL}`
|
'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.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ export function isGhes(): boolean {
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (!cache.isFeatureAvailable()) {
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
throw new Error(
|
core.warning(
|
||||||
'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.'
|
'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.'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
10
src/main.ts
10
src/main.ts
|
@ -16,7 +16,6 @@ export async function run() {
|
||||||
let version = resolveVersionInput();
|
let version = resolveVersionInput();
|
||||||
|
|
||||||
let arch = core.getInput('architecture');
|
let arch = core.getInput('architecture');
|
||||||
const cache = core.getInput('cache');
|
|
||||||
|
|
||||||
// if architecture supplied but node-version is not
|
// if architecture supplied but node-version is not
|
||||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||||
|
@ -39,6 +38,13 @@ export async function run() {
|
||||||
await installer.getNode(version, stable, checkLatest, auth, arch);
|
await installer.getNode(version, stable, checkLatest, auth, arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cache = core.getInput('cache');
|
||||||
|
|
||||||
const registryUrl: string = core.getInput('registry-url');
|
const registryUrl: string = core.getInput('registry-url');
|
||||||
const alwaysAuth: string = core.getInput('always-auth');
|
const alwaysAuth: string = core.getInput('always-auth');
|
||||||
if (registryUrl) {
|
if (registryUrl) {
|
||||||
|
@ -59,7 +65,7 @@ export async function run() {
|
||||||
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.setFailed(err.message);
|
core.warning(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue