Add v8 canary unit tests

This commit is contained in:
Sergey Dolin 2022-11-09 20:41:33 +01:00
parent 9c158b3dbd
commit 588599b944
3 changed files with 811 additions and 9 deletions

View file

@ -0,0 +1,537 @@
[
{
"version": "v20.0.0-v8-canary20221103f7e2421e91",
"date": "2022-11-03",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.138.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary202211026bf85d0fb4",
"date": "2022-11-02",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.130.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221101e50e45c9f8",
"date": "2022-11-01",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.129.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary202210311b1e675ad0",
"date": "2022-10-31",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.125.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221030fefe1c0879",
"date": "2022-10-30",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.125.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary202210293881e51ba2",
"date": "2022-10-29",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.122.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary202210286fe49d2a49",
"date": "2022-10-28",
"files": [
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.112.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221027c470b3108c",
"date": "2022-10-27",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.101.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221026c24f7d1e4a",
"date": "2022-10-26",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.88.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221025b063237e20",
"date": "2022-10-25",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.73.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary2022102454996f930f",
"date": "2022-10-24",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.61.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary2022102310ff1e5a8d",
"date": "2022-10-23",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.61.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221022e83bcb6c41",
"date": "2022-10-22",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "8.19.2",
"v8": "10.9.60.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221021f6d5f347fa",
"date": "2022-10-21",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip"
],
"npm": "8.19.2",
"v8": "10.9.48.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221020f78c149307",
"date": "2022-10-20",
"files": [
"headers",
"linux-arm64",
"linux-armv7l",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip"
],
"npm": "8.19.2",
"v8": "10.9.38.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v20.0.0-v8-canary20221019d52c76f76e",
"date": "2022-10-19",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"osx-arm64-tar",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip"
],
"npm": "8.19.2",
"v8": "10.9.27.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v19.0.0-v8-canary202210187d6960f23f",
"date": "2022-10-18",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip"
],
"npm": "8.19.2",
"v8": "10.9.12.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
},
{
"version": "v19.0.0-v8-canary202210172ec229fc56",
"date": "2022-10-17",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-arm64-tar",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip"
],
"npm": "8.19.2",
"v8": "10.9.6.0",
"uv": "1.43.0",
"zlib": "1.2.11",
"openssl": "3.0.5+quic",
"modules": "112",
"lts": false,
"security": false
}
]

View file

