Reuse manifest code
This commit is contained in:
parent
d9ce83b637
commit
c2dfe2df98
@ -399,8 +399,9 @@ describe('setup-node', () => {
|
|||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
'Attempt to resolve the latest version from manifest...'
|
'Attempt to resolve the latest version from manifest...'
|
||||||
);
|
);
|
||||||
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith(
|
expect(dbgSpy).not.toHaveBeenCalledWith(
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -422,8 +423,9 @@ describe('setup-node', () => {
|
|||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempt to resolve the latest version from manifest...'
|
'Attempt to resolve the latest version from manifest...'
|
||||||
);
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
@ -449,8 +451,9 @@ describe('setup-node', () => {
|
|||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempt to resolve the latest version from manifest...'
|
'Attempt to resolve the latest version from manifest...'
|
||||||
);
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
@ -488,8 +491,9 @@ describe('setup-node', () => {
|
|||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempt to resolve the latest version from manifest...'
|
'Attempt to resolve the latest version from manifest...'
|
||||||
);
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
`Failed to resolve version ${versionSpec} from manifest`
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
@ -567,9 +571,7 @@ describe('setup-node', () => {
|
|||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith(
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
||||||
);
|
);
|
||||||
@ -608,9 +610,7 @@ describe('setup-node', () => {
|
|||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith(
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
||||||
);
|
);
|
||||||
@ -649,9 +649,7 @@ describe('setup-node', () => {
|
|||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith(
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias '*' for Node version 'lts/*'`
|
`LTS alias '*' for Node version 'lts/*'`
|
||||||
);
|
);
|
||||||
@ -690,9 +688,7 @@ describe('setup-node', () => {
|
|||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith(
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias '*' for Node version 'lts/*'`
|
`LTS alias '*' for Node version 'lts/*'`
|
||||||
);
|
);
|
||||||
|
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -13111,9 +13111,8 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
|
|||||||
let osArch = translateArchToDistUrl(arch);
|
let osArch = translateArchToDistUrl(arch);
|
||||||
if (isLtsAlias(versionSpec)) {
|
if (isLtsAlias(versionSpec)) {
|
||||||
core.info('Attempt to resolve LTS alias from manifest...');
|
core.info('Attempt to resolve LTS alias from manifest...');
|
||||||
core.debug('Getting manifest from actions/node-versions@main');
|
|
||||||
// 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 tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
|
manifest = yield getManifest(auth);
|
||||||
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
||||||
}
|
}
|
||||||
if (checkLatest) {
|
if (checkLatest) {
|
||||||
@ -13228,6 +13227,10 @@ exports.getNode = getNode;
|
|||||||
function isLtsAlias(versionSpec) {
|
function isLtsAlias(versionSpec) {
|
||||||
return versionSpec.startsWith('lts');
|
return versionSpec.startsWith('lts');
|
||||||
}
|
}
|
||||||
|
function getManifest(auth) {
|
||||||
|
core.debug('Getting manifest from actions/node-versions@main');
|
||||||
|
return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
|
||||||
|
}
|
||||||
function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
|
function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
|
||||||
var _a;
|
var _a;
|
||||||
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||||
@ -13249,8 +13252,8 @@ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchTo
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let info = null;
|
let info = null;
|
||||||
if (!manifest) {
|
if (!manifest) {
|
||||||
core.debug('No manifest cached, getting manifest from actions/node-versions@main');
|
core.debug('No manifest cached');
|
||||||
manifest = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
|
manifest = yield getManifest(auth);
|
||||||
}
|
}
|
||||||
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
|
@ -42,14 +42,10 @@ export async function getNode(
|
|||||||
|
|
||||||
if (isLtsAlias(versionSpec)) {
|
if (isLtsAlias(versionSpec)) {
|
||||||
core.info('Attempt to resolve LTS alias from manifest...');
|
core.info('Attempt to resolve LTS alias from manifest...');
|
||||||
core.debug('Getting manifest from actions/node-versions@main');
|
|
||||||
// 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 tc.getManifestFromRepo(
|
manifest = await getManifest(auth);
|
||||||
'actions',
|
|
||||||
'node-versions',
|
|
||||||
auth,
|
|
||||||
'main'
|
|
||||||
);
|
|
||||||
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +196,11 @@ function isLtsAlias(versionSpec: string): boolean {
|
|||||||
return versionSpec.startsWith('lts');
|
return versionSpec.startsWith('lts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getManifest(auth: string | undefined): Promise<tc.IToolRelease[]> {
|
||||||
|
core.debug('Getting manifest from actions/node-versions@main');
|
||||||
|
return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
|
||||||
|
}
|
||||||
|
|
||||||
function resolveLtsAliasFromManifest(
|
function resolveLtsAliasFromManifest(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
@ -245,16 +246,8 @@ async function getInfoFromManifest(
|
|||||||
): Promise<INodeVersionInfo | null> {
|
): Promise<INodeVersionInfo | null> {
|
||||||
let info: INodeVersionInfo | null = null;
|
let info: INodeVersionInfo | null = null;
|
||||||
if (!manifest) {
|
if (!manifest) {
|
||||||
core.debug(
|
core.debug('No manifest cached');
|
||||||
'No manifest cached, getting manifest from actions/node-versions@main'
|
manifest = await getManifest(auth);
|
||||||
);
|
|
||||||
|
|
||||||
manifest = await tc.getManifestFromRepo(
|
|
||||||
'actions',
|
|
||||||
'node-versions',
|
|
||||||
auth,
|
|
||||||
'main'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const rel = await tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
const rel = await tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
||||||
|
Loading…
Reference in New Issue
Block a user