Don't reverse the manifest

This commit is contained in:
Jack Bates 2022-05-30 15:58:29 -07:00
parent c4f9da006e
commit e8fa6b0ff5
4 changed files with 195 additions and 171 deletions

View File

@ -3,50 +3,50 @@
"version": "14.0.0", "version": "14.0.0",
"stable": true, "stable": true,
"lts": "Fermium", "lts": "Fermium",
"release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200423.30", "release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200507.99",
"files": [ "files": [
{ {
"filename": "node-14.0.0-darwin-x64.tar.gz", "filename": "node-14.0.0-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-14.0.0-linux-x64.tar.gz", "filename": "node-14.0.0-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz"
}, },
{ {
"filename": "node-14.0.0-win32-x64.zip", "filename": "node-14.0.0-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-win32-x64.7z"
} }
] ]
}, },
{ {
"version": "13.13.0", "version": "13.13.0",
"stable": true, "stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200423.29", "release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200507.97",
"files": [ "files": [
{ {
"filename": "node-13.13.0-darwin-x64.tar.gz", "filename": "node-13.13.0-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-13.13.0-linux-x64.tar.gz", "filename": "node-13.13.0-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-linux-x64.tar.gz"
}, },
{ {
"filename": "node-13.13.0-win32-x64.zip", "filename": "node-13.13.0-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-win32-x64.7z"
} }
] ]
}, },
@ -54,25 +54,51 @@
"version": "12.16.2", "version": "12.16.2",
"stable": true, "stable": true,
"lts": "Erbium", "lts": "Erbium",
"release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200423.28", "release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200507.95",
"files": [ "files": [
{ {
"filename": "node-12.16.2-darwin-x64.tar.gz", "filename": "node-12.16.2-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-12.16.2-linux-x64.tar.gz", "filename": "node-12.16.2-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz"
}, },
{ {
"filename": "node-12.16.2-win32-x64.zip", "filename": "node-12.16.2-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-win32-x64.7z"
}
]
},
{
"version": "12.0.0",
"stable": true,
"lts": "Erbium",
"release_url": "https://github.com/actions/node-versions/releases/tag/12.0.0-20200507.71",
"files": [
{
"filename": "node-12.0.0-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-darwin-x64.tar.gz"
},
{
"filename": "node-12.0.0-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-linux-x64.tar.gz"
},
{
"filename": "node-12.0.0-win32-x64.7z",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-win32-x64.7z"
} }
] ]
}, },
@ -80,25 +106,25 @@
"version": "10.20.1", "version": "10.20.1",
"stable": true, "stable": true,
"lts": "Dubnium", "lts": "Dubnium",
"release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200423.27", "release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200507.70",
"files": [ "files": [
{ {
"filename": "node-10.20.1-darwin-x64.tar.gz", "filename": "node-10.20.1-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-10.20.1-linux-x64.tar.gz", "filename": "node-10.20.1-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-linux-x64.tar.gz"
}, },
{ {
"filename": "node-10.20.1-win32-x64.zip", "filename": "node-10.20.1-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-win32-x64.7z"
} }
] ]
}, },
@ -106,25 +132,25 @@
"version": "8.17.0", "version": "8.17.0",
"stable": true, "stable": true,
"lts": "Carbon", "lts": "Carbon",
"release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200423.26", "release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200507.37",
"files": [ "files": [
{ {
"filename": "node-8.17.0-darwin-x64.tar.gz", "filename": "node-8.17.0-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-8.17.0-linux-x64.tar.gz", "filename": "node-8.17.0-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-linux-x64.tar.gz"
}, },
{ {
"filename": "node-8.17.0-win32-x64.zip", "filename": "node-8.17.0-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-win32-x64.7z"
} }
] ]
}, },
@ -132,25 +158,25 @@
"version": "6.17.1", "version": "6.17.1",
"stable": true, "stable": true,
"lts": "Boron", "lts": "Boron",
"release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200423.25", "release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200529.2",
"files": [ "files": [
{ {
"filename": "node-6.17.1-darwin-x64.tar.gz", "filename": "node-6.17.1-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-darwin-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-darwin-x64.tar.gz"
}, },
{ {
"filename": "node-6.17.1-linux-x64.tar.gz", "filename": "node-6.17.1-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-linux-x64.tar.gz" "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-linux-x64.tar.gz"
}, },
{ {
"filename": "node-6.17.1-win32-x64.zip", "filename": "node-6.17.1-win32-x64.7z",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-win32-x64.zip" "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-win32-x64.7z"
} }
] ]
} }