@ -1,10 +1,10 @@
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as tc from '@actions/tool-cache';
import * as httpm from '@actions/http-client';
import * as exec from '@actions/exec';
import * as im from '../src/installer';
import * as cache from '@actions/cache';
import * as httpm from '@actions/http-client';
import fs from 'fs';
import cp from 'child_process';
import osm from 'os';
@ -17,6 +17,7 @@ const nodeTestManifest = require('./data/versions-manifest.json');
const nodeTestDist = require('./data/node-dist-index.json');
const nodeTestDistNightly = require('./data/node-nightly-index.json');
const nodeTestDistRc = require('./data/node-rc-index.json');
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json');
describe('setup-node', () => {
let inputs = {} as any;
@ -71,6 +72,7 @@ describe('setup-node', () => {
exSpy = jest.spyOn(tc, 'extractTar');
cacheSpy = jest.spyOn(tc, 'cacheDir');
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
// @ts-ignore
getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
parseNodeVersionSpy = jest.spyOn(im, 'parseNodeVersionFile');
@ -137,7 +139,7 @@ describe('setup-node', () => {
});
warningSpy.mockImplementation(msg => {
// uncomment to debug
// process.stderr.write('log:' + line + '\n');
// process.stderr.write('log:' + msg + '\n');
});
// @actions/exec
@ -1252,6 +1254,268 @@ describe('setup-node', () => {
}
);
});
describe('setup-node v8 canary unit tests', () => {
it('is not LTS alias', async () => {
const versionSpec = 'v99.0.0-v8-canary';
// @ts-ignore
const isLtsAlias = im.isLtsAlias(versionSpec);
expect(isLtsAlias).toBeFalsy();
});
it('is not isLatestSyntax', async () => {
const versionSpec = 'v99.0.0-v8-canary';
// @ts-ignore
const isLatestSyntax = im.isLatestSyntax(versionSpec);
expect(isLatestSyntax).toBeFalsy();
});
it('dist url to be https://nodejs.org/download/v8-canary for input versionSpec', () => {
const versionSpec = 'v99.0.0-v8-canary';
// @ts-ignore
const url = im.getNodejsDistUrl(versionSpec);
expect(url).toBe('https://nodejs.org/download/v8-canary');
});
it('dist url to be https://nodejs.org/download/v8-canary for full versionSpec', () => {
const versionSpec = 'v20.0.0-v8-canary20221103f7e2421e91';
// @ts-ignore
const url = im.getNodejsDistUrl(versionSpec);
expect(url).toBe('https://nodejs.org/download/v8-canary');
});
it('v20-v8-canary should match any minor and patch version', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20-v8-canary');
expect(matcher('v20.0.0-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.0.1-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.0-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.1-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.0.0-v8-canary202211026bf85d0fb4')).toBeTruthy();
});
it('v20-v8-canary should not match v21.x & v19.x', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20-v8-canary');
expect(matcher('v21.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v21.1.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v21.1.1-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v19.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v19.1.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v19.1.-v8-canary20221103f7e2421e91')).toBeFalsy();
});
it('v20.1-v8-canary should match any v20.1 patch version and minor above or eq v20.1', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20.1-v8-canary');
expect(matcher('v20.1.0-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.1-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.0-v8-canary202211026bf85d0fb4')).toBeTruthy();
expect(matcher('v20.2.0-v8-canary20221103f7e2421e91')).toBeTruthy();
});
it('v20.2-v8-canary should not match v21.x, v19.x, and v20 minor less v20.2', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20.2-v8-canary');
expect(matcher('v20.1.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v21.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v19.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
});
it('v20.1.1-v8-canary should match v20.1.x patch versions above or eq v20.1.1', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20.1.1-v8-canary');
expect(matcher('v20.1.1-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.2-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.2.0-v8-canary20221103f7e2421e91')).toBeTruthy();
});
it('v20.1.1-v8-canary should match patch versions with any canary timestamp', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20.1.1-v8-canary');
expect(matcher('v20.1.1-v8-canary20221103f7e2421e91')).toBeTruthy();
expect(matcher('v20.1.1-v8-canary202211026bf85d0fb4')).toBeTruthy();
});
it('v20.1.1-v8-canary should not match any other minor versions and patch versions below v20.1.1', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher('v20.1.1-v8-canary');
expect(matcher('v20.1.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v21.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
expect(matcher('v19.0.0-v8-canary20221103f7e2421e91')).toBeFalsy();
});
it('v20.0.0-v8-canary20221103f7e2421e91 should match only v20.0.0-v8-canary20221103f7e2421e91', () => {
// @ts-ignore
const matcher = im.evaluateCanaryMatcher(
'v20.0.0-v8-canary20221103f7e2421e91'
);
expect(matcher('v20.0.0-v8-canary20221103f7e2421e91')).toBeTruthy();
// see https://github.com/actions/setup-node/blob/00e1b6691b40cce14b5078cb411dd1ec7dab07f7/__tests__/verify-node.sh#L10
expect(matcher('v20.0.0-v8-canary202211026bf85d0fb4')).toBeFalsy();
});
it('v8 canary evaluateVersions without timestamp', () => {
const versions = [
'v20.0.0-v8-canary20221103f7e2421e91',
'v20.0.1-v8-canary20221103f7e2421e91',
'v20.1.0-v8-canary20221103f7e2421e91',
'v20.1.1-v8-canary20221103f7e2421e91',
'v21.1.0-v8-canary20221103f7e2421e91',
'v19.1.0-v8-canary20221103f7e2421e91'
];
// @ts-ignore
const version = im.evaluateVersions(versions, 'v20-v8-canary');
expect(version).toBe('v20.1.1-v8-canary20221103f7e2421e91');
});
it('v8 canary evaluateVersions with timestamp', () => {
const versions = [
'v20.0.0-v8-canary20221103f7e2421e91',
'v20.0.1-v8-canary20221103f7e2421e91',
'v20.0.1-v8-canary20221103f7e2421e92',
'v20.0.1-v8-canary20221103f7e2421e93',
'v20.0.2-v8-canary20221103f7e2421e91'
];
// @ts-ignore
const version = im.evaluateVersions(
versions,
'v20.0.1-v8-canary20221103f7e2421e92'
);
expect(version).toBe('v20.0.1-v8-canary20221103f7e2421e92');
});
it('v8 canary queryDistForMatch', async () => {
jest.spyOn(osm, 'platform').mockImplementationOnce(() => 'linux');
// @ts-ignore
const version = await im.queryDistForMatch(
'v20-v8-canary',
'x64',
nodeV8CanaryTestDist
);
expect(version).toBe('v20.0.0-v8-canary20221103f7e2421e91');
});
});
describe('setup-node v8 canary e2e tests', () => {
// @actions/http-client
let getDistIndexJsonSpy: jest.SpyInstance;
let findAllVersionSpy: jest.SpyInstance;
beforeEach(() => {
// @actions/http-client
getDistIndexJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
getDistIndexJsonSpy.mockImplementation(() => ({
result: nodeV8CanaryTestDist
}));
// @actions/tool-cache
findAllVersionSpy = jest.spyOn(tc, 'findAllVersions');
});
it('v8 canary setup node flow without cached', async () => {
let versionSpec = 'v20-v8-canary';
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
os.platform = 'linux';
os.arch = 'x64';
findAllVersionSpy.mockImplementation(() => []);
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/12.16.2/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
await main.run();
expect(dbgSpy.mock.calls[0][0]).toBe('requested v8 canary distribution');
expect(dbgSpy.mock.calls[1][0]).toBe('evaluating 17 versions');
expect(dbgSpy.mock.calls[2][0]).toBe(
'matched: v20.0.0-v8-canary20221103f7e2421e91'
);
expect(logSpy.mock.calls[0][0]).toBe(
'getting v8-canary node version v20.0.0-v8-canary20221103f7e2421e91...'
);
expect(logSpy.mock.calls[1][0]).toBe(
'Attempt to find existing version in cache...'
);
expect(dbgSpy.mock.calls[3][0]).toBe('evaluating 0 versions');
expect(dbgSpy.mock.calls[4][0]).toBe('match not found');
expect(logSpy.mock.calls[2][0]).toBe(
'Attempting to download v20.0.0-v8-canary20221103f7e2421e91...'
);
expect(dbgSpy.mock.calls[5][0]).toBe('No manifest cached');
expect(dbgSpy.mock.calls[6][0]).toBe(
'Getting manifest from actions/node-versions@main'
);
expect(dbgSpy.mock.calls[7][0].slice(0, 6)).toBe('check ');
expect(dbgSpy.mock.calls[13][0].slice(0, 6)).toBe('check ');
expect(logSpy.mock.calls[3][0]).toBe(
'Not found in manifest. Falling back to download directly from Node'
);
expect(dbgSpy.mock.calls[14][0]).toBe('evaluating 17 versions');
expect(dbgSpy.mock.calls[15][0]).toBe(
'matched: v20.0.0-v8-canary20221103f7e2421e91'
);
expect(dbgSpy.mock.calls[16][0]).toBe('requested v8 canary distribution');
expect(logSpy.mock.calls[4][0]).toBe(
'Acquiring 20.0.0-v8-canary20221103f7e2421e91 - x64 from https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
);
expect(dlSpy).toHaveBeenCalledTimes(1);
expect(exSpy).toHaveBeenCalledTimes(1);
expect(cacheSpy).toHaveBeenCalledTimes(1);
});
it('v8 canary setup node flow with cached', async () => {
let versionSpec = 'v20-v8-canary';
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
os.platform = 'linux';
os.arch = 'x64';
findAllVersionSpy.mockImplementation(() => [
'v20.0.0-v8-canary20221103f7e2421e91'
]);
await main.run();
expect(dbgSpy.mock.calls[0][0]).toBe('requested v8 canary distribution');
expect(dbgSpy.mock.calls[1][0]).toBe('evaluating 17 versions');
expect(dbgSpy.mock.calls[2][0]).toBe(
'matched: v20.0.0-v8-canary20221103f7e2421e91'
);
expect(logSpy.mock.calls[0][0]).toBe(
'getting v8-canary node version v20.0.0-v8-canary20221103f7e2421e91...'
);
expect(logSpy.mock.calls[1][0]).toBe(
'Attempt to find existing version in cache...'
);
expect(dbgSpy.mock.calls[3][0]).toBe('evaluating 1 versions');
expect(dbgSpy.mock.calls[4][0]).toBe(
'matched: v20.0.0-v8-canary20221103f7e2421e91'
);
expect(logSpy.mock.calls[2][0]).toBe(
'Found in cache @ v20.0.0-v8-canary20221103f7e2421e91'
);
expect(cnSpy.mock.calls[1][0].trim()).toBe(
`::add-path::v20.0.0-v8-canary20221103f7e2421e91${path.sep}bin`
);
expect(dlSpy).not.toHaveBeenCalled();
expect(exSpy).not.toHaveBeenCalled();
expect(cacheSpy).not.toHaveBeenCalled();
});
});
});
describe('helper methods', () => {

View file

@ -233,12 +233,10 @@ function findNightlyVersionInHostedToolcache(
osArch: string
) {
const foundAllVersions = tc.findAllVersions('node', osArch);
const version = evaluateVersions(foundAllVersions, versionsSpec);
return version;
return evaluateVersions(foundAllVersions, versionsSpec);
}
function isLtsAlias(versionSpec: string): boolean {
export function isLtsAlias(versionSpec: string): boolean {
return versionSpec.startsWith('lts/');
}
@ -247,7 +245,7 @@ function getManifest(auth: string | undefined): Promise<tc.IToolRelease[]> {
return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
}
function resolveLtsAliasFromManifest(
export function resolveLtsAliasFromManifest(
versionSpec: string,
stable: boolean,
manifest: INodeRelease[]
@ -421,7 +419,10 @@ function evaluateNightlyVersions(
}
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
function evaluateVersions(versions: string[], versionSpec: string): string {
export function evaluateVersions(
versions: string[],
versionSpec: string
): string {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
@ -622,7 +623,7 @@ export function parseNodeVersionFile(contents: string): string {
return nodeVersion as string;
}
function isLatestSyntax(versionSpec): boolean {
export function isLatestSyntax(versionSpec): boolean {
return ['current', 'latest', 'node'].includes(versionSpec);
}