Compare commits
5 Commits
main
...
update-mem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cd066d2e7 | ||
|
|
fc5dc8bbe4 | ||
|
|
8819aae165 | ||
|
|
ba2f076a9c | ||
|
|
d5f102c3e3 |
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
@ -15,5 +15,3 @@ jobs:
|
|||||||
call-basic-validation:
|
call-basic-validation:
|
||||||
name: Basic validation
|
name: Basic validation
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||||
with:
|
|
||||||
node-version: '20.x'
|
|
||||||
|
|||||||
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@ -15,5 +15,3 @@ jobs:
|
|||||||
call-check-dist:
|
call-check-dist:
|
||||||
name: Check dist/
|
name: Check dist/
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
with:
|
|
||||||
node-version: '20.x'
|
|
||||||
|
|||||||
24
.github/workflows/e2e-cache.yml
vendored
24
.github/workflows/e2e-cache.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [12, 14, 16]
|
node-version: [12, 14, 16]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Clean global cache
|
- name: Clean global cache
|
||||||
run: npm cache clean --force
|
run: npm cache clean --force
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
@ -44,7 +44,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [12, 14, 16]
|
node-version: [12, 14, 16]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v2
|
uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
@ -77,7 +77,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [14, 16]
|
node-version: [14, 16]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Yarn version
|
- name: Yarn version
|
||||||
run: yarn --version
|
run: yarn --version
|
||||||
- name: Generate yarn file
|
- name: Generate yarn file
|
||||||
@ -93,13 +93,13 @@ jobs:
|
|||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --ignore-engines
|
run: yarn install
|
||||||
- name: Verify node and yarn
|
- name: Verify node and yarn
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
node-yarn3-depencies-caching:
|
node-yarn2-depencies-caching:
|
||||||
name: Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
name: Test yarn 2 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
||||||
@ -109,9 +109,9 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [12, 14, 16]
|
node-version: [12, 14, 16]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Update yarn
|
- name: Update yarn
|
||||||
run: yarn set version 3.6.4
|
run: yarn set version berry
|
||||||
- name: Yarn version
|
- name: Yarn version
|
||||||
run: yarn --version
|
run: yarn --version
|
||||||
- name: Generate simple .yarnrc.yml
|
- name: Generate simple .yarnrc.yml
|
||||||
@ -143,7 +143,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: prepare sub-projects
|
- name: prepare sub-projects
|
||||||
run: __tests__/prepare-yarn-subprojects.sh yarn1
|
run: __tests__/prepare-yarn-subprojects.sh yarn1
|
||||||
@ -170,7 +170,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: prepare sub-projects
|
- name: prepare sub-projects
|
||||||
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
|
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
|
||||||
@ -197,7 +197,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: prepare sub-projects
|
- name: prepare sub-projects
|
||||||
run: __tests__/prepare-yarn-subprojects.sh global
|
run: __tests__/prepare-yarn-subprojects.sh global
|
||||||
@ -224,7 +224,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: prepare sub-projects
|
- name: prepare sub-projects
|
||||||
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
|
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
|
||||||
|
|||||||
4
.github/workflows/proxy.yml
vendored
4
.github/workflows/proxy.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
https_proxy: http://squid-proxy:3128
|
https_proxy: http://squid-proxy:3128
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Clear tool cache
|
- name: Clear tool cache
|
||||||
run: rm -rf $RUNNER_TOOL_CACHE/*
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
- name: Setup node 14
|
- name: Setup node 14
|
||||||
@ -41,7 +41,7 @@ jobs:
|
|||||||
https_proxy: http://no-such-proxy:3128
|
https_proxy: http://no-such-proxy:3128
|
||||||
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
|
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Clear tool cache
|
- name: Clear tool cache
|
||||||
run: rm -rf $RUNNER_TOOL_CACHE/*
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
- name: Setup node 11
|
- name: Setup node 11
|
||||||
|
|||||||
46
.github/workflows/versions.yml
vendored
46
.github/workflows/versions.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [10, 12, 14]
|
node-version: [10, 12, 14]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -37,7 +37,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
|
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
'20.0.0-v8-canary20221101e50e45c9f8'
|
'20.0.0-v8-canary20221101e50e45c9f8'
|
||||||
]
|
]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -85,7 +85,7 @@ jobs:
|
|||||||
node-version:
|
node-version:
|
||||||
[16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly]
|
[16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -105,7 +105,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [16.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0]
|
node-version: [16.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -125,7 +125,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [10.15, 12.16.0, 14.2.0, 16.3.0]
|
node-version: [10.15, 12.16.0, 14.2.0, 16.3.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -142,7 +142,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [10, 12, 14]
|
node-version: [10, 12, 14]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node and check latest
|
- name: Setup Node and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -161,7 +161,10 @@ jobs:
|
|||||||
node-version-file:
|
node-version-file:
|
||||||
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
- name: Remove volta from package.json
|
||||||
|
shell: bash
|
||||||
|
run: cat <<< "$(jq 'del(.volta)' ./__tests__/data/package.json)" > ./__tests__/data/package.json
|
||||||
- name: Setup node from node version file
|
- name: Setup node from node version file
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -176,26 +179,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node from node version file
|
- name: Setup node from node version file
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version-file: '__tests__/data/package-volta.json'
|
node-version-file: '__tests__/data/package.json'
|
||||||
- name: Verify node
|
|
||||||
run: __tests__/verify-node.sh 16
|
|
||||||
|
|
||||||
version-file-volta-extends:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup node from node version file
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
node-version-file: '__tests__/data/package-volta-extends.json'
|
|
||||||
- name: Verify node
|
- name: Verify node
|
||||||
run: __tests__/verify-node.sh 16
|
run: __tests__/verify-node.sh 16
|
||||||
|
|
||||||
@ -207,7 +195,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
node-version: [11, 13]
|
node-version: [11, 13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node from dist
|
- name: Setup Node from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -223,7 +211,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
# test old versions which didn't have npm and layout different
|
# 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: ./
|
||||||
@ -236,7 +224,7 @@ jobs:
|
|||||||
arch:
|
arch:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node 14 x86 from dist
|
- name: Setup node 14 x86 from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -260,7 +248,7 @@ jobs:
|
|||||||
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
|
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
|
||||||
id: version
|
id: version
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.11.dep.yml
Normal file
BIN
.licenses/npm/@actions/http-client-1.0.11.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/rest.dep.yml
Normal file
BIN
.licenses/npm/@octokit/rest.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/atob-lite.dep.yml
Normal file
BIN
.licenses/npm/atob-lite.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/btoa-lite.dep.yml
Normal file
BIN
.licenses/npm/btoa-lite.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/cross-spawn.dep.yml
Normal file
BIN
.licenses/npm/cross-spawn.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/form-data-3.0.1.dep.yml
Normal file
BIN
.licenses/npm/form-data-3.0.1.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/is-stream.dep.yml
Normal file
BIN
.licenses/npm/is-stream.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/isobject.dep.yml
Normal file
BIN
.licenses/npm/isobject.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.get.dep.yml
Normal file
BIN
.licenses/npm/lodash.get.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.memoize.dep.yml
Normal file
BIN
.licenses/npm/lodash.memoize.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.set.dep.yml
Normal file
BIN
.licenses/npm/lodash.set.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.uniq.dep.yml
Normal file
BIN
.licenses/npm/lodash.uniq.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/macos-release.dep.yml
Normal file
BIN
.licenses/npm/macos-release.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/npm-run-path.dep.yml
Normal file
BIN
.licenses/npm/npm-run-path.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
Normal file
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/p-finally.dep.yml
Normal file
BIN
.licenses/npm/p-finally.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/path-key.dep.yml
Normal file
BIN
.licenses/npm/path-key.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/shebang-command.dep.yml
Normal file
BIN
.licenses/npm/shebang-command.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/shebang-regex.dep.yml
Normal file
BIN
.licenses/npm/shebang-regex.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/signal-exit.dep.yml
Normal file
BIN
.licenses/npm/signal-exit.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/strip-eof.dep.yml
Normal file
BIN
.licenses/npm/strip-eof.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/tslib-2.3.1.dep.yml
Normal file
BIN
.licenses/npm/tslib-2.3.1.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/universal-user-agent-4.0.0.dep.yml
Normal file
BIN
.licenses/npm/universal-user-agent-4.0.0.dep.yml
Normal file
Binary file not shown.
BIN
.licenses/npm/uuid-3.3.2.dep.yml
Normal file
BIN
.licenses/npm/uuid-3.3.2.dep.yml
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/windows-release.dep.yml
Normal file
BIN
.licenses/npm/windows-release.dep.yml
Normal file
Binary file not shown.
32
README.md
32
README.md
@ -18,14 +18,14 @@ See [action.yml](action.yml)
|
|||||||
|
|
||||||
<!-- start usage -->
|
<!-- start usage -->
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
# Version Spec of the version to use in SemVer notation.
|
# Version Spec of the version to use in SemVer notation.
|
||||||
# It also emits such aliases as lts, latest, nightly and canary builds
|
# It also emits such aliases as lts, latest, nightly and canary builds
|
||||||
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
||||||
node-version: ''
|
node-version: ''
|
||||||
|
|
||||||
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
|
# File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions.
|
||||||
# If node-version and node-version-file are both provided the action will use version from node-version.
|
# If node-version and node-version-file are both provided the action will use version from node-version.
|
||||||
node-version-file: ''
|
node-version-file: ''
|
||||||
|
|
||||||
@ -83,8 +83,8 @@ See [action.yml](action.yml)
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -103,12 +103,12 @@ The `node-version` input supports the Semantic Versioning Specification, for mor
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- Major versions: `18`, `20`
|
- Major versions: `14`, `16`, `18`
|
||||||
- More specific versions: `10.15`, `16.15.1` , `18.4.0`
|
- More specific versions: `10.15`, `16.15.1` , `18.4.0`
|
||||||
- NVM LTS syntax: `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n`
|
- NVM LTS syntax: `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n`
|
||||||
- Latest release: `*` or `latest`/`current`/`node`
|
- Latest release: `*` or `latest`/`current`/`node`
|
||||||
|
|
||||||
**Note:** Like the other values, `*` will get the latest [locally-cached Node.js version](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#nodejs), or the latest version from [actions/node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json), depending on the [`check-latest`](docs/advanced-usage.md#check-latest-version) input.
|
**Note:** Like the other values, `*` will get the latest [locally-cached Node.js version](https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#nodejs), or the latest version from [actions/node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json), depending on the [`check-latest`](docs/advanced-usage.md#check-latest-version) input.
|
||||||
|
|
||||||
`current`/`latest`/`node` always resolve to the latest [dist version](https://nodejs.org/dist/index.json).
|
`current`/`latest`/`node` always resolve to the latest [dist version](https://nodejs.org/dist/index.json).
|
||||||
That version is then downloaded from actions/node-versions if possible, or directly from Node.js if not.
|
That version is then downloaded from actions/node-versions if possible, or directly from Node.js if not.
|
||||||
@ -132,10 +132,10 @@ See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` in
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 16
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
@ -145,10 +145,10 @@ steps:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 16
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: subdir/package-lock.json
|
cache-dependency-path: subdir/package-lock.json
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -166,9 +166,9 @@ jobs:
|
|||||||
node: [ 14, 16, 18 ]
|
node: [ 14, 16, 18 ]
|
||||||
name: Node ${{ matrix.node }} sample
|
name: Node ${{ matrix.node }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -182,10 +182,10 @@ jobs:
|
|||||||
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
|
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
||||||
node-version: 20
|
node-version: 16
|
||||||
```
|
```
|
||||||
|
|
||||||
If the runner is not able to access github.com, any Nodejs versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
|
If the runner is not able to access github.com, any Nodejs versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
|
||||||
|
|||||||
@ -6,8 +6,7 @@ import {
|
|||||||
PackageManagerInfo,
|
PackageManagerInfo,
|
||||||
isCacheFeatureAvailable,
|
isCacheFeatureAvailable,
|
||||||
supportedPackageManagers,
|
supportedPackageManagers,
|
||||||
getCommandOutput,
|
getProjectDirectoriesFromCacheDependencyPath
|
||||||
resetProjectDirectoriesMemoized
|
|
||||||
} from '../src/cache-utils';
|
} from '../src/cache-utils';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
@ -123,7 +122,7 @@ describe('cache-utils', () => {
|
|||||||
MockGlobber.create(['/foo', '/bar'])
|
MockGlobber.create(['/foo', '/bar'])
|
||||||
);
|
);
|
||||||
|
|
||||||
resetProjectDirectoriesMemoized();
|
getProjectDirectoriesFromCacheDependencyPath.cache.clear?.();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"volta": {
|
|
||||||
"extends": "./package-volta.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"engines": {
|
|
||||||
"node": "^14.0.0"
|
|
||||||
},
|
|
||||||
"volta": {
|
|
||||||
"node": "16.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^14.0.0"
|
"node": "^14.0.0"
|
||||||
|
},
|
||||||
|
"volta": {
|
||||||
|
"node": "16.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import * as core from '@actions/core';
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as io from '@actions/io';
|
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@ -25,13 +24,11 @@ describe('main tests', () => {
|
|||||||
let startGroupSpy: jest.SpyInstance;
|
let startGroupSpy: jest.SpyInstance;
|
||||||
let endGroupSpy: jest.SpyInstance;
|
let endGroupSpy: jest.SpyInstance;
|
||||||
|
|
||||||
let whichSpy: jest.SpyInstance;
|
|
||||||
|
|
||||||
let existsSpy: jest.SpyInstance;
|
let existsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
let getExecOutputSpy: jest.SpyInstance;
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
|
||||||
let getNodeVersionFromFileSpy: jest.SpyInstance;
|
let parseNodeVersionSpy: jest.SpyInstance;
|
||||||
let cnSpy: jest.SpyInstance;
|
let cnSpy: jest.SpyInstance;
|
||||||
let findSpy: jest.SpyInstance;
|
let findSpy: jest.SpyInstance;
|
||||||
let isCacheActionAvailable: jest.SpyInstance;
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
@ -44,7 +41,6 @@ describe('main tests', () => {
|
|||||||
// node
|
// node
|
||||||
os = {};
|
os = {};
|
||||||
console.log('::stop-commands::stoptoken');
|
console.log('::stop-commands::stoptoken');
|
||||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
|
||||||
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
infoSpy = jest.spyOn(core, 'info');
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
@ -60,18 +56,18 @@ describe('main tests', () => {
|
|||||||
inSpy = jest.spyOn(core, 'getInput');
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
inSpy.mockImplementation(name => inputs[name]);
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
whichSpy = jest.spyOn(io, 'which');
|
|
||||||
|
|
||||||
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|
||||||
findSpy = jest.spyOn(tc, 'find');
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
|
||||||
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
|
||||||
cnSpy = jest.spyOn(process.stdout, 'write');
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
cnSpy.mockImplementation(line => {
|
cnSpy.mockImplementation(line => {
|
||||||
// uncomment to debug
|
// uncomment to debug
|
||||||
process.stderr.write('write:' + line + '\n');
|
// process.stderr.write('write:' + line + '\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
setupNodeJsSpy = jest.spyOn(OfficialBuilds.prototype, 'setupNodeJs');
|
setupNodeJsSpy = jest.spyOn(OfficialBuilds.prototype, 'setupNodeJs');
|
||||||
@ -89,7 +85,7 @@ describe('main tests', () => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
describe('getNodeVersionFromFile', () => {
|
describe('parseNodeVersionFile', () => {
|
||||||
each`
|
each`
|
||||||
contents | expected
|
contents | expected
|
||||||
${'12'} | ${'12'}
|
${'12'} | ${'12'}
|
||||||
@ -104,27 +100,9 @@ describe('main tests', () => {
|
|||||||
${'unknown format'} | ${'unknown format'}
|
${'unknown format'} | ${'unknown format'}
|
||||||
${' 14.1.0 '} | ${'14.1.0'}
|
${' 14.1.0 '} | ${'14.1.0'}
|
||||||
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
|
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
|
||||||
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
|
|
||||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||||
${'{}'} | ${null}
|
|
||||||
`.it('parses "$contents"', ({contents, expected}) => {
|
`.it('parses "$contents"', ({contents, expected}) => {
|
||||||
const existsSpy = jest.spyOn(fs, 'existsSync');
|
expect(util.parseNodeVersionFile(contents)).toBe(expected);
|
||||||
existsSpy.mockImplementation(() => true);
|
|
||||||
|
|
||||||
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
|
||||||
readFileSpy.mockImplementation(filePath => {
|
|
||||||
if (
|
|
||||||
typeof filePath === 'string' &&
|
|
||||||
path.basename(filePath) === 'package.json'
|
|
||||||
) {
|
|
||||||
// Special case for volta.extends
|
|
||||||
return '{"volta": {"node": "18.0.0"}}';
|
|
||||||
}
|
|
||||||
|
|
||||||
return contents;
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(util.getNodeVersionFromFile('file')).toBe(expected);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -147,10 +125,6 @@ describe('main tests', () => {
|
|||||||
return {stdout: obj[command], stderr: '', exitCode: 0};
|
return {stdout: obj[command], stderr: '', exitCode: 0};
|
||||||
});
|
});
|
||||||
|
|
||||||
whichSpy.mockImplementation(cmd => {
|
|
||||||
return `some/${cmd}/path`;
|
|
||||||
});
|
|
||||||
|
|
||||||
await util.printEnvDetailsAndSetOutput();
|
await util.printEnvDetailsAndSetOutput();
|
||||||
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('node-version', obj['node']);
|
expect(setOutputSpy).toHaveBeenCalledWith('node-version', obj['node']);
|
||||||
@ -167,17 +141,10 @@ describe('main tests', () => {
|
|||||||
|
|
||||||
describe('node-version-file flag', () => {
|
describe('node-version-file flag', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
delete inputs['node-version'];
|
parseNodeVersionSpy = jest.spyOn(util, 'parseNodeVersionFile');
|
||||||
inputs['node-version-file'] = '.nvmrc';
|
|
||||||
|
|
||||||
getNodeVersionFromFileSpy = jest.spyOn(util, 'getNodeVersionFromFile');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
it('not used if node-version is provided', async () => {
|
||||||
getNodeVersionFromFileSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not read node-version-file if node-version is provided', async () => {
|
|
||||||
// Arrange
|
// Arrange
|
||||||
inputs['node-version'] = '12';
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
@ -185,54 +152,107 @@ describe('main tests', () => {
|
|||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(inputs['node-version']).toBeDefined();
|
expect(parseNodeVersionSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(inputs['node-version-file']).toBeDefined();
|
}, 10000);
|
||||||
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
|
||||||
|
it('not used if node-version-file not provided', async () => {
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(parseNodeVersionSpy).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reads node-version-file if provided', async () => {
|
||||||
|
// Arrange
|
||||||
|
const versionSpec = 'v14';
|
||||||
|
const versionFile = '.nvmrc';
|
||||||
|
const expectedVersionSpec = '14';
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
inputs['node-version-file'] = versionFile;
|
||||||
|
|
||||||
|
parseNodeVersionSpy.mockImplementation(() => expectedVersionSpec);
|
||||||
|
existsSpy.mockImplementationOnce(
|
||||||
|
input => input === path.join(__dirname, 'data', versionFile)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(existsSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(existsSpy).toHaveReturnedWith(true);
|
||||||
|
expect(parseNodeVersionSpy).toHaveBeenCalledWith(versionSpec);
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
||||||
|
);
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
it('reads package.json as node-version-file if provided', async () => {
|
||||||
|
// Arrange
|
||||||
|
const versionSpec = fs.readFileSync(
|
||||||
|
path.join(__dirname, 'data/package.json'),
|
||||||
|
'utf-8'
|
||||||
|
);
|
||||||
|
const versionFile = 'package.json';
|
||||||
|
const expectedVersionSpec = '14';
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
inputs['node-version-file'] = versionFile;
|
||||||
|
|
||||||
|
parseNodeVersionSpy.mockImplementation(() => expectedVersionSpec);
|
||||||
|
existsSpy.mockImplementationOnce(
|
||||||
|
input => input === path.join(__dirname, 'data', versionFile)
|
||||||
|
);
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(existsSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(existsSpy).toHaveReturnedWith(true);
|
||||||
|
expect(parseNodeVersionSpy).toHaveBeenCalledWith(versionSpec);
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
||||||
|
);
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
it('both node-version-file and node-version are provided', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
const versionSpec = 'v14';
|
||||||
|
const versionFile = '.nvmrc';
|
||||||
|
const expectedVersionSpec = '14';
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, '..');
|
||||||
|
inputs['node-version-file'] = versionFile;
|
||||||
|
|
||||||
|
parseNodeVersionSpy.mockImplementation(() => expectedVersionSpec);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(existsSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(parseNodeVersionSpy).not.toHaveBeenCalled();
|
||||||
expect(warningSpy).toHaveBeenCalledWith(
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not read node-version-file if node-version-file is not provided', async () => {
|
it('should throw an error if node-version-file is not found', async () => {
|
||||||
// Arrange
|
const versionFile = '.nvmrc';
|
||||||
delete inputs['node-version-file'];
|
const versionFilePath = path.join(__dirname, '..', versionFile);
|
||||||
|
inputs['node-version-file'] = versionFile;
|
||||||
|
|
||||||
// Act
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
await main.run();
|
existsSpy.mockImplementationOnce(
|
||||||
|
input => input === path.join(__dirname, 'data', versionFile)
|
||||||
// Assert
|
|
||||||
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reads node-version-file', async () => {
|
|
||||||
// Arrange
|
|
||||||
const expectedVersionSpec = '14';
|
|
||||||
getNodeVersionFromFileSpy.mockImplementation(() => expectedVersionSpec);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Resolved ${inputs['node-version-file']} as ${expectedVersionSpec}`
|
|
||||||
);
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
it('should throw an error if node-version-file is not accessible', async () => {
|
|
||||||
// Arrange
|
|
||||||
inputs['node-version-file'] = 'non-existing-file';
|
|
||||||
const versionFilePath = path.join(
|
|
||||||
__dirname,
|
|
||||||
'data',
|
|
||||||
inputs['node-version-file']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
expect(existsSpy).toHaveBeenCalled();
|
||||||
|
expect(existsSpy).toHaveReturnedWith(false);
|
||||||
|
expect(parseNodeVersionSpy).not.toHaveBeenCalled();
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
`::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}`
|
`::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -248,9 +248,6 @@ describe('setup-node', () => {
|
|||||||
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
whichSpy.mockImplementation(cmd => {
|
|
||||||
return `some/${cmd}/path`;
|
|
||||||
});
|
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
@ -360,41 +357,6 @@ describe('setup-node', () => {
|
|||||||
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reports when download failed but version exists', async () => {
|
|
||||||
os.platform = 'linux';
|
|
||||||
os.arch = 'x64';
|
|
||||||
|
|
||||||
// a version which is not in the manifest but is in node dist
|
|
||||||
const versionSpec = '11.15.0';
|
|
||||||
|
|
||||||
inputs['node-version'] = versionSpec;
|
|
||||||
inputs['always-auth'] = false;
|
|
||||||
inputs['token'] = 'faketoken';
|
|
||||||
|
|
||||||
// ... but not in the local cache
|
|
||||||
findSpy.mockImplementation(() => '');
|
|
||||||
|
|
||||||
dlSpy.mockImplementationOnce(async () => {
|
|
||||||
throw new tc.HTTPError(404);
|
|
||||||
});
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(getManifestSpy).toHaveBeenCalled();
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Attempting to download ${versionSpec}...`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Not found in manifest. Falling back to download directly from Node'
|
|
||||||
);
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith(
|
|
||||||
`Node version ${versionSpec} for platform ${os.platform} and architecture ${os.arch} was found but failed to download. ` +
|
|
||||||
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
|
||||||
'To resolve this issue you may either fall back to the older version or try again later.'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('acquires specified architecture of node', async () => {
|
it('acquires specified architecture of node', async () => {
|
||||||
for (const {arch, version, osSpec} of [
|
for (const {arch, version, osSpec} of [
|
||||||
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
||||||
|
|||||||
@ -8,7 +8,7 @@ inputs:
|
|||||||
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.'
|
||||||
node-version-file:
|
node-version-file:
|
||||||
description: 'File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.'
|
description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions.'
|
||||||
architecture:
|
architecture:
|
||||||
description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.'
|
description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.'
|
||||||
check-latest:
|
check-latest:
|
||||||
@ -33,7 +33,7 @@ outputs:
|
|||||||
node-version:
|
node-version:
|
||||||
description: 'The installed node version.'
|
description: 'The installed node version.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node16'
|
||||||
main: 'dist/setup/index.js'
|
main: 'dist/setup/index.js'
|
||||||
post: 'dist/cache-save/index.js'
|
post: 'dist/cache-save/index.js'
|
||||||
post-if: success()
|
post-if: success()
|
||||||
|
|||||||
39385
dist/cache-save/index.js
vendored
39385
dist/cache-save/index.js
vendored
File diff suppressed because one or more lines are too long
54836
dist/setup/index.js
vendored
54836
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
@ -45,8 +45,8 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
@ -63,8 +63,8 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -84,8 +84,6 @@ When using the `package.json` input, the action will look for `volta.node` first
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Otherwise, when [`volta.extends`](https://docs.volta.sh/advanced/workspaces) is defined, then it will resolve the corresponding file and look for `volta.node` or `engines.node` recursively.
|
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
|
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
|
||||||
@ -97,8 +95,8 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
|
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
|
||||||
@ -118,8 +116,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '20.0.0-v8-canary' # it will install the latest v8 canary release for node 20.0.0
|
node-version: '20.0.0-v8-canary' # it will install the latest v8 canary release for node 20.0.0
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -133,8 +131,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '20-v8-canary' # it will install the latest v8 canary release for node 20
|
node-version: '20-v8-canary' # it will install the latest v8 canary release for node 20
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -149,8 +147,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 'v20.1.1-v8-canary20221103f7e2421e91'
|
node-version: 'v20.1.1-v8-canary20221103f7e2421e91'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -169,8 +167,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16-nightly' # it will install the latest nightly release for node 16
|
node-version: '16-nightly' # it will install the latest nightly release for node 16
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -185,8 +183,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16.0.0-nightly' # it will install the latest nightly release for node 16.0.0
|
node-version: '16.0.0-nightly' # it will install the latest nightly release for node 16.0.0
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -201,8 +199,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16.0.0-nightly20210420a0261d231c'
|
node-version: '16.0.0-nightly20210420a0261d231c'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -219,8 +217,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16.0.0-rc.1'
|
node-version: '16.0.0-rc.1'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@ -236,8 +234,8 @@ The action follows [actions/cache](https://github.com/actions/cache/blob/main/ex
|
|||||||
Yarn caching handles both yarn versions: 1 or 2.
|
Yarn caching handles both yarn versions: 1 or 2.
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
@ -255,11 +253,11 @@ steps:
|
|||||||
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
|
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: 6.32.9
|
version: 6.32.9
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -274,8 +272,8 @@ steps:
|
|||||||
**Using wildcard patterns to cache dependencies**
|
**Using wildcard patterns to cache dependencies**
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@ -287,8 +285,8 @@ steps:
|
|||||||
**Using a list of file paths to cache dependencies**
|
**Using a list of file paths to cache dependencies**
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@ -324,9 +322,9 @@ jobs:
|
|||||||
architecture: x86
|
architecture: x86
|
||||||
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
|
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
architecture: ${{ matrix.architecture }}
|
architecture: ${{ matrix.architecture }}
|
||||||
@ -337,8 +335,8 @@ jobs:
|
|||||||
## Publish to npmjs and GPR with npm
|
## Publish to npmjs and GPR with npm
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '14.x'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@ -346,7 +344,7 @@ steps:
|
|||||||
- run: npm publish
|
- run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
registry-url: 'https://npm.pkg.github.com'
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
- run: npm publish
|
- run: npm publish
|
||||||
@ -357,8 +355,8 @@ steps:
|
|||||||
## Publish to npmjs and GPR with yarn
|
## Publish to npmjs and GPR with yarn
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '14.x'
|
||||||
registry-url: <registry url>
|
registry-url: <registry url>
|
||||||
@ -366,7 +364,7 @@ steps:
|
|||||||
- run: yarn publish
|
- run: yarn publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
registry-url: 'https://npm.pkg.github.com'
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
- run: yarn publish
|
- run: yarn publish
|
||||||
@ -377,8 +375,8 @@ steps:
|
|||||||
## Use private packages
|
## Use private packages
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '14.x'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@ -397,8 +395,8 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '14.x'
|
||||||
- name: Setup .yarnrc.yml
|
- name: Setup .yarnrc.yml
|
||||||
|
|||||||
10011
package-lock.json
generated
10011
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-node",
|
"name": "setup-node",
|
||||||
"version": "4.0.0",
|
"version": "3.4.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup node action",
|
"description": "setup node action",
|
||||||
"main": "lib/setup-node.js",
|
"main": "lib/setup-node.js",
|
||||||
@ -25,33 +25,34 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.2.4",
|
"@actions/cache": "^3.0.4",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^1.1.0",
|
||||||
"@actions/glob": "^0.4.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/http-client": "^2.2.1",
|
"@actions/http-client": "^1.0.11",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^1.5.4",
|
||||||
"semver": "^7.6.0",
|
"lodash.memoize": "^4.1.2",
|
||||||
"uuid": "^9.0.1"
|
"semver": "^6.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^20.11.25",
|
"@types/lodash.memoize": "^4.1.7",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/node": "^16.11.25",
|
||||||
|
"@types/semver": "^6.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||||
"@typescript-eslint/parser": "^5.54.0",
|
"@typescript-eslint/parser": "^5.54.0",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"@vercel/ncc": "^0.33.4",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-jest": "^27.9.0",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^27.2.5",
|
||||||
"jest-each": "^29.7.0",
|
"jest-each": "^27.2.5",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^2.8.4",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^5.4.2"
|
"typescript": "^4.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,22 +12,12 @@ process.on('uncaughtException', e => {
|
|||||||
core.info(`${warningPrefix}${e.message}`);
|
core.info(`${warningPrefix}${e.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Added early exit to resolve issue with slow post action step:
|
export async function run() {
|
||||||
export async function run(earlyExit?: boolean) {
|
|
||||||
try {
|
try {
|
||||||
const cacheLock = core.getState(State.CachePackageManager);
|
const cacheLock = core.getState(State.CachePackageManager);
|
||||||
|
await cachePackages(cacheLock);
|
||||||
if (cacheLock) {
|
|
||||||
await cachePackages(cacheLock);
|
|
||||||
|
|
||||||
if (earlyExit) {
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
core.debug(`Caching for '${cacheLock}' is not supported`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed((error as Error).message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,4 +58,4 @@ const cachePackages = async (packageManager: string) => {
|
|||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
run(true);
|
run();
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
|
import memoize from 'lodash.memoize';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {unique} from './util';
|
import {unique} from './util';
|
||||||
@ -111,50 +112,38 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Expands (converts) the string input `cache-dependency-path` to list of directories that
|
||||||
|
* may be project roots
|
||||||
|
*
|
||||||
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache`
|
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache`
|
||||||
* - first through `getCacheDirectories`
|
* - first through `getCacheDirectories`
|
||||||
* - second from `repoHasYarn3ManagedCache`
|
* - second from `repoHasYarn3ManagedCache`
|
||||||
*
|
*
|
||||||
* it contains expensive IO operation and thus should be memoized
|
* it contains expensive IO operation and thus should be memoized
|
||||||
*/
|
*
|
||||||
|
|
||||||
let projectDirectoriesMemoized: string[] | null = null;
|
|
||||||
/**
|
|
||||||
* unit test must reset memoized variables
|
|
||||||
*/
|
|
||||||
export const resetProjectDirectoriesMemoized = () =>
|
|
||||||
(projectDirectoriesMemoized = null);
|
|
||||||
/**
|
|
||||||
* Expands (converts) the string input `cache-dependency-path` to list of directories that
|
|
||||||
* may be project roots
|
|
||||||
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
* expected to be the result of `core.getInput('cache-dependency-path')`
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
* @return list of directories and possible
|
* @return list of directories
|
||||||
*/
|
*/
|
||||||
const getProjectDirectoriesFromCacheDependencyPath = async (
|
export const getProjectDirectoriesFromCacheDependencyPath = memoize(
|
||||||
cacheDependencyPath: string
|
async (cacheDependencyPath: string): Promise<string[]> => {
|
||||||
): Promise<string[]> => {
|
const globber = await glob.create(cacheDependencyPath);
|
||||||
if (projectDirectoriesMemoized !== null) {
|
const cacheDependenciesPaths = await globber.glob();
|
||||||
return projectDirectoriesMemoized;
|
|
||||||
|
const existingDirectories: string[] = cacheDependenciesPaths
|
||||||
|
.map(path.dirname)
|
||||||
|
.filter(unique())
|
||||||
|
.map(dirName => fs.realpathSync(dirName))
|
||||||
|
.filter(directory => fs.lstatSync(directory).isDirectory());
|
||||||
|
|
||||||
|
if (!existingDirectories.length)
|
||||||
|
core.warning(
|
||||||
|
`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`
|
||||||
|
);
|
||||||
|
|
||||||
|
return existingDirectories;
|
||||||
}
|
}
|
||||||
|
);
|
||||||
const globber = await glob.create(cacheDependencyPath);
|
|
||||||
const cacheDependenciesPaths = await globber.glob();
|
|
||||||
|
|
||||||
const existingDirectories: string[] = cacheDependenciesPaths
|
|
||||||
.map(path.dirname)
|
|
||||||
.filter(unique())
|
|
||||||
.map(dirName => fs.realpathSync(dirName))
|
|
||||||
.filter(directory => fs.lstatSync(directory).isDirectory());
|
|
||||||
|
|
||||||
if (!existingDirectories.length)
|
|
||||||
core.warning(
|
|
||||||
`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`
|
|
||||||
);
|
|
||||||
|
|
||||||
projectDirectoriesMemoized = existingDirectories;
|
|
||||||
return existingDirectories;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the cache directories configured for the repo if cache-dependency-path is not empty
|
* Finds the cache directories configured for the repo if cache-dependency-path is not empty
|
||||||
|
|||||||
@ -16,12 +16,12 @@ export default abstract class BasePrereleaseNodejs extends BaseDistribution {
|
|||||||
const localVersionPaths = tc
|
const localVersionPaths = tc
|
||||||
.findAllVersions('node', this.nodeInfo.arch)
|
.findAllVersions('node', this.nodeInfo.arch)
|
||||||
.filter(i => {
|
.filter(i => {
|
||||||
const prerelease = semver.prerelease(i, {});
|
const prerelease = semver.prerelease(i);
|
||||||
if (!prerelease) {
|
if (!prerelease) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return prerelease[0].toString().includes(this.distribution);
|
return prerelease[0].includes(this.distribution);
|
||||||
});
|
});
|
||||||
localVersionPaths.sort(semver.rcompare);
|
localVersionPaths.sort(semver.rcompare);
|
||||||
const localVersion = this.evaluateVersions(localVersionPaths);
|
const localVersion = this.evaluateVersions(localVersionPaths);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import {v4 as uuidv4} from 'uuid';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as hc from '@actions/http-client';
|
import * as hc from '@actions/http-client';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@ -112,11 +111,7 @@ export default abstract class BaseDistribution {
|
|||||||
? `node-v${version}-win-${osArch}`
|
? `node-v${version}-win-${osArch}`
|
||||||
: `node-v${version}-${this.osPlat}-${osArch}`;
|
: `node-v${version}-${this.osPlat}-${osArch}`;
|
||||||
const urlFileName: string =
|
const urlFileName: string =
|
||||||
this.osPlat == 'win32'
|
this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
|
||||||
? this.nodeInfo.arch === 'arm64'
|
|
||||||
? `${fileName}.zip`
|
|
||||||
: `${fileName}.7z`
|
|
||||||
: `${fileName}.tar.gz`;
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
const initialUrl = this.getDistributionUrl();
|
||||||
const url = `${initialUrl}/v${version}/${urlFileName}`;
|
const url = `${initialUrl}/v${version}/${urlFileName}`;
|
||||||
|
|
||||||
@ -157,7 +152,7 @@ export default abstract class BaseDistribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected validRange(versionSpec: string) {
|
protected validRange(versionSpec: string) {
|
||||||
let options: semver.RangeOptions | undefined;
|
let options: semver.Options | undefined;
|
||||||
const c = semver.clean(versionSpec) || '';
|
const c = semver.clean(versionSpec) || '';
|
||||||
const valid = semver.valid(c) ?? versionSpec;
|
const valid = semver.valid(c) ?? versionSpec;
|
||||||
|
|
||||||
@ -171,8 +166,9 @@ export default abstract class BaseDistribution {
|
|||||||
const initialUrl = this.getDistributionUrl();
|
const initialUrl = this.getDistributionUrl();
|
||||||
const osArch: string = this.translateArchToDistUrl(arch);
|
const osArch: string = this.translateArchToDistUrl(arch);
|
||||||
|
|
||||||
// Create temporary folder to download to
|
// Create temporary folder to download in to
|
||||||
const tempDownloadFolder = `temp_${uuidv4()}`;
|
const tempDownloadFolder: string =
|
||||||
|
'temp_' + Math.floor(Math.random() * 2000000000);
|
||||||
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||||
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
||||||
const tempDir: string = path.join(tempDirectory, tempDownloadFolder);
|
const tempDir: string = path.join(tempDirectory, tempDownloadFolder);
|
||||||
@ -219,24 +215,12 @@ export default abstract class BaseDistribution {
|
|||||||
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 (this.osPlat == 'win32') {
|
if (this.osPlat == 'win32') {
|
||||||
const extension = this.nodeInfo.arch === 'arm64' ? '.zip' : '.7z';
|
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
|
||||||
// Rename archive to add extension because after downloading
|
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
|
||||||
// archive does not contain extension type and it leads to some issues
|
|
||||||
// on Windows runners without PowerShell Core.
|
|
||||||
//
|
|
||||||
// For default PowerShell Windows it should contain extension type to unpack it.
|
|
||||||
if (extension === '.zip') {
|
|
||||||
const renamedArchive = `${downloadPath}.zip`;
|
|
||||||
fs.renameSync(downloadPath, renamedArchive);
|
|
||||||
extPath = await tc.extractZip(renamedArchive);
|
|
||||||
} else {
|
|
||||||
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
|
|
||||||
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
|
|
||||||
}
|
|
||||||
// 7z extracts to folder matching file name
|
// 7z extracts to folder matching file name
|
||||||
const nestedPath = path.join(
|
const nestedPath = path.join(
|
||||||
extPath,
|
extPath,
|
||||||
path.basename(info.fileName, extension)
|
path.basename(info.fileName, '.7z')
|
||||||
);
|
);
|
||||||
if (fs.existsSync(nestedPath)) {
|
if (fs.existsSync(nestedPath)) {
|
||||||
extPath = nestedPath;
|
extPath = nestedPath;
|
||||||
@ -276,11 +260,7 @@ export default abstract class BaseDistribution {
|
|||||||
dataFileName = `osx-${osArch}-tar`;
|
dataFileName = `osx-${osArch}-tar`;
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
if (this.nodeInfo.arch === 'arm64') {
|
dataFileName = `win-${osArch}-exe`;
|
||||||
dataFileName = `win-${osArch}-zip`;
|
|
||||||
} else {
|
|
||||||
dataFileName = `win-${osArch}-exe`;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unexpected OS '${this.osPlat}'`);
|
throw new Error(`Unexpected OS '${this.osPlat}'`);
|
||||||
|
|||||||
@ -18,7 +18,6 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
let manifest: tc.IToolRelease[] | undefined;
|
let manifest: tc.IToolRelease[] | undefined;
|
||||||
let nodeJsVersions: INodeVersion[] | undefined;
|
let nodeJsVersions: INodeVersion[] | undefined;
|
||||||
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
|
|
||||||
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
||||||
core.info('Attempt to resolve LTS alias from manifest...');
|
core.info('Attempt to resolve LTS alias from manifest...');
|
||||||
|
|
||||||
@ -62,57 +61,63 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
|
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
this.addToolPath(toolPath);
|
} else {
|
||||||
return;
|
let downloadPath = '';
|
||||||
}
|
try {
|
||||||
|
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
||||||
|
|
||||||
let downloadPath = '';
|
const versionInfo = await this.getInfoFromManifest(
|
||||||
try {
|
this.nodeInfo.versionSpec,
|
||||||
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
this.nodeInfo.stable,
|
||||||
|
osArch,
|
||||||
const versionInfo = await this.getInfoFromManifest(
|
manifest
|
||||||
this.nodeInfo.versionSpec,
|
|
||||||
this.nodeInfo.stable,
|
|
||||||
osArch,
|
|
||||||
manifest
|
|
||||||
);
|
|
||||||
|
|
||||||
if (versionInfo) {
|
|
||||||
core.info(
|
|
||||||
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
|
|
||||||
);
|
|
||||||
downloadPath = await tc.downloadTool(
|
|
||||||
versionInfo.downloadUrl,
|
|
||||||
undefined,
|
|
||||||
this.nodeInfo.auth
|
|
||||||
);
|
);
|
||||||
|
if (versionInfo) {
|
||||||
|
core.info(
|
||||||
|
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
|
||||||
|
);
|
||||||
|
downloadPath = await tc.downloadTool(
|
||||||
|
versionInfo.downloadUrl,
|
||||||
|
undefined,
|
||||||
|
this.nodeInfo.auth
|
||||||
|
);
|
||||||
|
|
||||||
if (downloadPath) {
|
if (downloadPath) {
|
||||||
toolPath = await this.extractArchive(downloadPath, versionInfo);
|
toolPath = await this.extractArchive(downloadPath, versionInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
core.info(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (err) {
|
||||||
core.info(
|
// Rate limit?
|
||||||
'Not found in manifest. Falling back to download directly from Node'
|
if (
|
||||||
);
|
err instanceof tc.HTTPError &&
|
||||||
|
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
|
||||||
|
) {
|
||||||
|
core.info(
|
||||||
|
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.info(err.message);
|
||||||
|
}
|
||||||
|
core.debug(err.stack);
|
||||||
|
core.info('Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
// Rate limit?
|
|
||||||
if (
|
|
||||||
err instanceof tc.HTTPError &&
|
|
||||||
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
|
|
||||||
) {
|
|
||||||
core.info(
|
|
||||||
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
core.info((err as Error).message);
|
|
||||||
}
|
|
||||||
core.debug((err as Error).stack ?? 'empty stack');
|
|
||||||
core.info('Falling back to download directly from Node');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
toolPath = await this.downloadDirectlyFromNode();
|
const nodeJsVersions = await this.getNodeJsVersions();
|
||||||
|
const versions = this.filterVersions(nodeJsVersions);
|
||||||
|
const evaluatedVersion = this.evaluateVersions(versions);
|
||||||
|
if (!evaluatedVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
||||||
|
toolPath = await this.downloadNodejs(toolName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.osPlat != 'win32') {
|
if (this.osPlat != 'win32') {
|
||||||
@ -122,43 +127,6 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected addToolPath(toolPath: string) {
|
|
||||||
if (this.osPlat != 'win32') {
|
|
||||||
toolPath = path.join(toolPath, 'bin');
|
|
||||||
}
|
|
||||||
|
|
||||||
core.addPath(toolPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async downloadDirectlyFromNode() {
|
|
||||||
const nodeJsVersions = await this.getNodeJsVersions();
|
|
||||||
const versions = this.filterVersions(nodeJsVersions);
|
|
||||||
const evaluatedVersion = this.evaluateVersions(versions);
|
|
||||||
|
|
||||||
if (!evaluatedVersion) {
|
|
||||||
throw new Error(
|
|
||||||
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const toolPath = await this.downloadNodejs(toolName);
|
|
||||||
return toolPath;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
|
|
||||||
core.warning(
|
|
||||||
`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` +
|
|
||||||
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
|
||||||
'To resolve this issue you may either fall back to the older version or try again later.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected evaluateVersions(versions: string[]): string {
|
protected evaluateVersions(versions: string[]): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
|
|
||||||
@ -246,7 +214,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
return info?.resolvedVersion;
|
return info?.resolvedVersion;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.info('Unable to resolve version from manifest...');
|
core.info('Unable to resolve version from manifest...');
|
||||||
core.debug((err as Error).message);
|
core.debug(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/main.ts
17
src/main.ts
@ -1,5 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import * as auth from './authutil';
|
import * as auth from './authutil';
|
||||||
@ -7,7 +8,7 @@ import * as path from 'path';
|
|||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache} from './cache-restore';
|
||||||
import {isCacheFeatureAvailable} from './cache-utils';
|
import {isCacheFeatureAvailable} from './cache-utils';
|
||||||
import {getNodejsDistribution} from './distributions/installer-factory';
|
import {getNodejsDistribution} from './distributions/installer-factory';
|
||||||
import {getNodeVersionFromFile, printEnvDetailsAndSetOutput} from './util';
|
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
|
||||||
import {State} from './constants';
|
import {State} from './constants';
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
@ -74,7 +75,7 @@ export async function run() {
|
|||||||
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.setFailed((err as Error).message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,16 +99,14 @@ function resolveVersionInput(): string {
|
|||||||
versionFileInput
|
versionFileInput
|
||||||
);
|
);
|
||||||
|
|
||||||
const parsedVersion = getNodeVersionFromFile(versionFilePath);
|
if (!fs.existsSync(versionFilePath)) {
|
||||||
|
throw new Error(
|
||||||
if (parsedVersion) {
|
`The specified node version file at: ${versionFilePath} does not exist`
|
||||||
version = parsedVersion;
|
|
||||||
} else {
|
|
||||||
core.warning(
|
|
||||||
`Could not determine node version from ${versionFilePath}. Falling back`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version = parseNodeVersionFile(fs.readFileSync(versionFilePath, 'utf8'));
|
||||||
|
|
||||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
68
src/util.ts
68
src/util.ts
@ -1,70 +1,34 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
|
||||||
|
|
||||||
import fs from 'fs';
|
export function parseNodeVersionFile(contents: string): string {
|
||||||
import path from 'path';
|
let nodeVersion: string | undefined;
|
||||||
|
|
||||||
export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|
||||||
if (!fs.existsSync(versionFilePath)) {
|
|
||||||
throw new Error(
|
|
||||||
`The specified node version file at: ${versionFilePath} does not exist`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const contents = fs.readFileSync(versionFilePath, 'utf8');
|
|
||||||
|
|
||||||
// Try parsing the file as an NPM `package.json` file.
|
// Try parsing the file as an NPM `package.json` file.
|
||||||
try {
|
try {
|
||||||
const manifest = JSON.parse(contents);
|
nodeVersion = JSON.parse(contents).volta?.node;
|
||||||
|
if (!nodeVersion) nodeVersion = JSON.parse(contents).engines?.node;
|
||||||
// Presume package.json file.
|
|
||||||
if (typeof manifest === 'object' && !!manifest) {
|
|
||||||
// Support Volta.
|
|
||||||
// See https://docs.volta.sh/guide/understanding#managing-your-project
|
|
||||||
if (manifest.volta?.node) {
|
|
||||||
return manifest.volta.node;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manifest.engines?.node) {
|
|
||||||
return manifest.engines.node;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Support Volta workspaces.
|
|
||||||
// See https://docs.volta.sh/advanced/workspaces
|
|
||||||
if (manifest.volta?.extends) {
|
|
||||||
const extendedFilePath = path.resolve(
|
|
||||||
path.dirname(versionFilePath),
|
|
||||||
manifest.volta.extends
|
|
||||||
);
|
|
||||||
core.info('Resolving node version from ' + extendedFilePath);
|
|
||||||
return getNodeVersionFromFile(extendedFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If contents are an object, we parsed JSON
|
|
||||||
// this can happen if node-version-file is a package.json
|
|
||||||
// yet contains no volta.node or engines.node
|
|
||||||
//
|
|
||||||
// If node-version file is _not_ JSON, control flow
|
|
||||||
// will not have reached these lines.
|
|
||||||
//
|
|
||||||
// And because we've reached here, we know the contents
|
|
||||||
// *are* JSON, so no further string parsing makes sense.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
core.info('Node version file is not JSON file');
|
core.info('Node version file is not JSON file');
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
|
if (!nodeVersion) {
|
||||||
return found?.groups?.version ?? contents.trim();
|
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
|
||||||
|
nodeVersion = found?.groups?.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the case of an unknown format,
|
||||||
|
// return as is and evaluate the version separately.
|
||||||
|
if (!nodeVersion) nodeVersion = contents.trim();
|
||||||
|
|
||||||
|
return nodeVersion as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function printEnvDetailsAndSetOutput() {
|
export async function printEnvDetailsAndSetOutput() {
|
||||||
core.startGroup('Environment details');
|
core.startGroup('Environment details');
|
||||||
|
|
||||||
const promises = ['node', 'npm', 'yarn'].map(async tool => {
|
const promises = ['node', 'npm', 'yarn'].map(async tool => {
|
||||||
const pathTool = await io.which(tool, false);
|
const output = await getToolVersion(tool, ['--version']);
|
||||||
const output = pathTool ? await getToolVersion(tool, ['--version']) : '';
|
|
||||||
|
|
||||||
return {tool, output};
|
return {tool, output};
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user