mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 03:28:42 +00:00
fix tests and update documentation
This commit is contained in:
parent
2900876013
commit
ca842d5a5e
5 changed files with 50 additions and 91 deletions
12
README.md
12
README.md
|
@ -116,11 +116,13 @@ jobs:
|
|||
1. [Check latest version](docs/advanced-usage.md#check-latest-version)
|
||||
2. [Using a node version file](docs/advanced-usage.md#node-version-file)
|
||||
3. [Using different architectures](docs/advanced-usage.md#architecture)
|
||||
4. [Caching packages data](docs/advanced-usage.md#caching-packages-data)
|
||||
5. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)
|
||||
6. [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
|
||||
7. [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
|
||||
8. [Using private packages](docs/advanced-usage.md#use-private-packages)
|
||||
4. [Using nigthly versions](docs/advanced-usage.md#nightly-versions)
|
||||
5. [Using rc versions](docs/advanced-usage.md#rc-versions)
|
||||
6. [Caching packages data](docs/advanced-usage.md#caching-packages-data)
|
||||
7. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)
|
||||
8. [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
|
||||
9. [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
|
||||
10. [Using private packages](docs/advanced-usage.md#use-private-packages)
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -391,18 +391,6 @@ describe('setup-node', () => {
|
|||
});
|
||||
|
||||
it('acquires specified architecture of node', async () => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
for (const {arch, version, osSpec} of [
|
||||
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
||||
{arch: 'x86', version: '14.0.0', osSpec: 'win32'}
|
||||
|
@ -443,20 +431,6 @@ describe('setup-node', () => {
|
|||
}, 100000);
|
||||
|
||||
describe('check-latest flag', () => {
|
||||
beforeEach(() => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
});
|
||||
it('use local version and dont check manifest if check-latest is not specified', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
@ -956,21 +930,6 @@ describe('setup-node', () => {
|
|||
});
|
||||
|
||||
describe('rc versions', () => {
|
||||
beforeEach(() => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'13.10.1-rc.0',
|
||||
|
@ -1081,21 +1040,6 @@ describe('setup-node', () => {
|
|||
});
|
||||
|
||||
describe('nightly versions', () => {
|
||||
beforeEach(() => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'17.5.0-nightly',
|
||||
|
@ -1260,18 +1204,6 @@ describe('setup-node', () => {
|
|||
it.each(['latest', 'current', 'node'])(
|
||||
'download the %s version if alias is provided',
|
||||
async inputVersion => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
// Arrange
|
||||
inputs['node-version'] = inputVersion;
|
||||
|
||||
|
@ -1298,18 +1230,6 @@ describe('setup-node', () => {
|
|||
it.each(['latest', 'current', 'node'])(
|
||||
'download the %s version if alias is provided',
|
||||
async inputVersion => {
|
||||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <im.INodeVersion>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <im.INodeVersion>nodeTestDistNightly;
|
||||
} else {
|
||||
res = <im.INodeVersion>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
});
|
||||
// Arrange
|
||||
inputs['node-version'] = inputVersion;
|
||||
const expectedVersion = nodeTestDist[0];
|
||||
|
|
6
dist/setup/index.js
vendored
6
dist/setup/index.js
vendored
|
@ -73489,10 +73489,10 @@ function getNodejsDistUrl(version) {
|
|||
if (version.includes('nightly')) {
|
||||
return 'https://nodejs.org/download/nightly';
|
||||
}
|
||||
else if (!prerelease) {
|
||||
return 'https://nodejs.org/dist';
|
||||
else if (prerelease) {
|
||||
return 'https://nodejs.org/download/rc';
|
||||
}
|
||||
return 'https://nodejs.org/download/rc';
|
||||
return 'https://nodejs.org/dist';
|
||||
}
|
||||
exports.getNodejsDistUrl = getNodejsDistUrl;
|
||||
function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions) {
|
||||
|
|
|
@ -104,6 +104,42 @@ jobs:
|
|||
- run: npm test
|
||||
```
|
||||
|
||||
## Nightly versions
|
||||
|
||||
You can specify a nightly version to download it from https://nodejs.org/download/nightly.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.0.0-nightly' # or 16-nightly
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
```
|
||||
|
||||
## RC versions
|
||||
|
||||
You can use specify a rc version to download it from https://nodejs.org/download/rc.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.0.0-rc.1'
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
```
|
||||
|
||||
## Caching packages data
|
||||
The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions.
|
||||
|
||||
|
|
|
@ -443,10 +443,11 @@ export function getNodejsDistUrl(version: string) {
|
|||
const prerelease = semver.prerelease(version);
|
||||
if (version.includes('nightly')) {
|
||||
return 'https://nodejs.org/download/nightly';
|
||||
} else if (!prerelease) {
|
||||
return 'https://nodejs.org/dist';
|
||||
} else if (prerelease) {
|
||||
return 'https://nodejs.org/download/rc';
|
||||
}
|
||||
return 'https://nodejs.org/download/rc';
|
||||
|
||||
return 'https://nodejs.org/dist';
|
||||
}
|
||||
|
||||
async function queryDistForMatch(
|
||||
|
|
Loading…
Add table
Reference in a new issue