@ -13,11 +13,11 @@ import * as auth from '../src/authutil';
import OfficialBuilds from '../src/distributions/official_builds/official_builds' ;
import { INodeVersion } from '../src/distributions/base-models' ;
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' ) ;
import nodeTestManifest from './data/versions-manifest.json' ;
import nodeTestDist from './data/node-dist-index.json' ;
import nodeTestDistNightly from './data/node-nightly-index.json' ;
import nodeTestDistRc from './data/node-rc-index.json' ;
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json' ;
describe ( 'setup-node' , ( ) = > {
let build : OfficialBuilds ;
@ -95,11 +95,11 @@ describe('setup-node', () => {
getJsonSpy . mockImplementation ( url = > {
let res : any ;
if ( url . includes ( '/rc' ) ) {
res = < INodeVersion > nodeTestDistRc ;
res = < INodeVersion [ ] > nodeTestDistRc ;
} else if ( url . includes ( '/nightly' ) ) {
res = < INodeVersion > nodeTestDistNightly ;
res = < INodeVersion [ ] > nodeTestDistNightly ;
} else {
res = < INodeVersion > nodeTestDist ;
res = < INodeVersion [ ] > nodeTestDist ;
}
return { result : res } ;
@ -156,13 +156,13 @@ describe('setup-node', () => {
async ( versionSpec , platform , expectedVersion , expectedLts ) = > {
os . platform = platform ;
os . arch = 'x64' ;
le t versions : tc.IToolRelease [ ] | null = await tc . getManifestFromRepo (
cons t versions : tc.IToolRelease [ ] | null = await tc . getManifestFromRepo (
'actions' ,
'node-versions' ,
'mocktoken'
) ;
expect ( versions ) . toBeDefined ( ) ;
le t match = await tc . findFromManifest ( versionSpec , true , versions ) ;
cons t match = await tc . findFromManifest ( versionSpec , true , versions ) ;
expect ( match ) . toBeDefined ( ) ;
expect ( match ? . version ) . toBe ( expectedVersion ) ;
expect ( ( match as any ) . lts ) . toBe ( expectedLts ) ;
@ -177,7 +177,7 @@ describe('setup-node', () => {
inputs [ 'node-version' ] = '12' ;
inputs . stable = 'true' ;
le t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
findSpy . mockImplementation ( ( ) = > toolPath ) ;
await main . run ( ) ;
@ -189,7 +189,7 @@ describe('setup-node', () => {
inSpy . mockImplementation ( name = > inputs [ name ] ) ;
le t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
findSpy . mockImplementation ( ( ) = > toolPath ) ;
await main . run ( ) ;
@ -201,16 +201,16 @@ describe('setup-node', () => {
inSpy . mockImplementation ( name = > inputs [ name ] ) ;
le t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/12.16.1/x64' ) ;
findSpy . mockImplementation ( ( ) = > toolPath ) ;
await main . run ( ) ;
le t expPath = path . join ( toolPath , 'bin' ) ;
cons t expPath = path . join ( toolPath , 'bin' ) ;
expect ( cnSpy ) . toHaveBeenCalledWith ( ` ::add-path:: ${ expPath } ${ osm . EOL } ` ) ;
} ) ;
it ( 'handles unhandled find error and reports error' , async ( ) = > {
le t errMsg = 'unhandled error message' ;
cons t errMsg = 'unhandled error message' ;
inputs [ 'node-version' ] = '12' ;
findSpy . mockImplementation ( ( ) = > {
@ -231,27 +231,27 @@ describe('setup-node', () => {
os . arch = 'x64' ;
// a version which is in the manifest
le t versionSpec = '12.16.2' ;
le t resolvedVersion = versionSpec ;
cons t versionSpec = '12.16.2' ;
cons t resolvedVersion = versionSpec ;
inputs [ 'node-version' ] = versionSpec ;
inputs [ 'always-auth' ] = false ;
inputs [ 'token' ] = 'faketoken' ;
le t expectedUrl =
cons t expectedUrl =
'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
findSpy . mockImplementation ( ( ) = > '' ) ;
dlSpy . mockImplementation ( async ( ) = > '/some/temp/path' ) ;
le t toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
exSpy . mockImplementation ( async ( ) = > '/some/other/temp/path' ) ;
cacheSpy . mockImplementation ( async ( ) = > toolPath ) ;
await main . run ( ) ;
le t expPath = path . join ( toolPath , 'bin' ) ;
cons t expPath = path . join ( toolPath , 'bin' ) ;
expect ( getExecOutputSpy ) . toHaveBeenCalledWith (
'node' ,
@ -284,7 +284,7 @@ describe('setup-node', () => {
os . arch = 'x64' ;
// a version which is not in the manifest but is in node dist
le t versionSpec = '11.15.0' ;
cons t versionSpec = '11.15.0' ;
inputs [ 'node-version' ] = versionSpec ;
inputs [ 'always-auth' ] = false ;
@ -318,7 +318,7 @@ describe('setup-node', () => {
os . platform = 'linux' ;
os . arch = 'x64' ;
le t versionSpec = '9.99.9' ;
cons t versionSpec = '9.99.9' ;
inputs [ 'node-version' ] = versionSpec ;
findSpy . mockImplementation ( ( ) = > '' ) ;
@ -336,13 +336,13 @@ describe('setup-node', () => {
} ) ;
it ( 'reports a failed download' , async ( ) = > {
le t errMsg = 'unhandled download message' ;
cons t errMsg = 'unhandled download message' ;
os . platform = 'linux' ;
os . arch = 'x64' ;
// a version which is in the manifest
le t versionSpec = '12.16.2' ;
le t resolvedVersion = versionSpec ;
cons t versionSpec = '12.16.2' ;
cons t resolvedVersion = versionSpec ;
inputs [ 'node-version' ] = versionSpec ;
inputs [ 'always-auth' ] = false ;
@ -376,7 +376,7 @@ describe('setup-node', () => {
inputs [ 'always-auth' ] = false ;
inputs [ 'token' ] = 'faketoken' ;
le t expectedUrl =
cons t expectedUrl =
arch === 'x64'
? ` https://github.com/actions/node-versions/releases/download/ ${ version } /node- ${ version } - ${ platform } - ${ arch } .zip `
: ` https://nodejs.org/dist/v ${ version } /node-v ${ version } - ${ platform } - ${ arch } . ${ fileExtension } ` ;
@ -385,7 +385,7 @@ describe('setup-node', () => {
findSpy . mockImplementation ( ( ) = > '' ) ;
dlSpy . mockImplementation ( async ( ) = > '/some/temp/path' ) ;
le t toolPath = path . normalize ( ` /cache/node/ ${ version } / ${ arch } ` ) ;
cons t toolPath = path . normalize ( ` /cache/node/ ${ version } / ${ arch } ` ) ;
exSpy . mockImplementation ( async ( ) = > '/some/other/temp/path' ) ;
cacheSpy . mockImplementation ( async ( ) = > toolPath ) ;
@ -481,7 +481,7 @@ describe('setup-node', () => {
os . arch = 'x64' ;
// a version which is not in the manifest but is in node dist
le t versionSpec = '11' ;
cons t versionSpec = '11' ;
inputs [ 'node-version' ] = versionSpec ;
inputs [ 'check-latest' ] = 'true' ;
@ -492,13 +492,13 @@ describe('setup-node', () => {
findSpy . mockImplementation ( ( ) = > '' ) ;
dlSpy . mockImplementation ( async ( ) = > '/some/temp/path' ) ;
le t toolPath = path . normalize ( '/cache/node/11.11.0/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/11.11.0/x64' ) ;
exSpy . mockImplementation ( async ( ) = > '/some/other/temp/path' ) ;
cacheSpy . mockImplementation ( async ( ) = > toolPath ) ;
await main . run ( ) ;
le t expPath = path . join ( toolPath , 'bin' ) ;
cons t expPath = path . join ( toolPath , 'bin' ) ;
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
expect ( exSpy ) . toHaveBeenCalled ( ) ;
@ -523,7 +523,7 @@ describe('setup-node', () => {
os . arch = 'x64' ;
// a version which is not in the manifest but is in node dist
le t versionSpec = '12' ;
cons t versionSpec = '12' ;
inputs [ 'node-version' ] = versionSpec ;
inputs [ 'check-latest' ] = 'true' ;
@ -537,13 +537,13 @@ describe('setup-node', () => {
} ) ;
dlSpy . mockImplementation ( async ( ) = > '/some/temp/path' ) ;
le t toolPath = path . normalize ( '/cache/node/12.11.0/x64' ) ;
cons t toolPath = path . normalize ( '/cache/node/12.11.0/x64' ) ;
exSpy . mockImplementation ( async ( ) = > '/some/other/temp/path' ) ;
cacheSpy . mockImplementation ( async ( ) = > toolPath ) ;
await main . run ( ) ;
le t expPath = path . join ( toolPath , 'bin' ) ;
cons t expPath = path . join ( toolPath , 'bin' ) ;
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
expect ( exSpy ) . toHaveBeenCalled ( ) ;