Add Node version validation and manifest fetch retry (#1580)
Some checks failed
Basic validation / Basic validation (push) Failing after 0s
Check dist / Check dist/ (push) Failing after 0s
CodeQL analysis / CodeQL analysis (push) Failing after 0s
e2e-cache / Test npm (Node 20, ubuntu-latest) (push) Successful in 10m19s
e2e-cache / Test npm (Node 22, ubuntu-latest) (push) Successful in 10m14s
e2e-cache / Test npm (Node 24, ubuntu-latest) (push) Successful in 10m20s
e2e-cache / Test pnpm (Node 20, ubuntu-latest) (push) Failing after 2m1s
e2e-cache / Test pnpm (Node 22, ubuntu-latest) (push) Failing after 2m1s
e2e-cache / Test pnpm (Node 24, ubuntu-latest) (push) Failing after 1m59s
e2e-cache / Test yarn 1 (Node 20, ubuntu-latest) (push) Failing after 13s
e2e-cache / Test yarn 1 (Node 22, ubuntu-latest) (push) Failing after 14s
e2e-cache / Test yarn 1 (Node 24, ubuntu-latest) (push) Failing after 9s
e2e-cache / Test yarn 3 (Node 20, ubuntu-latest) (push) Failing after 8s
e2e-cache / Test yarn 3 (Node 22, ubuntu-latest) (push) Failing after 9s
e2e-cache / Test yarn 3 (Node 24, ubuntu-latest) (push) Failing after 9s
e2e-cache / Test yarn subprojects (20) (push) Failing after 9s
e2e-cache / Test yarn subprojects (22) (push) Failing after 9s
e2e-cache / Test yarn subprojects (24) (push) Failing after 9s
e2e-cache / Test yarn subprojects all locally managed (20) (push) Failing after 9s
e2e-cache / Test yarn subprojects all locally managed (22) (push) Failing after 9s
e2e-cache / Test yarn subprojects all locally managed (24) (push) Failing after 8s
e2e-cache / Test yarn subprojects some locally managed (20) (push) Failing after 9s
e2e-cache / Test yarn subprojects some locally managed (22) (push) Failing after 8s
e2e-cache / Test yarn subprojects some locally managed (24) (push) Failing after 11s
e2e-cache / Test yarn subprojects managed by git (20) (push) Failing after 9s
e2e-cache / Test yarn subprojects managed by git (22) (push) Failing after 9s
e2e-cache / Test yarn subprojects managed by git (24) (push) Failing after 9s
e2e-cache / Test auto cache with top-level packageManager (20, ubuntu-latest) (push) Successful in 9m40s
e2e-cache / Test auto cache with top-level packageManager (22, ubuntu-latest) (push) Failing after 1m38s
e2e-cache / Test auto cache with top-level packageManager (24, ubuntu-latest) (push) Successful in 9m45s
e2e-cache / Test auto cache with devEngines.packageManager (20, ubuntu-latest) (push) Failing after 1m37s
e2e-cache / Test auto cache with devEngines.packageManager (22, ubuntu-latest) (push) Failing after 17m3s
e2e-cache / Test auto cache with devEngines.packageManager (24, ubuntu-latest) (push) Successful in 9m43s
Licensed / Licensed (push) Failing after 0s
proxy / test-proxy (push) Failing after 2s
proxy / test-bypass-proxy (push) Failing after 1m14s
versions / local-cache (20, ubuntu-latest) (push) Successful in 26s
versions / local-cache (22, ubuntu-latest) (push) Successful in 26s
versions / local-cache (24, ubuntu-latest) (push) Successful in 19s
versions / lts-syntax (lts/*, ubuntu-latest) (push) Failing after 18s
versions / lts-syntax (lts/-1, ubuntu-latest) (push) Failing after 18s
versions / lts-syntax (lts/dubnium, ubuntu-latest) (push) Failing after 18s
versions / lts-syntax (lts/erbium, ubuntu-latest) (push) Failing after 16m34s
versions / lts-syntax (lts/fermium, ubuntu-latest) (push) Failing after 26m44s
versions / v8-canary-syntax (20-v8-canary, ubuntu-latest) (push) Failing after 17m4s
versions / v8-canary-syntax (20.0.0-v8-canary, ubuntu-latest) (push) Successful in 1m49s
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, ubuntu-latest) (push) Successful in 50s
versions / nightly-syntax (20-nightly, ubuntu-latest) (push) Successful in 48s
versions / nightly-syntax (24.0.0-nightly, ubuntu-latest) (push) Failing after 34s
versions / nightly-syntax (25-nightly, ubuntu-latest) (push) Failing after 32s
versions / rc-syntax (20.0.0-rc.1, ubuntu-latest) (push) Failing after 32s
versions / rc-syntax (22.14.0-rc.1, ubuntu-latest) (push) Failing after 33s
versions / rc-syntax (24.0.0-rc.4, ubuntu-latest) (push) Failing after 34s
versions / manifest (20.10.0, ubuntu-latest) (push) Failing after 33s
versions / manifest (22.0.0, ubuntu-latest) (push) Failing after 32s
versions / manifest (24.9.0, ubuntu-latest) (push) Failing after 34s
versions / check-latest (20, ubuntu-latest) (push) Failing after 33s
versions / check-latest (22, ubuntu-latest) (push) Failing after 1m44s
versions / check-latest (24, ubuntu-latest) (push) Successful in 38s
versions / version-file (.nvmrc, ubuntu-latest) (push) Failing after 33s
versions / version-file (.tool-versions, ubuntu-latest) (push) Failing after 32s
versions / version-file (.tool-versions-node, ubuntu-latest) (push) Failing after 32s
versions / version-file (package.json, ubuntu-latest) (push) Failing after 32s
versions / version-file-dev-engines (ubuntu-latest) (push) Failing after 33s
versions / version-file-volta (ubuntu-latest) (push) Failing after 34s
versions / version-file-volta-extends (ubuntu-latest) (push) Failing after 32s
versions / node-dist (21, ubuntu-latest) (push) Failing after 32s
versions / node-dist (23, ubuntu-latest) (push) Successful in 30s
versions / old-versions (ubuntu-latest) (push) Successful in 13s
versions / node-latest-aliases (current, ubuntu-latest) (push) Successful in 23s
versions / node-latest-aliases (latest, ubuntu-latest) (push) Successful in 22s
versions / node-latest-aliases (node, ubuntu-latest) (push) Successful in 22s
e2e-cache / Test npm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (20, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (20, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (22, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (22, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (24, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (24, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (20, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (20, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (22, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (22, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (24, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (24, windows-latest) (push) Has been cancelled
versions / local-cache (20, macos-latest) (push) Has been cancelled
versions / local-cache (20, macos-latest-large) (push) Has been cancelled
versions / local-cache (20, windows-latest) (push) Has been cancelled
versions / local-cache (22, macos-latest) (push) Has been cancelled
versions / local-cache (22, macos-latest-large) (push) Has been cancelled
versions / local-cache (22, windows-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest-large) (push) Has been cancelled
versions / local-cache (24, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/*, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/-1, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/erbium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/erbium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, windows-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (20-nightly, windows-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, windows-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (25-nightly, windows-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, windows-latest) (push) Has been cancelled
versions / manifest (20.10.0, macos-latest) (push) Has been cancelled
versions / manifest (20.10.0, macos-latest-large) (push) Has been cancelled
versions / manifest (20.10.0, windows-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest-large) (push) Has been cancelled
versions / manifest (22.0.0, windows-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest-large) (push) Has been cancelled
versions / manifest (24.9.0, windows-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest-large) (push) Has been cancelled
versions / check-latest (20, windows-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest-large) (push) Has been cancelled
versions / check-latest (22, windows-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest-large) (push) Has been cancelled
versions / check-latest (24, windows-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (push) Has been cancelled
versions / version-file (package.json, windows-latest) (push) Has been cancelled
versions / version-file-dev-engines (macos-latest) (push) Has been cancelled
versions / version-file-dev-engines (windows-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest-large) (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 (macos-latest-large) (push) Has been cancelled
versions / version-file-volta-extends (windows-latest) (push) Has been cancelled
versions / node-dist (21, macos-latest) (push) Has been cancelled
versions / node-dist (21, macos-latest-large) (push) Has been cancelled
versions / node-dist (21, windows-latest) (push) Has been cancelled
versions / node-dist (23, macos-latest) (push) Has been cancelled
versions / node-dist (23, macos-latest-large) (push) Has been cancelled
versions / node-dist (23, windows-latest) (push) Has been cancelled
versions / old-versions (macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (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, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (node, windows-latest) (push) Has been cancelled

* Add Node version validation and manifest fetch retry

* Add debug logs for expected and actual Node versions

* chore: rebuild dist

* refactor: enhance debug logging for Node installation failure

* update test cases

* Improve formatting of test cases

* revert package-lock.json
This commit is contained in:
v-jitenderpalsingh
2026-07-15 04:25:44 +05:30
committed by GitHub
parent 8207627860
commit 363be39a57
3 changed files with 225 additions and 20 deletions

View File

@@ -258,7 +258,11 @@ describe('setup-node', () => {
// @actions/exec
getExecOutputSpy = exec.getExecOutput as jest.Mock;
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
getExecOutputSpy.mockImplementation(async () => ({
stdout: 'v16.15.0',
stderr: '',
exitCode: 0
}));
});
afterEach(() => {
@@ -379,6 +383,16 @@ describe('setup-node', () => {
whichSpy.mockImplementation((cmd: any) => {
return `some/${cmd}/path`;
});
getExecOutputSpy.mockImplementation(async (cmd: string) => ({
stdout:
cmd === 'node'
? `v${resolvedVersion}`
: cmd === 'npm'
? '11.12.1'
: '4.17.1',
stderr: '',
exitCode: 0
}));
await main.run();
@@ -756,7 +770,7 @@ describe('setup-node', () => {
`Attempting to download ${versionSpec}...`
);
expect(addPathSpy).toHaveBeenCalledWith(expPath);
});
}, 10000);
});
describe('LTS version', () => {
@@ -924,8 +938,10 @@ describe('setup-node', () => {
expect(dbgSpy).toHaveBeenCalledWith(
'Getting manifest from actions/node-versions@main'
);
expect(setFailedSpy).toHaveBeenCalledWith('Unable to download manifest');
});
expect(setFailedSpy).toHaveBeenCalledWith(
`Failed to fetch a valid manifest after 3 attempts. Last error: Unable to download manifest`
);
}, 10000);
});
describe('latest alias syntax', () => {
@@ -947,10 +963,13 @@ describe('setup-node', () => {
await main.run();
// assert
expect(logSpy).toHaveBeenCalledWith('Unable to download manifest');
expect(logSpy).toHaveBeenCalledWith(
'Failed to fetch a valid manifest after 3 attempts. Last error: Unable to download manifest'
);
expect(logSpy).toHaveBeenCalledWith('getting latest node version...');
}
},
10000
);
});
@@ -1020,4 +1039,91 @@ describe('setup-node', () => {
);
}
}, 100000);
describe('manifest retry and validation', () => {
beforeEach(() => {
os.platform = 'linux';
os.arch = 'x64';
inputs['node-version'] = 'lts/erbium';
findSpy.mockImplementation(() => '');
});
it('retries fetching the manifest and succeeds on a later attempt', async () => {
let calls = 0;
getManifestSpy.mockImplementation(() => {
calls++;
if (calls < 2) {
throw new Error('transient network failure');
}
return <tc.IToolRelease[]>nodeTestManifest;
});
dlSpy.mockImplementation(async () => '/some/temp/path');
const toolPath = path.normalize('/cache/node/12.16.2/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
getExecOutputSpy.mockImplementation(async () => ({
stdout: `v${path.basename(path.dirname(toolPath))}\n`,
stderr: '',
exitCode: 0
}));
await main.run();
expect(calls).toBe(2);
expect(logSpy).toHaveBeenCalledWith('Retrying to fetch the manifest...');
expect(dbgSpy).toHaveBeenCalledWith(
`Found LTS release '12.16.2' for Node version 'lts/erbium'`
);
}, 10000);
it('rejects an empty manifest as invalid and retries', async () => {
getManifestSpy.mockImplementation(() => []);
await main.run();
expect(getManifestSpy).toHaveBeenCalledTimes(3);
expect(setFailedSpy).toHaveBeenCalledWith(
`Failed to fetch a valid manifest after 3 attempts. Last error: The manifest fetched is empty, truncated, or does not contain any valid tool release entries.`
);
}, 10000);
});
describe('node version verification', () => {
beforeEach(() => {
os.platform = 'linux';
os.arch = 'x64';
inputs['node-version'] = '12';
});
it('fails when the installed node version does not match the expected version', async () => {
const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockReturnValue(toolPath);
getExecOutputSpy.mockImplementation(async () => ({
stdout: 'v22.22.3\n',
stderr: '',
exitCode: 0
}));
await main.run();
expect(setFailedSpy).toHaveBeenCalledWith(
`Node v12.16.1 installation failed, likely due to an incomplete or corrupted download.`
);
});
it('fails when the node executable cannot be invoked', async () => {
const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockReturnValue(toolPath);
getExecOutputSpy.mockImplementation(async () => {
throw new Error('node not found');
});
await main.run();
expect(setFailedSpy).toHaveBeenCalledWith(
`Node installation failed. Node may not be installed or not on PATH: node not found`
);
});
});
});