View File

@ -77,9 +77,9 @@ describe('setup-node', () => {
authSpy.mockImplementation(() => {}); authSpy.mockImplementation(() => {});
// gets // gets
getManifestSpy.mockImplementation(() => [ getManifestSpy.mockImplementation(
...(<tc.IToolRelease[]>nodeTestManifest) () => <tc.IToolRelease[]>nodeTestManifest
]); );
getDistSpy.mockImplementation(() => <im.INodeVersion>nodeTestDist); getDistSpy.mockImplementation(() => <im.INodeVersion>nodeTestDist);
// writes // writes
@ -126,7 +126,7 @@ describe('setup-node', () => {
'mocktoken' 'mocktoken'
); );
expect(versions).toBeDefined(); expect(versions).toBeDefined();
expect(versions?.length).toBe(6); expect(versions?.length).toBe(7);
}); });
it('can mock dist versions', async () => { it('can mock dist versions', async () => {
@ -228,7 +228,7 @@ describe('setup-node', () => {
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = let expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -266,7 +266,7 @@ describe('setup-node', () => {
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = let expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -435,7 +435,7 @@ describe('setup-node', () => {
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
const expectedUrl = const expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
await main.run(); await main.run();
@ -718,17 +718,17 @@ describe('setup-node', () => {
[ [
'erbium', 'erbium',
'12.16.2', '12.16.2',
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz' 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
], ],
[ [
'*', '*',
'14.0.0', '14.0.0',
'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz' 'https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz'
], ],
[ [
'-1', '-1',
'12.16.2', '12.16.2',
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz' 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
] ]
])( ])(
'find latest LTS version and install it from manifest (lts/%s)', 'find latest LTS version and install it from manifest (lts/%s)',

5
dist/setup/index.js vendored
View File

@ -70626,8 +70626,6 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
core.info('Attempt to resolve LTS alias from manifest...'); core.info('Attempt to resolve LTS alias from manifest...');
// No try-catch since it's not possible to resolve LTS alias without manifest // No try-catch since it's not possible to resolve LTS alias without manifest
manifest = yield getManifest(auth); manifest = yield getManifest(auth);
// Reverse it so later Object.fromEntries() gets the latest version of each LTS
manifest.reverse();
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest); versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
} }
if (isLatestSyntax(versionSpec)) { if (isLatestSyntax(versionSpec)) {
@ -70762,7 +70760,8 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
const n = Number(alias); const n = Number(alias);
const aliases = Object.fromEntries(manifest const aliases = Object.fromEntries(manifest
.filter(x => x.lts && x.stable === stable) .filter(x => x.lts && x.stable === stable)
.map(x => [x.lts.toLowerCase(), x])); .map(x => [x.lts.toLowerCase(), x])
.reverse());
const numbered = Object.values(aliases); const numbered = Object.values(aliases);
const release = alias === '*' const release = alias === '*'
? numbered[numbered.length - 1] ? numbered[numbered.length - 1]

View File

@ -46,8 +46,6 @@ export async function getNode(
// No try-catch since it's not possible to resolve LTS alias without manifest // No try-catch since it's not possible to resolve LTS alias without manifest
manifest = await getManifest(auth); manifest = await getManifest(auth);
// Reverse it so later Object.fromEntries() gets the latest version of each LTS
manifest.reverse();
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest); versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
} }
@ -231,6 +229,7 @@ function resolveLtsAliasFromManifest(
manifest manifest
.filter(x => x.lts && x.stable === stable) .filter(x => x.lts && x.stable === stable)
.map(x => [x.lts!.toLowerCase(), x]) .map(x => [x.lts!.toLowerCase(), x])
.reverse()
); );
const numbered = Object.values(aliases); const numbered = Object.values(aliases);
const release = const release =