mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 09:21:00 +00:00
work on resolving comments
This commit is contained in:
parent
65270bbd55
commit
882cfbaf78
5 changed files with 54 additions and 18 deletions
2
.github/workflows/versions.yml
vendored
2
.github/workflows/versions.yml
vendored
|
@ -57,7 +57,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [17-nightly, 18-nightly, 19-nightly]
|
node-version: [16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
|
|
10
__tests__/README.md
Normal file
10
__tests__/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Files located in data directory are used only for testing purposes.
|
||||||
|
|
||||||
|
|
||||||
|
## Here the list of files in the data directory
|
||||||
|
- `.nvmrc`, `.tools-versions` and `package.json` are used to test node-version-file logic
|
||||||
|
- `package-lock.json`, `pnpm-lock.yaml` and `yarn.lock` are used to test cache logic
|
||||||
|
- `versions-manifest.json` is used for unit testing to check downloading Node.js versions from the node-versions repository.
|
||||||
|
- `node-dist-index.json` is used for unit testing to check downloading Node.js versions from the official site.
|
||||||
|
- `node-rc-index.json` is used for unit testing to check downloading Node.js rc versions from the official site.
|
||||||
|
- `node-nightly-index.json` is used for unit testing to check downloading Node.js nightly builds from the official site.
|
9
dist/setup/index.js
vendored
9
dist/setup/index.js
vendored
|
@ -73438,7 +73438,7 @@ function evaluateNightlyVersions(versions, versionSpec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (range) {
|
if (range) {
|
||||||
versions.sort((a, b) => +semver.lt(a, b) - 0.5);
|
versions.sort(semver.rcompare);
|
||||||
for (const currentVersion of versions) {
|
for (const currentVersion of versions) {
|
||||||
const satisfied = semver.satisfies(currentVersion.replace('-nightly', '-nightly.'), range, { includePrerelease: true }) && currentVersion.includes('nightly');
|
const satisfied = semver.satisfies(currentVersion.replace('-nightly', '-nightly.'), range, { includePrerelease: true }) && currentVersion.includes('nightly');
|
||||||
if (satisfied) {
|
if (satisfied) {
|
||||||
|
@ -73462,12 +73462,7 @@ function evaluateVersions(versions, versionSpec) {
|
||||||
if (versionSpec.includes('nightly')) {
|
if (versionSpec.includes('nightly')) {
|
||||||
return evaluateNightlyVersions(versions, versionSpec);
|
return evaluateNightlyVersions(versions, versionSpec);
|
||||||
}
|
}
|
||||||
versions = versions.sort((a, b) => {
|
versions = versions.sort(semver.rcompare);
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
for (let i = versions.length - 1; i >= 0; i--) {
|
||||||
const potential = versions[i];
|
const potential = versions[i];
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
const satisfied = semver.satisfies(potential, versionSpec);
|
||||||
|
|
|
@ -106,7 +106,9 @@ jobs:
|
||||||
|
|
||||||
## Nightly versions
|
## Nightly versions
|
||||||
|
|
||||||
You can specify a nightly version to download it from https://nodejs.org/download/nightly.
|
You can specify a nightly version to download it from https://nodejs.org/download/nightly.
|
||||||
|
|
||||||
|
### Install nightly build for specific node version
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -117,7 +119,39 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16.0.0-nightly' # or 16-nightly
|
node-version: '16.0.0-nightly' # it will install the latest nigthly release for node 16.0.0
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install nightly build for major node version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '16-nightly' # it will install the latest nigthly release for node 16
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install the exact nightly version
|
||||||
|
|
||||||
|
```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-nightly20210420a0261d231c'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
@ -140,6 +174,8 @@ jobs:
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** You should specify the exact version for rc: `16.0.0-rc.1`.
|
||||||
|
|
||||||
## Caching packages data
|
## 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.
|
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.
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ function evaluateNightlyVersions(
|
||||||
versionSpec: string
|
versionSpec: string
|
||||||
): string {
|
): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
let range: string | null | undefined;
|
let range: string | undefined;
|
||||||
const [raw, prerelease] = versionSpec.split('-');
|
const [raw, prerelease] = versionSpec.split('-');
|
||||||
const isValidVersion = semver.valid(raw);
|
const isValidVersion = semver.valid(raw);
|
||||||
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
||||||
|
@ -383,7 +383,7 @@ function evaluateNightlyVersions(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (range) {
|
if (range) {
|
||||||
versions.sort((a, b) => +semver.lt(a, b) - 0.5);
|
versions.sort(semver.rcompare);
|
||||||
for (const currentVersion of versions) {
|
for (const currentVersion of versions) {
|
||||||
const satisfied: boolean =
|
const satisfied: boolean =
|
||||||
semver.satisfies(
|
semver.satisfies(
|
||||||
|
@ -416,12 +416,7 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
|
||||||
return evaluateNightlyVersions(versions, versionSpec);
|
return evaluateNightlyVersions(versions, versionSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
versions = versions.sort((a, b) => {
|
versions = versions.sort(semver.rcompare);
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
for (let i = versions.length - 1; i >= 0; i--) {
|
||||||
const potential: string = versions[i];
|
const potential: string = versions[i];
|
||||||
const satisfied: boolean = semver.satisfies(potential, versionSpec);
|
const satisfied: boolean = semver.satisfies(potential, versionSpec);
|
||||||
|
|
Loading…
Add table
Reference in a new issue