Compare commits
35 Commits
master
...
users/eric
Author | SHA1 | Date |
---|---|---|
eric sciple | 1c0119c056 | |
eric sciple | 095ab69cb7 | |
eric sciple | e7b5a7c545 | |
eric sciple | e37249e03d | |
Bryan MacFarlane | 2ae9264901 | |
Bryan MacFarlane | 2a0fbec10d | |
Bryan MacFarlane | 0a9e8b1d0f | |
Bryan MacFarlane | a875da2574 | |
Bryan MacFarlane | a80a170798 | |
Bryan MacFarlane | 5e7b076d00 | |
Bryan MacFarlane | 8e221092f3 | |
Bryan MacFarlane | 6a1b66a606 | |
Bryan MacFarlane | 9fcef3fcea | |
Bryan MacFarlane | beb2155295 | |
Bryan MacFarlane | 11f920585c | |
Bryan MacFarlane | dd6f5ab66c | |
Bryan MacFarlane | f7c5caf605 | |
Bryan MacFarlane | a4145577de | |
Bryan MacFarlane | 42746a4f3c | |
Bryan MacFarlane | c8617ac6ae | |
Bryan MacFarlane | 1b2d431484 | |
Bryan MacFarlane | 5e5ef8fd55 | |
Bryan MacFarlane | 2fb08c4f31 | |
Bryan MacFarlane | e3ad114cc4 | |
Bryan MacFarlane | 501fd29d66 | |
Bryan MacFarlane | 2bdb2ab1c9 | |
Bryan MacFarlane | ed3a918d25 | |
Bryan MacFarlane | efab84ad3c | |
Bryan MacFarlane | 8a1d983ace | |
Bryan MacFarlane | 22c0aea623 | |
Bryan MacFarlane | 1c2f59fb67 | |
Bryan MacFarlane | ec6092f7d2 | |
Bryan MacFarlane | 889def385d | |
Bryan MacFarlane | 8885b7194e | |
Bryan MacFarlane | ecf0ce62f9 |
|
@ -16,7 +16,7 @@ jobs:
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup node 12
|
- name: Setup node 12
|
||||||
|
|
|
@ -12,88 +12,36 @@ on:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
local-cache:
|
versions:
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
node-version: [10, 12, 14]
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Node
|
# test version that falls through to node dist
|
||||||
|
- name: Setup node 11 from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: 11
|
||||||
- name: Verify node and npm
|
- name: Verify node and npm
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh 11
|
||||||
shell: bash
|
# test old versions which didn't have npm and layout different
|
||||||
|
|
||||||
manifest:
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
node-version: [10.15, 12.16.0, 14.2.0]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup Node
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
- name: Verify node and npm
|
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
check-latest:
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
node-version: [10, 11, 12, 14]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup Node and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
check-latest: true
|
|
||||||
- name: Verify node and npm
|
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
node-dist:
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
node-version: [11, 13]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup Node from dist
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
- name: Verify node and npm
|
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
old-versions:
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
# test old versions which didn't have npm and layout different
|
|
||||||
- name: Setup node 0.12.18 from dist
|
- name: Setup node 0.12.18 from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version: 0.12.18
|
node-version: 0.12.18
|
||||||
- name: Verify node
|
- name: Verify node
|
||||||
run: __tests__/verify-node.sh 0.12.18 SKIP_NPM
|
shell: bash
|
||||||
shell: bash
|
run: __tests__/verify-node.sh 0.12.18 SKIP_NPM
|
||||||
|
# test version from node manifest
|
||||||
|
- name: Setup node 12.16.2 from manifest
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: 12.16.2
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh 12
|
||||||
|
|
42
README.md
42
README.md
|
@ -1,30 +1,13 @@
|
||||||
# setup-node
|
# setup-node
|
||||||
|
|
||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://github.com/actions/setup-node/actions?query=workflow%3Abuild-test"><img alt="build-test status" src="https://github.com/actions/setup-node/workflows/build-test/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aversions"><img alt="versions status" src="https://github.com/actions/setup-node/workflows/versions/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aproxy"><img alt="proxy status" src="https://github.com/actions/setup-node/workflows/proxy/badge.svg"></a>
|
<a href="https://github.com/actions/setup-node"><img alt="GitHub Actions status" src="https://github.com/actions/setup-node/workflows/Main%20workflow/badge.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
This action sets by node environment for use in actions by:
|
This action sets by node environment for use in actions by:
|
||||||
|
|
||||||
- optionally downloading and caching a version of node - npm by version spec and add to PATH
|
- optionally downloading and caching a version of node - npm by version spec and add to PATH
|
||||||
- registering problem matchers for error output
|
- registering problem matchers for error output
|
||||||
- configuring authentication for GPR or npm
|
|
||||||
|
|
||||||
# v2-beta
|
|
||||||
|
|
||||||
A beta release which adds reliability for pulling node distributions from a cache of node releases is available by referencing the `v2-beta` tag.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2-beta
|
|
||||||
with:
|
|
||||||
node-version: '12'
|
|
||||||
```
|
|
||||||
|
|
||||||
The action will first check the local cache for a semver match. The hosted images have been updated with the latest of each LTS from v8, v10, v12, and v14. `self-hosted` machines will benefit from the cache as well only downloading once. The action will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
|
|
||||||
|
|
||||||
The `node-version` input is optional. If not supplied, the node version that is PATH will be used. However, this action will still register problem matchers and support auth features. So setting up the node environment is still a valid scenario without downloading and caching versions.
|
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
@ -36,26 +19,7 @@ steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: '12'
|
node-version: '10.x'
|
||||||
- run: npm install
|
|
||||||
- run: npm test
|
|
||||||
```
|
|
||||||
|
|
||||||
Check latest version:
|
|
||||||
|
|
||||||
In the basic example above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of node from the local cache. For information regarding locally cached versions of Node on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). The local version of Node in cache gets updated every couple of weeks. If unable to find a specific version in the cache, the action will then attempt to download a version of Node. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node is always used.
|
|
||||||
|
|
||||||
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a version of Node will then be downloaded. Set `check-latest` to `true` it you want the most up-to-date version of Node to always be used.
|
|
||||||
|
|
||||||
> Setting `check-latest` to `true` has performance implications as downloading versions of Node is slower than using cached versions
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '12'
|
|
||||||
check-latest: true
|
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,7 +8,6 @@ import path from 'path';
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as im from '../src/installer';
|
import * as im from '../src/installer';
|
||||||
import * as auth from '../src/authutil';
|
import * as auth from '../src/authutil';
|
||||||
import {context} from '@actions/github';
|
|
||||||
|
|
||||||
let nodeTestManifest = require('./data/versions-manifest.json');
|
let nodeTestManifest = require('./data/versions-manifest.json');
|
||||||
let nodeTestDist = require('./data/node-dist-index.json');
|
let nodeTestDist = require('./data/node-dist-index.json');
|
||||||
|
@ -25,7 +24,6 @@ describe('setup-node', () => {
|
||||||
let findSpy: jest.SpyInstance;
|
let findSpy: jest.SpyInstance;
|
||||||
let cnSpy: jest.SpyInstance;
|
let cnSpy: jest.SpyInstance;
|
||||||
let logSpy: jest.SpyInstance;
|
let logSpy: jest.SpyInstance;
|
||||||
let warningSpy: jest.SpyInstance;
|
|
||||||
let getManifestSpy: jest.SpyInstance;
|
let getManifestSpy: jest.SpyInstance;
|
||||||
let getDistSpy: jest.SpyInstance;
|
let getDistSpy: jest.SpyInstance;
|
||||||
let platSpy: jest.SpyInstance;
|
let platSpy: jest.SpyInstance;
|
||||||
|
@ -79,9 +77,8 @@ describe('setup-node', () => {
|
||||||
|
|
||||||
// writes
|
// writes
|
||||||
cnSpy = jest.spyOn(process.stdout, 'write');
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
logSpy = jest.spyOn(core, 'info');
|
logSpy = jest.spyOn(console, 'log');
|
||||||
dbgSpy = jest.spyOn(core, 'debug');
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
warningSpy = jest.spyOn(core, 'warning');
|
|
||||||
cnSpy.mockImplementation(line => {
|
cnSpy.mockImplementation(line => {
|
||||||
// uncomment to debug
|
// uncomment to debug
|
||||||
// process.stderr.write('write:' + line + '\n');
|
// process.stderr.write('write:' + line + '\n');
|
||||||
|
@ -336,154 +333,4 @@ describe('setup-node', () => {
|
||||||
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('check-latest flag', () => {
|
|
||||||
it('use local version and dont check manifest if check-latest is not specified', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
inputs['node-version'] = '12';
|
|
||||||
inputs['check-latest'] = 'false';
|
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
|
||||||
findSpy.mockReturnValue(toolPath);
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve the latest version from manifest...'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('check latest version and resolve it from local cache', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
inputs['node-version'] = '12';
|
|
||||||
inputs['check-latest'] = 'true';
|
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
|
||||||
findSpy.mockReturnValue(toolPath);
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve the latest version from manifest...'
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('check latest version and install it from manifest', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
inputs['node-version'] = '12';
|
|
||||||
inputs['check-latest'] = 'true';
|
|
||||||
|
|
||||||
findSpy.mockImplementation(() => '');
|
|
||||||
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);
|
|
||||||
const expectedUrl =
|
|
||||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve the latest version from manifest...'
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Acquiring 12.16.2 from ${expectedUrl}`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fallback to dist if version if not found in manifest', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
// a version which is not in the manifest but is in node dist
|
|
||||||
let versionSpec = '11';
|
|
||||||
|
|
||||||
inputs['node-version'] = versionSpec;
|
|
||||||
inputs['check-latest'] = 'true';
|
|
||||||
inputs['always-auth'] = false;
|
|
||||||
inputs['token'] = 'faketoken';
|
|
||||||
|
|
||||||
// ... but not in the local cache
|
|
||||||
findSpy.mockImplementation(() => '');
|
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
||||||
let toolPath = path.normalize('/cache/node/11.11.0/x64');
|
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
|
||||||
expect(exSpy).toHaveBeenCalled();
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve the latest version from manifest...'
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Failed to resolve version ${versionSpec} from manifest`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Attempting to download ${versionSpec}...`
|
|
||||||
);
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fallback to dist if manifest is not available', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
// a version which is not in the manifest but is in node dist
|
|
||||||
let versionSpec = '12';
|
|
||||||
|
|
||||||
inputs['node-version'] = versionSpec;
|
|
||||||
inputs['check-latest'] = 'true';
|
|
||||||
inputs['always-auth'] = false;
|
|
||||||
inputs['token'] = 'faketoken';
|
|
||||||
|
|
||||||
// ... but not in the local cache
|
|
||||||
findSpy.mockImplementation(() => '');
|
|
||||||
getManifestSpy.mockImplementation(() => {
|
|
||||||
throw new Error('Unable to download manifest');
|
|
||||||
});
|
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
||||||
let toolPath = path.normalize('/cache/node/12.11.0/x64');
|
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
|
||||||
expect(exSpy).toHaveBeenCalled();
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve the latest version from manifest...'
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Unable to resolve version from manifest...'
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Failed to resolve version ${versionSpec} from manifest`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Attempting to download ${versionSpec}...`
|
|
||||||
);
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,9 +7,6 @@ inputs:
|
||||||
default: 'false'
|
default: 'false'
|
||||||
node-version:
|
node-version:
|
||||||
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0'
|
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0'
|
||||||
check-latest:
|
|
||||||
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
|
||||||
default: false
|
|
||||||
registry-url:
|
registry-url:
|
||||||
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
|
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
|
||||||
scope:
|
scope:
|
||||||
|
|
|
@ -4643,12 +4643,12 @@ function run() {
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('version');
|
version = core.getInput('version');
|
||||||
}
|
}
|
||||||
|
console.log(`version: ${version}`);
|
||||||
if (version) {
|
if (version) {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
yield installer.getNode(version, stable, auth);
|
||||||
yield installer.getNode(version, stable, checkLatest, auth);
|
|
||||||
}
|
}
|
||||||
const registryUrl = core.getInput('registry-url');
|
const registryUrl = core.getInput('registry-url');
|
||||||
const alwaysAuth = core.getInput('always-auth');
|
const alwaysAuth = core.getInput('always-auth');
|
||||||
|
@ -10943,7 +10943,7 @@ function downloadTool(url, dest, auth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise retry
|
// Otherwise retry
|
||||||
return true;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10965,6 +10965,7 @@ function downloadToolAttempt(url, dest, auth) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const response = yield http.get(url, headers);
|
const response = yield http.get(url, headers);
|
||||||
|
throw new HTTPError(500);
|
||||||
if (response.message.statusCode !== 200) {
|
if (response.message.statusCode !== 200) {
|
||||||
const err = new HTTPError(response.message.statusCode);
|
const err = new HTTPError(response.message.statusCode);
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
|
@ -12994,30 +12995,19 @@ const tc = __importStar(__webpack_require__(533));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(280));
|
const semver = __importStar(__webpack_require__(280));
|
||||||
const fs = __webpack_require__(747);
|
const fs = __webpack_require__(747);
|
||||||
function getNode(versionSpec, stable, checkLatest, auth) {
|
function getNode(versionSpec, stable, auth) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let osPlat = os.platform();
|
let osPlat = os.platform();
|
||||||
let osArch = translateArchToDistUrl(os.arch());
|
let osArch = translateArchToDistUrl(os.arch());
|
||||||
if (checkLatest) {
|
|
||||||
core.info('Attempt to resolve the latest version from manifest...');
|
|
||||||
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth);
|
|
||||||
if (resolvedVersion) {
|
|
||||||
versionSpec = resolvedVersion;
|
|
||||||
core.info(`Resolved as '${versionSpec}'`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.info(`Failed to resolve version ${versionSpec} from manifest`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath;
|
let toolPath;
|
||||||
toolPath = tc.find('node', versionSpec);
|
toolPath = tc.find('node', versionSpec);
|
||||||
// If not found in cache, download
|
// If not found in cache, download
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
console.log(`Found in cache @ ${toolPath}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Attempting to download ${versionSpec}...`);
|
console.log(`Attempting to download ${versionSpec}...`);
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
let info = null;
|
let info = null;
|
||||||
//
|
//
|
||||||
|
@ -13026,24 +13016,24 @@ function getNode(versionSpec, stable, checkLatest, auth) {
|
||||||
try {
|
try {
|
||||||
info = yield getInfoFromManifest(versionSpec, stable, auth);
|
info = yield getInfoFromManifest(versionSpec, stable, auth);
|
||||||
if (info) {
|
if (info) {
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
|
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Not found in manifest. Falling back to download directly from Node');
|
console.log('Not found in manifest. Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// Rate limit?
|
// Rate limit?
|
||||||
if (err instanceof tc.HTTPError &&
|
if (err instanceof tc.HTTPError &&
|
||||||
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
|
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
|
||||||
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
|
console.log(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(err.message);
|
console.log(err.message);
|
||||||
}
|
}
|
||||||
core.debug(err.stack);
|
core.debug(err.stack);
|
||||||
core.info('Falling back to download directly from Node');
|
console.log('Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Download from nodejs.org
|
// Download from nodejs.org
|
||||||
|
@ -13053,7 +13043,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
||||||
}
|
}
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
try {
|
try {
|
||||||
downloadPath = yield tc.downloadTool(info.downloadUrl);
|
downloadPath = yield tc.downloadTool(info.downloadUrl);
|
||||||
}
|
}
|
||||||
|
@ -13067,7 +13057,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
|
||||||
//
|
//
|
||||||
// Extract
|
// Extract
|
||||||
//
|
//
|
||||||
core.info('Extracting ...');
|
console.log('Extracting ...');
|
||||||
let extPath;
|
let extPath;
|
||||||
info = info || {}; // satisfy compiler, never null when reaches here
|
info = info || {}; // satisfy compiler, never null when reaches here
|
||||||
if (osPlat == 'win32') {
|
if (osPlat == 'win32') {
|
||||||
|
@ -13089,9 +13079,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
|
||||||
//
|
//
|
||||||
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
||||||
//
|
//
|
||||||
core.info('Adding to the cache ...');
|
console.log('Adding to the cache ...');
|
||||||
toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion);
|
toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion);
|
||||||
core.info('Done');
|
console.log('Done');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// a tool installer initimately knows details about the layout of that tool
|
// a tool installer initimately knows details about the layout of that tool
|
||||||
|
@ -13110,7 +13100,8 @@ exports.getNode = getNode;
|
||||||
function getInfoFromManifest(versionSpec, stable, auth) {
|
function getInfoFromManifest(versionSpec, stable, auth) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let info = null;
|
let info = null;
|
||||||
const releases = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
|
const releases = yield tc.getManifestFromRepo('actions', 'node-versions', auth);
|
||||||
|
console.log(`matching ${versionSpec}...`);
|
||||||
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
|
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
info = {};
|
info = {};
|
||||||
|
@ -13146,18 +13137,6 @@ function getInfoFromDist(versionSpec) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function resolveVersionFromManifest(versionSpec, stable, auth) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
const info = yield getInfoFromManifest(versionSpec, stable, auth);
|
|
||||||
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
core.info('Unable to resolve version from manifest...');
|
|
||||||
core.debug(err.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
|
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
|
||||||
function evaluateVersions(versions, versionSpec) {
|
function evaluateVersions(versions, versionSpec) {
|
||||||
let version = '';
|
let version = '';
|
||||||
|
@ -13255,7 +13234,7 @@ function acquireNodeFromFallbackLocation(version) {
|
||||||
try {
|
try {
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
||||||
core.info(`Downloading only node binary from ${exeUrl}`);
|
console.log(`Downloading only node binary from ${exeUrl}`);
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
const exePath = yield tc.downloadTool(exeUrl);
|
||||||
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
const libPath = yield tc.downloadTool(libUrl);
|
||||||
|
|
|
@ -26,36 +26,20 @@ interface INodeVersionInfo {
|
||||||
export async function getNode(
|
export async function getNode(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
checkLatest: boolean,
|
|
||||||
auth: string | undefined
|
auth: string | undefined
|
||||||
) {
|
) {
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = translateArchToDistUrl(os.arch());
|
let osArch: string = translateArchToDistUrl(os.arch());
|
||||||
|
|
||||||
if (checkLatest) {
|
|
||||||
core.info('Attempt to resolve the latest version from manifest...');
|
|
||||||
const resolvedVersion = await resolveVersionFromManifest(
|
|
||||||
versionSpec,
|
|
||||||
stable,
|
|
||||||
auth
|
|
||||||
);
|
|
||||||
if (resolvedVersion) {
|
|
||||||
versionSpec = resolvedVersion;
|
|
||||||
core.info(`Resolved as '${versionSpec}'`);
|
|
||||||
} else {
|
|
||||||
core.info(`Failed to resolve version ${versionSpec} from manifest`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('node', versionSpec);
|
toolPath = tc.find('node', versionSpec);
|
||||||
|
|
||||||
// If not found in cache, download
|
// If not found in cache, download
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
console.log(`Found in cache @ ${toolPath}`);
|
||||||
} else {
|
} else {
|
||||||
core.info(`Attempting to download ${versionSpec}...`);
|
console.log(`Attempting to download ${versionSpec}...`);
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
let info: INodeVersionInfo | null = null;
|
let info: INodeVersionInfo | null = null;
|
||||||
|
|
||||||
|
@ -65,10 +49,12 @@ export async function getNode(
|
||||||
try {
|
try {
|
||||||
info = await getInfoFromManifest(versionSpec, stable, auth);
|
info = await getInfoFromManifest(versionSpec, stable, auth);
|
||||||
if (info) {
|
if (info) {
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
console.log(
|
||||||
|
`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`
|
||||||
|
);
|
||||||
downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth);
|
downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth);
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
console.log(
|
||||||
'Not found in manifest. Falling back to download directly from Node'
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -78,14 +64,14 @@ export async function getNode(
|
||||||
err instanceof tc.HTTPError &&
|
err instanceof tc.HTTPError &&
|
||||||
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
|
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
|
||||||
) {
|
) {
|
||||||
core.info(
|
console.log(
|
||||||
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
core.info(err.message);
|
console.log(err.message);
|
||||||
}
|
}
|
||||||
core.debug(err.stack);
|
core.debug(err.stack);
|
||||||
core.info('Falling back to download directly from Node');
|
console.log('Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -99,7 +85,7 @@ export async function getNode(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
try {
|
try {
|
||||||
downloadPath = await tc.downloadTool(info.downloadUrl);
|
downloadPath = await tc.downloadTool(info.downloadUrl);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -114,7 +100,7 @@ export async function getNode(
|
||||||
//
|
//
|
||||||
// Extract
|
// Extract
|
||||||
//
|
//
|
||||||
core.info('Extracting ...');
|
console.log('Extracting ...');
|
||||||
let extPath: string;
|
let extPath: string;
|
||||||
info = info || ({} as INodeVersionInfo); // satisfy compiler, never null when reaches here
|
info = info || ({} as INodeVersionInfo); // satisfy compiler, never null when reaches here
|
||||||
if (osPlat == 'win32') {
|
if (osPlat == 'win32') {
|
||||||
|
@ -136,9 +122,9 @@ export async function getNode(
|
||||||
//
|
//
|
||||||
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
||||||
//
|
//
|
||||||
core.info('Adding to the cache ...');
|
console.log('Adding to the cache ...');
|
||||||
toolPath = await tc.cacheDir(extPath, 'node', info.resolvedVersion);
|
toolPath = await tc.cacheDir(extPath, 'node', info.resolvedVersion);
|
||||||
core.info('Done');
|
console.log('Done');
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -164,9 +150,9 @@ async function getInfoFromManifest(
|
||||||
const releases = await tc.getManifestFromRepo(
|
const releases = await tc.getManifestFromRepo(
|
||||||
'actions',
|
'actions',
|
||||||
'node-versions',
|
'node-versions',
|
||||||
auth,
|
auth
|
||||||
'main'
|
|
||||||
);
|
);
|
||||||
|
console.log(`matching ${versionSpec}...`);
|
||||||
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
||||||
|
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
|
@ -211,20 +197,6 @@ async function getInfoFromDist(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveVersionFromManifest(
|
|
||||||
versionSpec: string,
|
|
||||||
stable: boolean,
|
|
||||||
auth: string | undefined
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
try {
|
|
||||||
const info = await getInfoFromManifest(versionSpec, stable, auth);
|
|
||||||
return info?.resolvedVersion;
|
|
||||||
} catch (err) {
|
|
||||||
core.info('Unable to resolve version from manifest...');
|
|
||||||
core.debug(err.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
|
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
|
||||||
function evaluateVersions(versions: string[], versionSpec: string): string {
|
function evaluateVersions(versions: string[], versionSpec: string): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
|
@ -329,7 +301,7 @@ async function acquireNodeFromFallbackLocation(
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
||||||
|
|
||||||
core.info(`Downloading only node binary from ${exeUrl}`);
|
console.log(`Downloading only node binary from ${exeUrl}`);
|
||||||
|
|
||||||
const exePath = await tc.downloadTool(exeUrl);
|
const exePath = await tc.downloadTool(exeUrl);
|
||||||
await io.cp(exePath, path.join(tempDir, 'node.exe'));
|
await io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
|
|
|
@ -15,13 +15,12 @@ export async function run() {
|
||||||
version = core.getInput('version');
|
version = core.getInput('version');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`version: ${version}`);
|
||||||
if (version) {
|
if (version) {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
const checkLatest =
|
await installer.getNode(version, stable, auth);
|
||||||
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
|
||||||
await installer.getNode(version, stable, checkLatest, auth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const registryUrl: string = core.getInput('registry-url');
|
const registryUrl: string = core.getInput('registry-url');
|
||||||
|
|
Loading…
Reference in New Issue