mirror of
https://github.com/actions/setup-node.git
synced 2025-12-18 06:48:57 +08:00
Compare commits
84 Commits
malob/upda
...
v3.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeb10cff27 | ||
|
|
ed1a46e9f2 | ||
|
|
daff393d43 | ||
|
|
b14573ddb9 | ||
|
|
7569de03e7 | ||
|
|
b20a2561b9 | ||
|
|
ea3459bb45 | ||
|
|
141334fcd1 | ||
|
|
808c8f917f | ||
|
|
fd1b409bc3 | ||
|
|
9a03ebd9cc | ||
|
|
45e544a71a | ||
|
|
8c66f89aef | ||
|
|
3601f2a33e | ||
|
|
4d62fafc05 | ||
|
|
17f8bd9264 | ||
|
|
b067f78ed3 | ||
|
|
0bd06765ef | ||
|
|
25184c4485 | ||
|
|
337fdf2194 | ||
|
|
86bf502a33 | ||
|
|
146c4d84a5 | ||
|
|
56337c4255 | ||
|
|
76d3665dc0 | ||
|
|
5b52f097d3 | ||
|
|
75716637dc | ||
|
|
546fd45825 | ||
|
|
bacd6b4b3a | ||
|
|
bed538bd04 | ||
|
|
f3e93d1b9d | ||
|
|
ed960c9656 | ||
|
|
77f43a4400 | ||
|
|
9ced9a43a2 | ||
|
|
3e90744edf | ||
|
|
28df918a56 | ||
|
|
f099707f6e | ||
|
|
f658dc5bd7 | ||
|
|
5e2e068714 | ||
|
|
7a0f7a9962 | ||
|
|
7b558676dd | ||
|
|
1f8c6b94b2 | ||
|
|
9a74eb4e64 | ||
|
|
04c56d2f95 | ||
|
|
d08cf22211 | ||
|
|
360ab8b75b | ||
|
|
fd4bd829f2 | ||
|
|
a4b8ed2f4e | ||
|
|
270253e841 | ||
|
|
d1178716db | ||
|
|
041bafb672 | ||
|
|
996306e892 | ||
|
|
85d4122530 | ||
|
|
928244ce45 | ||
|
|
25316bbc1f | ||
|
|
76a4cff9ae | ||
|
|
a869e7cc2d | ||
|
|
a0cdab1110 | ||
|
|
4d0182af5e | ||
|
|
896ee80599 | ||
|
|
d21ecc7c5b | ||
|
|
d6e3b5539e | ||
|
|
db716f881a | ||
|
|
c24389f79e | ||
|
|
004fb83876 | ||
|
|
180b77fed2 | ||
|
|
9f31dbbbc4 | ||
|
|
aa759c6c94 | ||
|
|
0ae03de2b7 | ||
|
|
4bc87b8e10 | ||
|
|
b96348a4e9 | ||
|
|
3af302a4f2 | ||
|
|
f452812b44 | ||
|
|
f43d8a1f27 | ||
|
|
e93556ca66 | ||
|
|
0453e516eb | ||
|
|
399982b368 | ||
|
|
d278e78bdd | ||
|
|
fdbc93ea6e | ||
|
|
f24e78e0f6 | ||
|
|
3c1fbef7d3 | ||
|
|
5aa72c249a | ||
|
|
d9aab2aba4 | ||
|
|
162ddf7c40 | ||
|
|
38d90ce44d |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report
|
||||||
|
title: ''
|
||||||
|
labels: bug, needs triage
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Action version:**
|
||||||
|
Specify the action version
|
||||||
|
|
||||||
|
**Platform:**
|
||||||
|
- [ ] Ubuntu
|
||||||
|
- [ ] macOS
|
||||||
|
- [ ] Windows
|
||||||
|
|
||||||
|
**Runner type:**
|
||||||
|
- [ ] Hosted
|
||||||
|
- [ ] Self-hosted
|
||||||
|
|
||||||
|
**Tools version:**
|
||||||
|
<!--- Please specify versions of node and package manager (npm, yarn, pnpm and etc)-->
|
||||||
|
|
||||||
|
**Repro steps:**
|
||||||
|
A description with steps to reproduce the issue. If you have a public example or repo to share, please provide the link.
|
||||||
|
|
||||||
|
**Expected behavior:**
|
||||||
|
A description of what you expected to happen.
|
||||||
|
|
||||||
|
**Actual behavior:**
|
||||||
|
A description of what is actually happening.
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: feature request, needs triage
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
Describe your proposal.
|
||||||
|
|
||||||
|
**Justification:**
|
||||||
|
Justification or a use case for your proposal.
|
||||||
|
|
||||||
|
**Are you willing to submit a PR?**
|
||||||
|
<!--- We accept contributions! -->
|
||||||
9
.github/pull_request_template.md
vendored
Normal file
9
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
**Description:**
|
||||||
|
Describe your changes.
|
||||||
|
|
||||||
|
**Related issue:**
|
||||||
|
Add link to the related issue.
|
||||||
|
|
||||||
|
**Check list:**
|
||||||
|
- [ ] Mark if documentation changes are required.
|
||||||
|
- [ ] Mark if tests were added or updated to cover the changes.
|
||||||
18
.github/workflows/build-test.yml
vendored
18
.github/workflows/build-test.yml
vendored
@@ -3,14 +3,14 @@ name: build-test
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/*
|
- releases/*
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -18,15 +18,13 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node 12
|
- name: Setup Node 16.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- name: Verify no unstaged changes
|
|
||||||
if: runner.os != 'windows'
|
|
||||||
run: __tests__/verify-no-unstaged-changes.sh
|
|
||||||
|
|||||||
52
.github/workflows/check-dist.yml
vendored
Normal file
52
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# `dist/index.js` is a special file in Actions.
|
||||||
|
# When you reference an action with `uses:` in a workflow,
|
||||||
|
# `index.js` is the code that will run.
|
||||||
|
# For our project, we generate this file through a build process from other source files.
|
||||||
|
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||||
|
name: Check dist/
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-dist:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Node 16.x
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Rebuild the dist/ directory
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Compare the expected and actual dist/ directories
|
||||||
|
run: |
|
||||||
|
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||||
|
echo "Detected uncommitted changes after build. See status below:"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id: diff
|
||||||
|
|
||||||
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
||||||
45
.github/workflows/e2e-cache.yml
vendored
45
.github/workflows/e2e-cache.yml
vendored
@@ -10,7 +10,7 @@ on:
|
|||||||
- releases/*
|
- releases/*
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
node-npm-depencies-caching:
|
node-npm-depencies-caching:
|
||||||
name: Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
name: Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
@@ -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@v2
|
- 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
|
||||||
@@ -35,6 +35,39 @@ jobs:
|
|||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
node-pnpm-depencies-caching:
|
||||||
|
name: Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
node-version: [12, 14, 16]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
|
version: 6.10.0
|
||||||
|
- name: Generate pnpm file
|
||||||
|
run: pnpm install
|
||||||
|
- name: Remove dependencies
|
||||||
|
shell: pwsh
|
||||||
|
run: Remove-Item node_modules -Force -Recurse
|
||||||
|
- name: Clean global cache
|
||||||
|
run: rm -rf ~/.pnpm-store
|
||||||
|
shell: bash
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'pnpm'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
- name: Verify node and pnpm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
node-yarn1-depencies-caching:
|
node-yarn1-depencies-caching:
|
||||||
name: Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
name: Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -44,7 +77,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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Yarn version
|
- name: Yarn version
|
||||||
run: yarn --version
|
run: yarn --version
|
||||||
- name: Generate yarn file
|
- name: Generate yarn file
|
||||||
@@ -68,13 +101,15 @@ jobs:
|
|||||||
node-yarn2-depencies-caching:
|
node-yarn2-depencies-caching:
|
||||||
name: Test yarn 2 (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:
|
||||||
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Update yarn
|
- name: Update yarn
|
||||||
run: yarn set version berry
|
run: yarn set version berry
|
||||||
- name: Yarn version
|
- name: Yarn version
|
||||||
@@ -98,4 +133,4 @@ jobs:
|
|||||||
run: yarn install
|
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
|
||||||
|
|||||||
14
.github/workflows/licensed.yml
vendored
14
.github/workflows/licensed.yml
vendored
@@ -1,20 +1,24 @@
|
|||||||
name: Licensed
|
name: Licensed
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push: {branches: main}
|
push:
|
||||||
pull_request: {branches: main}
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Install licensed
|
- name: Install licensed
|
||||||
run: |
|
run: |
|
||||||
cd $RUNNER_TEMP
|
cd $RUNNER_TEMP
|
||||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
|
||||||
sudo tar -xzf licensed.tar.gz
|
sudo tar -xzf licensed.tar.gz
|
||||||
sudo mv licensed /usr/local/bin/licensed
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
- run: licensed status
|
- run: licensed status
|
||||||
|
|||||||
16
.github/workflows/proxy.yml
vendored
16
.github/workflows/proxy.yml
vendored
@@ -3,19 +3,17 @@ name: proxy
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
- releases/*
|
- releases/*
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-proxy:
|
test-proxy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
options: --dns 127.0.0.1
|
options: --dns 127.0.0.1
|
||||||
@@ -27,7 +25,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
https_proxy: http://squid-proxy:3128
|
https_proxy: http://squid-proxy:3128
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
||||||
@@ -39,13 +37,11 @@ jobs:
|
|||||||
|
|
||||||
test-bypass-proxy:
|
test-bypass-proxy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
env:
|
env:
|
||||||
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@v2
|
- 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
|
||||||
|
|||||||
76
.github/workflows/versions.yml
vendored
76
.github/workflows/versions.yml
vendored
@@ -3,14 +3,14 @@ name: versions
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/*
|
- releases/*
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
local-cache:
|
local-cache:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -35,13 +35,21 @@ 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: [lts/dubnium, lts/erbium, lts/fermium, lts/*]
|
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
check-latest: true
|
||||||
|
- if: runner.os != 'Windows'
|
||||||
|
name: Verify node and npm
|
||||||
|
run: |
|
||||||
|
. "$NVM_DIR/nvm.sh"
|
||||||
|
[[ $(nvm version-remote "${{ matrix.node-version }}") =~ ^v([^.]+) ]]
|
||||||
|
__tests__/verify-node.sh "${BASH_REMATCH[1]}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
manifest:
|
manifest:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -51,7 +59,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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -68,7 +76,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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node and check latest
|
- name: Setup Node and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -78,6 +86,21 @@ jobs:
|
|||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
version-file:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/.nvmrc'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 14
|
||||||
|
|
||||||
node-dist:
|
node-dist:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -86,7 +109,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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node from dist
|
- name: Setup Node from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -102,7 +125,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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: ./
|
||||||
@@ -115,7 +138,7 @@ jobs:
|
|||||||
arch:
|
arch:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node 14 x86 from dist
|
- name: Setup node 14 x86 from dist
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -124,3 +147,34 @@ jobs:
|
|||||||
- name: Verify node
|
- name: Verify node
|
||||||
run: __tests__/verify-arch.sh "ia32"
|
run: __tests__/verify-arch.sh "ia32"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
node-latest-aliases:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
node-version: [current, latest, node]
|
||||||
|
steps:
|
||||||
|
- name: Get node version
|
||||||
|
run: |
|
||||||
|
latestNodeVersion=$(curl https://nodejs.org/dist/index.json | jq -r '. [0].version')
|
||||||
|
echo "::set-output name=LATEST_NODE_VERSION::$latestNodeVersion"
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Retrieve version after install
|
||||||
|
run: |
|
||||||
|
updatedVersion=$(echo $(node --version))
|
||||||
|
echo "::set-output name=NODE_VERSION_UPDATED::$updatedVersion"
|
||||||
|
id: updatedVersion
|
||||||
|
shell: bash
|
||||||
|
- name: Compare versions
|
||||||
|
if: ${{ steps.version.outputs.LATEST_NODE_VERSION != steps.updatedVersion.outputs.NODE_VERSION_UPDATED}}
|
||||||
|
run: |
|
||||||
|
echo "Latest node version failed to download."
|
||||||
|
exit 1
|
||||||
|
|||||||
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.6.dep.yml
generated
BIN
.licenses/npm/@actions/http-client-1.0.6.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-asynciterator-polyfill.dep.yml
generated
BIN
.licenses/npm/@azure/core-asynciterator-polyfill.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-http.dep.yml
generated
BIN
.licenses/npm/@azure/core-http.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/logger.dep.yml
generated
BIN
.licenses/npm/@azure/logger.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@opencensus/web-types.dep.yml
generated
BIN
.licenses/npm/@opencensus/web-types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
BIN
.licenses/npm/@types/node.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Normal file
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
BIN
.licenses/npm/node-fetch.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
Normal file
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/whatwg-url.dep.yml
generated
Normal file
BIN
.licenses/npm/whatwg-url.dep.yml
generated
Normal file
Binary file not shown.
@@ -1 +1 @@
|
|||||||
* @actions/spark
|
* @actions/actions-service
|
||||||
|
|||||||
107
README.md
107
README.md
@@ -1,110 +1,129 @@
|
|||||||
# setup-node
|
# setup-node
|
||||||
|
|
||||||
<p align="left">
|
[](https://github.com/actions/setup-node/actions/workflows/build-test.yml)
|
||||||
<a href="https://github.com/actions/setup-node/actions?query=workflow%3Abuild-test"><img alt="build-test status" src="https://github.com/actions/setup-node/workflows/build-test/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aversions"><img alt="versions status" src="https://github.com/actions/setup-node/workflows/versions/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aproxy"><img alt="proxy status" src="https://github.com/actions/setup-node/workflows/proxy/badge.svg"></a>
|
[](https://github.com/actions/setup-node/actions/workflows/versions.yml)
|
||||||
</p>
|
[](https://github.com/actions/setup-node/actions/workflows/proxy.yml)
|
||||||
|
|
||||||
This action provides the following functionality for GitHub Actions users:
|
This action provides the following functionality for GitHub Actions users:
|
||||||
|
|
||||||
- Optionally downloading and caching distribution of the requested Node.js version, and adding it to the PATH
|
- Optionally downloading and caching distribution of the requested Node.js version, and adding it to the PATH
|
||||||
- Optionally caching npm/yarn dependencies
|
- Optionally caching npm/yarn/pnpm dependencies
|
||||||
- Registering problem matchers for error output
|
- Registering problem matchers for error output
|
||||||
- Configuring authentication for GPR or npm
|
- Configuring authentication for GPR or npm
|
||||||
|
|
||||||
# Usage
|
## Usage
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml)
|
||||||
|
|
||||||
**Basic:**
|
**Basic:**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: 14
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and don't rely on the system one.
|
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and don't rely on the system one.
|
||||||
|
|
||||||
The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
|
The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
|
||||||
|
|
||||||
For information regarding locally cached versions of Node.js on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).
|
For information regarding locally cached versions of Node.js on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).
|
||||||
|
|
||||||
#### Supported version syntax
|
### Supported version syntax
|
||||||
The `node-version` input supports the following syntax:
|
|
||||||
|
|
||||||
major versions: `12`, `14`, `16`
|
The `node-version` input supports the following values:
|
||||||
more specific versions: `10.15`, `14.2.0`, `16.3.0`
|
|
||||||
nvm lts syntax: `lts/erbium`, `lts/fermium`, `lts/*`
|
|
||||||
|
|
||||||
### Caching packages dependencies
|
- Major versions: `12`, `14`, `16`
|
||||||
|
- More specific versions: `10.15`, `14.2.0`, `16.3.0`
|
||||||
|
- NVM LTS syntax: `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n`
|
||||||
|
- Latest release: `latest`/`current`/`node`
|
||||||
|
|
||||||
The action has a built-in functionality for caching and restoring npm/yarn dependencies. Supported package managers are `npm`, `yarn`. The `cache` input is optional, and caching is turned off by default.
|
**Note:** Since the latest release will not be cached always, there is possibility of hitting rate limit when downloading from dist
|
||||||
|
|
||||||
|
### Checking in lockfiles
|
||||||
|
|
||||||
|
It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
|
||||||
|
|
||||||
|
## Caching global packages data
|
||||||
|
|
||||||
|
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
|
||||||
|
|
||||||
|
The action defaults to search for the dependency file (`package-lock.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.
|
||||||
|
|
||||||
|
**Note:** The action does not cache `node_modules`
|
||||||
|
|
||||||
|
See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-data) guide.
|
||||||
|
|
||||||
**Caching npm dependencies:**
|
**Caching npm dependencies:**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: 14
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
**Caching yarn dependencies:**
|
**Caching npm dependencies in monorepos:**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: 14
|
||||||
cache: 'yarn'
|
cache: 'npm'
|
||||||
- run: yarn install
|
cache-dependency-path: subdir/package-lock.json
|
||||||
- run: yarn test
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
```
|
```
|
||||||
Yarn caching handles both yarn versions: 1 or 2.
|
|
||||||
|
|
||||||
> At the moment, only `lock` files in the project root are supported.
|
## Matrix Testing
|
||||||
|
|
||||||
### Matrix Testing:
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: [ '12', '14', '16' ]
|
node: [ 12, 14, 16 ]
|
||||||
name: Node ${{ matrix.node }} sample
|
name: Node ${{ matrix.node }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced usage
|
## Advanced usage
|
||||||
|
|
||||||
1. [Check latest version](docs/advanced-usage.md#check-latest-version)
|
1. [Check latest version](docs/advanced-usage.md#check-latest-version)
|
||||||
2. [Using different architectures](docs/advanced-usage.md#architecture)
|
2. [Using a node version file](docs/advanced-usage.md#node-version-file)
|
||||||
3. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)
|
3. [Using different architectures](docs/advanced-usage.md#architecture)
|
||||||
4. [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
|
4. [Caching packages data](docs/advanced-usage.md#caching-packages-data)
|
||||||
5. [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
|
5. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)
|
||||||
6. [Using private packages](docs/advanced-usage.md#use-private-packages)
|
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)
|
||||||
|
|
||||||
# License
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
|
||||||
# Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
:wave: Be nice. See [our code of conduct](CONDUCT)
|
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||||
|
|||||||
@@ -14,14 +14,18 @@ describe('cache-restore', () => {
|
|||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
const commonPath = '/some/random/path';
|
const commonPath = '/some/random/path';
|
||||||
const npmCachePath = `${commonPath}/npm`;
|
const npmCachePath = `${commonPath}/npm`;
|
||||||
|
const pnpmCachePath = `${commonPath}/pnpm`;
|
||||||
const yarn1CachePath = `${commonPath}/yarn1`;
|
const yarn1CachePath = `${commonPath}/yarn1`;
|
||||||
const yarn2CachePath = `${commonPath}/yarn2`;
|
const yarn2CachePath = `${commonPath}/yarn2`;
|
||||||
const yarnFileHash =
|
const yarnFileHash =
|
||||||
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
||||||
const npmFileHash =
|
const npmFileHash =
|
||||||
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
||||||
|
const pnpmFileHash =
|
||||||
|
'26309058093e84713f38869c50cf1cee9b08155ede874ec1b44ce3fca8c68c70';
|
||||||
const cachesObject = {
|
const cachesObject = {
|
||||||
[npmCachePath]: npmFileHash,
|
[npmCachePath]: npmFileHash,
|
||||||
|
[pnpmCachePath]: pnpmFileHash,
|
||||||
[yarn1CachePath]: yarnFileHash,
|
[yarn1CachePath]: yarnFileHash,
|
||||||
[yarn2CachePath]: yarnFileHash
|
[yarn2CachePath]: yarnFileHash
|
||||||
};
|
};
|
||||||
@@ -30,6 +34,8 @@ describe('cache-restore', () => {
|
|||||||
switch (command) {
|
switch (command) {
|
||||||
case utils.supportedPackageManagers.npm.getCacheFolderCommand:
|
case utils.supportedPackageManagers.npm.getCacheFolderCommand:
|
||||||
return npmCachePath;
|
return npmCachePath;
|
||||||
|
case utils.supportedPackageManagers.pnpm.getCacheFolderCommand:
|
||||||
|
return pnpmCachePath;
|
||||||
case utils.supportedPackageManagers.yarn1.getCacheFolderCommand:
|
case utils.supportedPackageManagers.yarn1.getCacheFolderCommand:
|
||||||
return yarn1CachePath;
|
return yarn1CachePath;
|
||||||
case utils.supportedPackageManagers.yarn2.getCacheFolderCommand:
|
case utils.supportedPackageManagers.yarn2.getCacheFolderCommand:
|
||||||
@@ -66,6 +72,8 @@ describe('cache-restore', () => {
|
|||||||
hashFilesSpy.mockImplementation((pattern: string) => {
|
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||||
if (pattern.includes('package-lock.json')) {
|
if (pattern.includes('package-lock.json')) {
|
||||||
return npmFileHash;
|
return npmFileHash;
|
||||||
|
} else if (pattern.includes('pnpm-lock.yaml')) {
|
||||||
|
return pnpmFileHash;
|
||||||
} else if (pattern.includes('yarn.lock')) {
|
} else if (pattern.includes('yarn.lock')) {
|
||||||
return yarnFileHash;
|
return yarnFileHash;
|
||||||
} else {
|
} else {
|
||||||
@@ -97,7 +105,7 @@ describe('cache-restore', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Validate provided package manager', () => {
|
describe('Validate provided package manager', () => {
|
||||||
it.each([['npm7'], ['npm6'], ['yarn1'], ['yarn2'], ['random']])(
|
it.each([['npm7'], ['npm6'], ['pnpm6'], ['yarn1'], ['yarn2'], ['random']])(
|
||||||
'Throw an error because %s is not supported',
|
'Throw an error because %s is not supported',
|
||||||
async packageManager => {
|
async packageManager => {
|
||||||
await expect(restoreCache(packageManager)).rejects.toThrowError(
|
await expect(restoreCache(packageManager)).rejects.toThrowError(
|
||||||
@@ -111,7 +119,8 @@ describe('cache-restore', () => {
|
|||||||
it.each([
|
it.each([
|
||||||
['yarn', '2.1.2', yarnFileHash],
|
['yarn', '2.1.2', yarnFileHash],
|
||||||
['yarn', '1.2.3', yarnFileHash],
|
['yarn', '1.2.3', yarnFileHash],
|
||||||
['npm', '', npmFileHash]
|
['npm', '', npmFileHash],
|
||||||
|
['pnpm', '', pnpmFileHash]
|
||||||
])(
|
])(
|
||||||
'restored dependencies for %s',
|
'restored dependencies for %s',
|
||||||
async (packageManager, toolVersion, fileHash) => {
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
@@ -131,6 +140,7 @@ describe('cache-restore', () => {
|
|||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -139,7 +149,8 @@ describe('cache-restore', () => {
|
|||||||
it.each([
|
it.each([
|
||||||
['yarn', '2.1.2', yarnFileHash],
|
['yarn', '2.1.2', yarnFileHash],
|
||||||
['yarn', '1.2.3', yarnFileHash],
|
['yarn', '1.2.3', yarnFileHash],
|
||||||
['npm', '', npmFileHash]
|
['npm', '', npmFileHash],
|
||||||
|
['pnpm', '', pnpmFileHash]
|
||||||
])(
|
])(
|
||||||
'dependencies are changed %s',
|
'dependencies are changed %s',
|
||||||
async (packageManager, toolVersion, fileHash) => {
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
@@ -157,6 +168,7 @@ describe('cache-restore', () => {
|
|||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
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 fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import * as utils from '../src/cache-utils';
|
import * as utils from '../src/cache-utils';
|
||||||
@@ -12,6 +13,8 @@ describe('run', () => {
|
|||||||
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
||||||
const npmFileHash =
|
const npmFileHash =
|
||||||
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
||||||
|
const pnpmFileHash =
|
||||||
|
'26309058093e84713f38869c50cf1cee9b08155ede874ec1b44ce3fca8c68c70';
|
||||||
const commonPath = '/some/random/path';
|
const commonPath = '/some/random/path';
|
||||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ describe('run', () => {
|
|||||||
let saveCacheSpy: jest.SpyInstance;
|
let saveCacheSpy: jest.SpyInstance;
|
||||||
let getCommandOutputSpy: jest.SpyInstance;
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
let hashFilesSpy: jest.SpyInstance;
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
getInputSpy = jest.spyOn(core, 'getInput');
|
getInputSpy = jest.spyOn(core, 'getInput');
|
||||||
@@ -61,10 +65,17 @@ describe('run', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
existsSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
describe('Package manager validation', () => {
|
describe('Package manager validation', () => {
|
||||||
it('Package manager is not provided, skip caching', async () => {
|
it('Package manager is not provided, skip caching', async () => {
|
||||||
inputs['cache'] = '';
|
inputs['cache'] = '';
|
||||||
@@ -150,6 +161,23 @@ describe('run', () => {
|
|||||||
);
|
);
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not save cache for pnpm', async () => {
|
||||||
|
inputs['cache'] = 'pnpm';
|
||||||
|
getStateSpy.mockImplementation(() => pnpmFileHash);
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/pnpm`);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(debugSpy).toHaveBeenCalledWith(`pnpm path is ${commonPath}/pnpm`);
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('action saves the cache', () => {
|
describe('action saves the cache', () => {
|
||||||
@@ -239,6 +267,33 @@ describe('run', () => {
|
|||||||
);
|
);
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('saves cache from pnpm', async () => {
|
||||||
|
inputs['cache'] = 'pnpm';
|
||||||
|
getStateSpy.mockImplementation((name: string) => {
|
||||||
|
if (name === State.CacheMatchedKey) {
|
||||||
|
return pnpmFileHash;
|
||||||
|
} else {
|
||||||
|
return npmFileHash;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/pnpm`);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(debugSpy).toHaveBeenCalledWith(`pnpm path is ${commonPath}/pnpm`);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@@ -1,39 +1,35 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as utils from '../src/cache-utils';
|
import * as utils from '../src/cache-utils';
|
||||||
import {PackageManagerInfo} from '../src/cache-utils';
|
import {PackageManagerInfo, isCacheFeatureAvailable} from '../src/cache-utils';
|
||||||
|
|
||||||
describe('cache-utils', () => {
|
describe('cache-utils', () => {
|
||||||
const commonPath = '/some/random/path';
|
|
||||||
const versionYarn1 = '1.2.3';
|
const versionYarn1 = '1.2.3';
|
||||||
const versionYarn2 = '2.3.4';
|
|
||||||
|
|
||||||
let debugSpy: jest.SpyInstance;
|
let debugSpy: jest.SpyInstance;
|
||||||
let getCommandOutputSpy: jest.SpyInstance;
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
|
let isFeatureAvailable: jest.SpyInstance;
|
||||||
function getPackagePath(name: string) {
|
let info: jest.SpyInstance;
|
||||||
if (name === utils.supportedPackageManagers.npm.getCacheFolderCommand) {
|
let warningSpy: jest.SpyInstance;
|
||||||
return `${commonPath}/npm`;
|
|
||||||
} else {
|
|
||||||
if (name === utils.supportedPackageManagers.yarn1.getCacheFolderCommand) {
|
|
||||||
return `${commonPath}/yarn1`;
|
|
||||||
} else {
|
|
||||||
return `${commonPath}/yarn2`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
debugSpy = jest.spyOn(core, 'debug');
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
debugSpy.mockImplementation(msg => {});
|
debugSpy.mockImplementation(msg => {});
|
||||||
|
|
||||||
|
info = jest.spyOn(core, 'info');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
|
||||||
|
isFeatureAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getPackageManagerInfo', () => {
|
describe('getPackageManagerInfo', () => {
|
||||||
it.each<[string, PackageManagerInfo | null]>([
|
it.each<[string, PackageManagerInfo | null]>([
|
||||||
['npm', utils.supportedPackageManagers.npm],
|
['npm', utils.supportedPackageManagers.npm],
|
||||||
|
['pnpm', utils.supportedPackageManagers.pnpm],
|
||||||
['yarn', utils.supportedPackageManagers.yarn1],
|
['yarn', utils.supportedPackageManagers.yarn1],
|
||||||
['yarn1', null],
|
['yarn1', null],
|
||||||
['yarn2', null],
|
['yarn2', null],
|
||||||
@@ -46,7 +42,32 @@ describe('cache-utils', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES is false', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => false);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
||||||
|
|
||||||
|
expect(() => isCacheFeatureAvailable()).toThrowError(
|
||||||
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES has an interhal error', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => false);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
|
isCacheFeatureAvailable();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES is available', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => true);
|
||||||
|
|
||||||
|
expect(isCacheFeatureAvailable()).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|||||||
1
__tests__/data/.nvmrc
Normal file
1
__tests__/data/.nvmrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
v14
|
||||||
360
__tests__/data/pnpm-lock.yaml
generated
Normal file
360
__tests__/data/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
lockfileVersion: 5.3
|
||||||
|
|
||||||
|
specifiers:
|
||||||
|
express: ^4.17.1
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
express: 4.17.1
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
/accepts/1.3.7:
|
||||||
|
resolution: {integrity: sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
mime-types: 2.1.31
|
||||||
|
negotiator: 0.6.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/array-flatten/1.1.1:
|
||||||
|
resolution: {integrity: sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/body-parser/1.19.0:
|
||||||
|
resolution: {integrity: sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dependencies:
|
||||||
|
bytes: 3.1.0
|
||||||
|
content-type: 1.0.4
|
||||||
|
debug: 2.6.9
|
||||||
|
depd: 1.1.2
|
||||||
|
http-errors: 1.7.2
|
||||||
|
iconv-lite: 0.4.24
|
||||||
|
on-finished: 2.3.0
|
||||||
|
qs: 6.7.0
|
||||||
|
raw-body: 2.4.0
|
||||||
|
type-is: 1.6.18
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/bytes/3.1.0:
|
||||||
|
resolution: {integrity: sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/content-disposition/0.5.3:
|
||||||
|
resolution: {integrity: sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
safe-buffer: 5.1.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/content-type/1.0.4:
|
||||||
|
resolution: {integrity: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/cookie-signature/1.0.6:
|
||||||
|
resolution: {integrity: sha1-4wOogrNCzD7oylE6eZmXNNqzriw=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/cookie/0.4.0:
|
||||||
|
resolution: {integrity: sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/debug/2.6.9:
|
||||||
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
|
dependencies:
|
||||||
|
ms: 2.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/depd/1.1.2:
|
||||||
|
resolution: {integrity: sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/destroy/1.0.4:
|
||||||
|
resolution: {integrity: sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/ee-first/1.1.1:
|
||||||
|
resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/encodeurl/1.0.2:
|
||||||
|
resolution: {integrity: sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/escape-html/1.0.3:
|
||||||
|
resolution: {integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/etag/1.8.1:
|
||||||
|
resolution: {integrity: sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/express/4.17.1:
|
||||||
|
resolution: {integrity: sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==}
|
||||||
|
engines: {node: '>= 0.10.0'}
|
||||||
|
dependencies:
|
||||||
|
accepts: 1.3.7
|
||||||
|
array-flatten: 1.1.1
|
||||||
|
body-parser: 1.19.0
|
||||||
|
content-disposition: 0.5.3
|
||||||
|
content-type: 1.0.4
|
||||||
|
cookie: 0.4.0
|
||||||
|
cookie-signature: 1.0.6
|
||||||
|
debug: 2.6.9
|
||||||
|
depd: 1.1.2
|
||||||
|
encodeurl: 1.0.2
|
||||||
|
escape-html: 1.0.3
|
||||||
|
etag: 1.8.1
|
||||||
|
finalhandler: 1.1.2
|
||||||
|
fresh: 0.5.2
|
||||||
|
merge-descriptors: 1.0.1
|
||||||
|
methods: 1.1.2
|
||||||
|
on-finished: 2.3.0
|
||||||
|
parseurl: 1.3.3
|
||||||
|
path-to-regexp: 0.1.7
|
||||||
|
proxy-addr: 2.0.7
|
||||||
|
qs: 6.7.0
|
||||||
|
range-parser: 1.2.1
|
||||||
|
safe-buffer: 5.1.2
|
||||||
|
send: 0.17.1
|
||||||
|
serve-static: 1.14.1
|
||||||
|
setprototypeof: 1.1.1
|
||||||
|
statuses: 1.5.0
|
||||||
|
type-is: 1.6.18
|
||||||
|
utils-merge: 1.0.1
|
||||||
|
vary: 1.1.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/finalhandler/1.1.2:
|
||||||
|
resolution: {integrity: sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dependencies:
|
||||||
|
debug: 2.6.9
|
||||||
|
encodeurl: 1.0.2
|
||||||
|
escape-html: 1.0.3
|
||||||
|
on-finished: 2.3.0
|
||||||
|
parseurl: 1.3.3
|
||||||
|
statuses: 1.5.0
|
||||||
|
unpipe: 1.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/forwarded/0.2.0:
|
||||||
|
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/fresh/0.5.2:
|
||||||
|
resolution: {integrity: sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/http-errors/1.7.2:
|
||||||
|
resolution: {integrity: sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
depd: 1.1.2
|
||||||
|
inherits: 2.0.3
|
||||||
|
setprototypeof: 1.1.1
|
||||||
|
statuses: 1.5.0
|
||||||
|
toidentifier: 1.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/http-errors/1.7.3:
|
||||||
|
resolution: {integrity: sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
depd: 1.1.2
|
||||||
|
inherits: 2.0.4
|
||||||
|
setprototypeof: 1.1.1
|
||||||
|
statuses: 1.5.0
|
||||||
|
toidentifier: 1.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/iconv-lite/0.4.24:
|
||||||
|
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||||
|
engines: {node: '>=0.10.0'}
|
||||||
|
dependencies:
|
||||||
|
safer-buffer: 2.1.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/inherits/2.0.3:
|
||||||
|
resolution: {integrity: sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/inherits/2.0.4:
|
||||||
|
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/ipaddr.js/1.9.1:
|
||||||
|
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
|
||||||
|
engines: {node: '>= 0.10'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/media-typer/0.3.0:
|
||||||
|
resolution: {integrity: sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/merge-descriptors/1.0.1:
|
||||||
|
resolution: {integrity: sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/methods/1.1.2:
|
||||||
|
resolution: {integrity: sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/mime-db/1.48.0:
|
||||||
|
resolution: {integrity: sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/mime-types/2.1.31:
|
||||||
|
resolution: {integrity: sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
mime-db: 1.48.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/mime/1.6.0:
|
||||||
|
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
|
||||||
|
engines: {node: '>=4'}
|
||||||
|
hasBin: true
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/ms/2.0.0:
|
||||||
|
resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/ms/2.1.1:
|
||||||
|
resolution: {integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/negotiator/0.6.2:
|
||||||
|
resolution: {integrity: sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/on-finished/2.3.0:
|
||||||
|
resolution: {integrity: sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dependencies:
|
||||||
|
ee-first: 1.1.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/parseurl/1.3.3:
|
||||||
|
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/path-to-regexp/0.1.7:
|
||||||
|
resolution: {integrity: sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/proxy-addr/2.0.7:
|
||||||
|
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
|
||||||
|
engines: {node: '>= 0.10'}
|
||||||
|
dependencies:
|
||||||
|
forwarded: 0.2.0
|
||||||
|
ipaddr.js: 1.9.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/qs/6.7.0:
|
||||||
|
resolution: {integrity: sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==}
|
||||||
|
engines: {node: '>=0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/range-parser/1.2.1:
|
||||||
|
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/raw-body/2.4.0:
|
||||||
|
resolution: {integrity: sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dependencies:
|
||||||
|
bytes: 3.1.0
|
||||||
|
http-errors: 1.7.2
|
||||||
|
iconv-lite: 0.4.24
|
||||||
|
unpipe: 1.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/safe-buffer/5.1.2:
|
||||||
|
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/safer-buffer/2.1.2:
|
||||||
|
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/send/0.17.1:
|
||||||
|
resolution: {integrity: sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==}
|
||||||
|
engines: {node: '>= 0.8.0'}
|
||||||
|
dependencies:
|
||||||
|
debug: 2.6.9
|
||||||
|
depd: 1.1.2
|
||||||
|
destroy: 1.0.4
|
||||||
|
encodeurl: 1.0.2
|
||||||
|
escape-html: 1.0.3
|
||||||
|
etag: 1.8.1
|
||||||
|
fresh: 0.5.2
|
||||||
|
http-errors: 1.7.3
|
||||||
|
mime: 1.6.0
|
||||||
|
ms: 2.1.1
|
||||||
|
on-finished: 2.3.0
|
||||||
|
range-parser: 1.2.1
|
||||||
|
statuses: 1.5.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/serve-static/1.14.1:
|
||||||
|
resolution: {integrity: sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==}
|
||||||
|
engines: {node: '>= 0.8.0'}
|
||||||
|
dependencies:
|
||||||
|
encodeurl: 1.0.2
|
||||||
|
escape-html: 1.0.3
|
||||||
|
parseurl: 1.3.3
|
||||||
|
send: 0.17.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/setprototypeof/1.1.1:
|
||||||
|
resolution: {integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/statuses/1.5.0:
|
||||||
|
resolution: {integrity: sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/toidentifier/1.0.0:
|
||||||
|
resolution: {integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==}
|
||||||
|
engines: {node: '>=0.6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/type-is/1.6.18:
|
||||||
|
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
dependencies:
|
||||||
|
media-typer: 0.3.0
|
||||||
|
mime-types: 2.1.31
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/unpipe/1.0.0:
|
||||||
|
resolution: {integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/utils-merge/1.0.1:
|
||||||
|
resolution: {integrity: sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=}
|
||||||
|
engines: {node: '>= 0.4.0'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/vary/1.1.2:
|
||||||
|
resolution: {integrity: sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dev: false
|
||||||
@@ -1,157 +1,183 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"version": "14.0.0",
|
"version": "14.0.0",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"lts": "Fermium",
|
"lts": "Fermium",
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200423.30",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200507.99",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-14.0.0-darwin-x64.tar.gz",
|
"filename": "node-14.0.0-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-14.0.0-linux-x64.tar.gz",
|
"filename": "node-14.0.0-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-14.0.0-win32-x64.zip",
|
"filename": "node-14.0.0-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "13.13.0",
|
"version": "13.13.0",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200423.29",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200507.97",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-13.13.0-darwin-x64.tar.gz",
|
"filename": "node-13.13.0-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-13.13.0-linux-x64.tar.gz",
|
"filename": "node-13.13.0-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-13.13.0-win32-x64.zip",
|
"filename": "node-13.13.0-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "12.16.2",
|
"version": "12.16.2",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"lts": "Erbium",
|
"lts": "Erbium",
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200423.28",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200507.95",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-12.16.2-darwin-x64.tar.gz",
|
"filename": "node-12.16.2-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-12.16.2-linux-x64.tar.gz",
|
"filename": "node-12.16.2-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-12.16.2-win32-x64.zip",
|
"filename": "node-12.16.2-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "10.20.1",
|
"version": "12.0.0",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"lts": "Dubnium",
|
"lts": "Erbium",
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200423.27",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/12.0.0-20200507.71",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-10.20.1-darwin-x64.tar.gz",
|
"filename": "node-12.0.0-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-10.20.1-linux-x64.tar.gz",
|
"filename": "node-12.0.0-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-10.20.1-win32-x64.zip",
|
"filename": "node-12.0.0-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "8.17.0",
|
"version": "10.20.1",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"lts": "Carbon",
|
"lts": "Dubnium",
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200423.26",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200507.70",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-8.17.0-darwin-x64.tar.gz",
|
"filename": "node-10.20.1-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-8.17.0-linux-x64.tar.gz",
|
"filename": "node-10.20.1-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-8.17.0-win32-x64.zip",
|
"filename": "node-10.20.1-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "6.17.1",
|
"version": "8.17.0",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"lts": "Boron",
|
"lts": "Carbon",
|
||||||
"release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200423.25",
|
"release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200507.37",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"filename": "node-6.17.1-darwin-x64.tar.gz",
|
"filename": "node-8.17.0-darwin-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "darwin",
|
"platform": "darwin",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-darwin-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-darwin-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-6.17.1-linux-x64.tar.gz",
|
"filename": "node-8.17.0-linux-x64.tar.gz",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-linux-x64.tar.gz"
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-linux-x64.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "node-6.17.1-win32-x64.zip",
|
"filename": "node-8.17.0-win32-x64.7z",
|
||||||
"arch": "x64",
|
"arch": "x64",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-win32-x64.zip"
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-win32-x64.7z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
|
"version": "6.17.1",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Boron",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200529.2",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as im from '../src/installer';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import osm = require('os');
|
import osm = require('os');
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as im from '../src/installer';
|
|
||||||
import * as auth from '../src/authutil';
|
import * as auth from '../src/authutil';
|
||||||
|
|
||||||
let nodeTestManifest = require('./data/versions-manifest.json');
|
let nodeTestManifest = require('./data/versions-manifest.json');
|
||||||
@@ -31,9 +32,12 @@ describe('setup-node', () => {
|
|||||||
let dbgSpy: jest.SpyInstance;
|
let dbgSpy: jest.SpyInstance;
|
||||||
let whichSpy: jest.SpyInstance;
|
let whichSpy: jest.SpyInstance;
|
||||||
let existsSpy: jest.SpyInstance;
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let readFileSyncSpy: jest.SpyInstance;
|
||||||
let mkdirpSpy: jest.SpyInstance;
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
let execSpy: jest.SpyInstance;
|
let execSpy: jest.SpyInstance;
|
||||||
let authSpy: jest.SpyInstance;
|
let authSpy: jest.SpyInstance;
|
||||||
|
let parseNodeVersionSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// @actions/core
|
// @actions/core
|
||||||
@@ -58,12 +62,16 @@ describe('setup-node', () => {
|
|||||||
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
|
getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
|
||||||
|
parseNodeVersionSpy = jest.spyOn(im, 'parseNodeVersionFile');
|
||||||
|
|
||||||
// io
|
// io
|
||||||
whichSpy = jest.spyOn(io, 'which');
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
existsSpy = jest.spyOn(fs, 'existsSync');
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
// disable authentication portion for installer tests
|
// disable authentication portion for installer tests
|
||||||
authSpy = jest.spyOn(auth, 'configAuthentication');
|
authSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
authSpy.mockImplementation(() => {});
|
authSpy.mockImplementation(() => {});
|
||||||
@@ -91,6 +99,10 @@ describe('setup-node', () => {
|
|||||||
// uncomment to see debug output
|
// uncomment to see debug output
|
||||||
// process.stderr.write(msg + '\n');
|
// process.stderr.write(msg + '\n');
|
||||||
});
|
});
|
||||||
|
warningSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -101,6 +113,7 @@ describe('setup-node', () => {
|
|||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
jest.restoreAllMocks();
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@@ -113,7 +126,7 @@ describe('setup-node', () => {
|
|||||||
'mocktoken'
|
'mocktoken'
|
||||||
);
|
);
|
||||||
expect(versions).toBeDefined();
|
expect(versions).toBeDefined();
|
||||||
expect(versions?.length).toBe(6);
|
expect(versions?.length).toBe(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can mock dist versions', async () => {
|
it('can mock dist versions', async () => {
|
||||||
@@ -122,50 +135,28 @@ describe('setup-node', () => {
|
|||||||
expect(versions?.length).toBe(23);
|
expect(versions?.length).toBe(23);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can find 12.16.2 from manifest on osx', async () => {
|
it.each([
|
||||||
os.platform = 'darwin';
|
['12.16.2', 'darwin', '12.16.2', 'Erbium'],
|
||||||
os.arch = 'x64';
|
['12', 'linux', '12.16.2', 'Erbium'],
|
||||||
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
|
['10', 'win32', '10.20.1', 'Dubnium'],
|
||||||
'actions',
|
['*', 'linux', '14.0.0', 'Fermium']
|
||||||
'node-versions',
|
])(
|
||||||
'mocktoken'
|
'can find %s from manifest on %s',
|
||||||
);
|
async (versionSpec, platform, expectedVersion, expectedLts) => {
|
||||||
expect(versions).toBeDefined();
|
os.platform = platform;
|
||||||
let match = await tc.findFromManifest('12.16.2', true, versions);
|
os.arch = 'x64';
|
||||||
expect(match).toBeDefined();
|
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
|
||||||
expect(match?.version).toBe('12.16.2');
|
'actions',
|
||||||
expect((match as any).lts).toBe('Erbium');
|
'node-versions',
|
||||||
});
|
'mocktoken'
|
||||||
|
);
|
||||||
it('can find 12 from manifest on linux', async () => {
|
expect(versions).toBeDefined();
|
||||||
os.platform = 'linux';
|
let match = await tc.findFromManifest(versionSpec, true, versions);
|
||||||
os.arch = 'x64';
|
expect(match).toBeDefined();
|
||||||
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
|
expect(match?.version).toBe(expectedVersion);
|
||||||
'actions',
|
expect((match as any).lts).toBe(expectedLts);
|
||||||
'node-versions',
|
}
|
||||||
'mocktoken'
|
);
|
||||||
);
|
|
||||||
expect(versions).toBeDefined();
|
|
||||||
let match = await tc.findFromManifest('12.16.2', true, versions);
|
|
||||||
expect(match).toBeDefined();
|
|
||||||
expect(match?.version).toBe('12.16.2');
|
|
||||||
expect((match as any).lts).toBe('Erbium');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can find 10 from manifest on windows', async () => {
|
|
||||||
os.platform = 'win32';
|
|
||||||
os.arch = 'x64';
|
|
||||||
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
|
|
||||||
'actions',
|
|
||||||
'node-versions',
|
|
||||||
'mocktoken'
|
|
||||||
);
|
|
||||||
expect(versions).toBeDefined();
|
|
||||||
let match = await tc.findFromManifest('10', true, versions);
|
|
||||||
expect(match).toBeDefined();
|
|
||||||
expect(match?.version).toBe('10.20.1');
|
|
||||||
expect((match as any).lts).toBe('Dubnium');
|
|
||||||
});
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Found in cache tests
|
// Found in cache tests
|
||||||
@@ -237,7 +228,7 @@ describe('setup-node', () => {
|
|||||||
inputs['token'] = 'faketoken';
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
let expectedUrl =
|
let expectedUrl =
|
||||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
|
||||||
|
|
||||||
// ... but not in the local cache
|
// ... but not in the local cache
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
@@ -275,7 +266,7 @@ describe('setup-node', () => {
|
|||||||
inputs['token'] = 'faketoken';
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
let expectedUrl =
|
let expectedUrl =
|
||||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
|
||||||
|
|
||||||
// ... but not in the local cache
|
// ... but not in the local cache
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
@@ -343,7 +334,7 @@ describe('setup-node', () => {
|
|||||||
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
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'},
|
||||||
{arch: 'x86', version: '14.0.0', osSpec: 'win32'}
|
{arch: 'x86', version: '14.0.0', osSpec: 'win32'}
|
||||||
@@ -444,7 +435,7 @@ describe('setup-node', () => {
|
|||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
const expectedUrl =
|
const expectedUrl =
|
||||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
@@ -549,6 +540,136 @@ describe('setup-node', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('node-version-file flag', () => {
|
||||||
|
it('not used if node-version is provided', async () => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(parseNodeVersionSpy).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
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(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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(
|
||||||
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if node-version-file is not found', async () => {
|
||||||
|
const versionFile = '.nvmrc';
|
||||||
|
const versionFilePath = path.join(__dirname, '..', versionFile);
|
||||||
|
inputs['node-version-file'] = versionFile;
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
existsSpy.mockImplementationOnce(
|
||||||
|
input => input === path.join(__dirname, 'data', versionFile)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(existsSpy).toHaveBeenCalled();
|
||||||
|
expect(existsSpy).toHaveReturnedWith(false);
|
||||||
|
expect(parseNodeVersionSpy).not.toHaveBeenCalled();
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cache on GHES', () => {
|
||||||
|
it('Should throw an error, because cache is not supported', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => false);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should throw an internal error', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => false);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('LTS version', () => {
|
describe('LTS version', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
@@ -556,145 +677,102 @@ describe('setup-node', () => {
|
|||||||
inputs.stable = 'true';
|
inputs.stable = 'true';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('find latest LTS version and resolve it from local cache (lts/erbium)', async () => {
|
it.each([
|
||||||
// arrange
|
['erbium', '12.16.2'],
|
||||||
inputs['node-version'] = 'lts/erbium';
|
['*', '14.0.0'],
|
||||||
|
['-1', '12.16.2']
|
||||||
|
])(
|
||||||
|
'find latest LTS version and resolve it from local cache (lts/%s)',
|
||||||
|
async (lts, expectedVersion) => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = `lts/${lts}`;
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
findSpy.mockReturnValue(toolPath);
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempt to resolve LTS alias from manifest...'
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
`LTS alias '${lts}' for Node version 'lts/${lts}'`
|
||||||
);
|
);
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`Found LTS release '12.16.2' for Node version 'lts/erbium'`
|
`Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'`
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it('find latest LTS version and install it from manifest (lts/erbium)', async () => {
|
it.each([
|
||||||
// arrange
|
[
|
||||||
inputs['node-version'] = 'lts/erbium';
|
'erbium',
|
||||||
|
'12.16.2',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'*',
|
||||||
|
'14.0.0',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'-1',
|
||||||
|
'12.16.2',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'find latest LTS version and install it from manifest (lts/%s)',
|
||||||
|
async (lts, expectedVersion, expectedUrl) => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = `lts/${lts}`;
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
const expectedUrl =
|
const expectedMajor = expectedVersion.split('.')[0];
|
||||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
|
|
||||||
|
|
||||||
// act
|
// act
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempt to resolve LTS alias from manifest...'
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
'Getting manifest from actions/node-versions@main'
|
'Getting manifest from actions/node-versions@main'
|
||||||
);
|
);
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`LTS alias 'erbium' for Node version 'lts/erbium'`
|
`LTS alias '${lts}' for Node version 'lts/${lts}'`
|
||||||
);
|
);
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
`Found LTS release '12.16.2' for Node version 'lts/erbium'`
|
`Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'`
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith('Attempting to download 12...');
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
`Attempting to download ${expectedMajor}...`
|
||||||
`Acquiring 12.16.2 - ${os.arch} from ${expectedUrl}`
|
);
|
||||||
);
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
);
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
);
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
});
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
it('find latest LTS version and resolve it from local cache (lts/*)', async () => {
|
}
|
||||||
// arrange
|
);
|
||||||
inputs['node-version'] = 'lts/*';
|
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/14.0.0/x64');
|
|
||||||
findSpy.mockReturnValue(toolPath);
|
|
||||||
|
|
||||||
// act
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve LTS alias from manifest...'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
'Getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
`LTS alias '*' for Node version 'lts/*'`
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
`Found LTS release '14.0.0' for Node version 'lts/*'`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
|
||||||
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('find latest LTS version and install it from manifest (lts/*)', async () => {
|
|
||||||
// arrange
|
|
||||||
inputs['node-version'] = 'lts/*';
|
|
||||||
|
|
||||||
const toolPath = path.normalize('/cache/node/14.0.0/x64');
|
|
||||||
findSpy.mockImplementation(() => '');
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
|
||||||
const expectedUrl =
|
|
||||||
'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz';
|
|
||||||
|
|
||||||
// act
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
'Attempt to resolve LTS alias from manifest...'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
'Getting manifest from actions/node-versions@main'
|
|
||||||
);
|
|
||||||
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
`LTS alias '*' for Node version 'lts/*'`
|
|
||||||
);
|
|
||||||
expect(dbgSpy).toHaveBeenCalledWith(
|
|
||||||
`Found LTS release '14.0.0' for Node version 'lts/*'`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Attempting to download 14...');
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
|
||||||
`Acquiring 14.0.0 - ${os.arch} from ${expectedUrl}`
|
|
||||||
);
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
|
||||||
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fail with unable to parse LTS alias (lts/)', async () => {
|
it('fail with unable to parse LTS alias (lts/)', async () => {
|
||||||
// arrange
|
// arrange
|
||||||
@@ -766,4 +844,57 @@ describe('setup-node', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('latest alias syntax', () => {
|
||||||
|
it.each(['latest', 'current', 'node'])(
|
||||||
|
'download the %s version if alias is provided',
|
||||||
|
async inputVersion => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = inputVersion;
|
||||||
|
|
||||||
|
os.platform = 'darwin';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getManifestSpy.mockImplementation(() => {
|
||||||
|
throw new Error('Unable to download manifest');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Unable to download manifest');
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('getting latest node version...');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('latest alias syntax from cache', () => {
|
||||||
|
it.each(['latest', 'current', 'node'])(
|
||||||
|
'download the %s version if alias is provided',
|
||||||
|
async inputVersion => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = inputVersion;
|
||||||
|
const expectedVersion = nodeTestDist[0];
|
||||||
|
|
||||||
|
os.platform = 'darwin';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
`/cache/node/${expectedVersion.version}/x64`
|
||||||
|
);
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('getting latest node version...');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ "$(git status --porcelain)" != "" ]]; then
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo git status
|
|
||||||
echo ----------------------------------------
|
|
||||||
git status
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo git diff
|
|
||||||
echo ----------------------------------------
|
|
||||||
git diff
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo Troubleshooting
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run pre-checkin"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
29
action.yml
29
action.yml
@@ -1,34 +1,37 @@
|
|||||||
name: 'Setup Node.js environment'
|
name: 'Setup Node.js environment'
|
||||||
description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH'
|
description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
always-auth:
|
always-auth:
|
||||||
description: 'Set always-auth in npmrc'
|
description: 'Set always-auth in npmrc.'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
node-version:
|
node-version:
|
||||||
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0'
|
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.'
|
||||||
|
node-version-file:
|
||||||
|
description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version.'
|
||||||
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:
|
||||||
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec.'
|
||||||
default: false
|
default: false
|
||||||
registry-url:
|
registry-url:
|
||||||
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
|
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.'
|
||||||
scope:
|
scope:
|
||||||
description: 'Optional scope for authenticating against scoped registries'
|
description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).'
|
||||||
token:
|
token:
|
||||||
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user.
|
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
cache:
|
cache:
|
||||||
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn'
|
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
|
||||||
|
cache-dependency-path:
|
||||||
|
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
||||||
# TODO: add input to control forcing to pull from cloud or dist.
|
# TODO: add input to control forcing to pull from cloud or dist.
|
||||||
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
||||||
# Deprecated option, do not use. Will not be supported after October 1, 2019
|
outputs:
|
||||||
version:
|
cache-hit:
|
||||||
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
|
description: 'A boolean value to indicate if a cache was hit.'
|
||||||
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use node-version instead'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
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()
|
||||||
|
|||||||
105838
dist/cache-save/index.js
vendored
105838
dist/cache-save/index.js
vendored
File diff suppressed because one or more lines are too long
126596
dist/setup/index.js
vendored
126596
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
|||||||
# 0. Caching dependencies
|
# 0. Caching dependencies
|
||||||
Date: 2021-05-21
|
Date: 2021-05-21
|
||||||
|
|
||||||
Status: Proposed
|
Status: Accepted
|
||||||
|
|
||||||
# Context
|
# Context
|
||||||
`actions/setup-node` is the 2nd most popular action in GitHub Actions. A lot of customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependencies installation.
|
`actions/setup-node` is the 2nd most popular action in GitHub Actions. A lot of customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependencies installation.
|
||||||
|
|||||||
48
docs/adrs/0001-support-caching-deps-for-monorepos.md
Normal file
48
docs/adrs/0001-support-caching-deps-for-monorepos.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# 0. Support caching dependencies for mono repos
|
||||||
|
Date: 2021-07-13
|
||||||
|
|
||||||
|
Status: Proposed
|
||||||
|
|
||||||
|
## Context
|
||||||
|
Currently, `actions/setup-node` supports caching dependencies for Npm and Yarn package managers.
|
||||||
|
For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root.
|
||||||
|
Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities)
|
||||||
|
|
||||||
|
Obviously, it made build-in caching unusable for mono-repos and repos with complex structure.
|
||||||
|
We would like to revisit this decision and add customization for dependencies lock file location.
|
||||||
|
|
||||||
|
## Proposal
|
||||||
|
We have the following options:
|
||||||
|
1. Allow to specify directory where `package-lock.json` or `yarn.lock` are located
|
||||||
|
2. Allow to specify path to the dependencies lock file (including directory path and filename)
|
||||||
|
|
||||||
|
The second option looks more generic because it allows to:
|
||||||
|
- specify multiple dependencies files using file patterns like `**/package-lock.json` ([one of recommended approaches in actions/cache](https://github.com/actions/cache/blob/main/examples.md#macos-and-ubuntu))
|
||||||
|
- specify custom dependencies files like `src/npm-shrinkwrap.json`
|
||||||
|
- change default resolving priority if both `yarn.lock` and `package-lock.json` exist in repository
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
Add `cache-dependency-path` input that will accept path (relative to repository root) to dependencies lock file.
|
||||||
|
If provided path contains wildcards, the action will search all maching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does.
|
||||||
|
The hash of provided matched files will be used as a part of cache key.
|
||||||
|
|
||||||
|
Yaml examples:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: 'sub-project/package-lock.json'
|
||||||
|
```
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: yarn
|
||||||
|
cache-dependency-path: 'sub-project/**/yarn.lock'
|
||||||
|
```
|
||||||
@@ -1,6 +1,41 @@
|
|||||||
# Advanced usage
|
## Working with lockfiles
|
||||||
|
|
||||||
### Check latest version:
|
All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
|
||||||
|
|
||||||
|
- Enables faster installation for CI and production environments, due to being able to skip package resolution.
|
||||||
|
- Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
|
||||||
|
- Provides a facility for users to "time-travel" to previous states of `node_modules` without having to commit the directory itself.
|
||||||
|
- Facilitates greater visibility of tree changes through readable source control diffs.
|
||||||
|
|
||||||
|
In order to get the most out of using your lockfile on continuous integration follow the conventions outlined below for your respective package manager.
|
||||||
|
|
||||||
|
### NPM
|
||||||
|
|
||||||
|
Ensure that `package-lock.json` is always committed, use `npm ci` instead of `npm install` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Documentation of `package-lock.json`](https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json)
|
||||||
|
- [Documentation of `npm ci`](https://docs.npmjs.com/cli/v8/commands/npm-ci)
|
||||||
|
|
||||||
|
### Yarn
|
||||||
|
|
||||||
|
To ensure that `yarn.lock` is always committed, use `yarn install --immutable` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Documentation of `yarn.lock`](https://classic.yarnpkg.com/en/docs/yarn-lock)
|
||||||
|
- [Documentation of `--frozen-lockfile` option](https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-frozen-lockfile)
|
||||||
|
- [QA - Should lockfiles be committed to the repoistory?](https://yarnpkg.com/getting-started/qa/#should-lockfiles-be-committed-to-the-repository)
|
||||||
|
- [Documentation of `yarn install`](https://yarnpkg.com/cli/install)
|
||||||
|
|
||||||
|
### PNPM
|
||||||
|
|
||||||
|
Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lockfile` to `pnpm install` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles)
|
||||||
|
- [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile)
|
||||||
|
|
||||||
|
## Check latest version
|
||||||
|
|
||||||
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
|
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
|
||||||
|
|
||||||
@@ -10,16 +45,32 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '14'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Architecture:
|
## Node version file
|
||||||
|
|
||||||
|
The `node-version-file` input accepts a path to a file containing the version of Node.js to be used by a project, for example `.nvmrc` or `.node-version`. If both the `node-version` and the `node-version-file` inputs are provided then the `node-version` input is used.
|
||||||
|
See [supported version syntax](https://github.com/actions/setup-node#supported-version-syntax)
|
||||||
|
> The action will search for the node version file relative to the repository root.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
You can use any of the [supported operating systems](https://docs.github.com/en/actions/reference/virtual-environments-for-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/reference/virtual-environments-for-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).
|
||||||
|
|
||||||
@@ -30,16 +81,82 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
name: Node sample
|
name: Node sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- 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
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multiple Operating Systems and Architectures:
|
## 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.
|
||||||
|
|
||||||
|
**Caching yarn dependencies:**
|
||||||
|
Yarn caching handles both yarn versions: 1 or 2.
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: 'yarn'
|
||||||
|
- run: yarn install --frozen-lockfile # optional, --immutable
|
||||||
|
- run: yarn test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Caching pnpm (v6.10+) dependencies:**
|
||||||
|
```yaml
|
||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
|
version: 6.32.9
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: 'pnpm'
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using wildcard patterns to cache dependencies**
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: '**/package-lock.json'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using a list of file paths to cache dependencies**
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: |
|
||||||
|
server/app/package-lock.json
|
||||||
|
frontend/app/package-lock.json
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Multiple Operating Systems and Architectures
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@@ -64,29 +181,29 @@ 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@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
architecture: ${{ matrix.architecture }}
|
architecture: ${{ matrix.architecture }}
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Publish to npmjs and GPR with npm:
|
## Publish to npmjs and GPR with npm
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- 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'
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm publish
|
- run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
- uses: actions/setup-node@v2
|
- 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
|
||||||
@@ -94,19 +211,19 @@ steps:
|
|||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Publish to npmjs and GPR with yarn:
|
## Publish to npmjs and GPR with yarn
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '14.x'
|
||||||
registry-url: <registry url>
|
registry-url: <registry url>
|
||||||
- run: yarn install
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn publish
|
- run: yarn publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
||||||
- uses: actions/setup-node@v2
|
- 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
|
||||||
@@ -114,17 +231,17 @@ steps:
|
|||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use private packages:
|
## Use private packages
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v2
|
- 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'
|
||||||
# Skip post-install scripts here, as a malicious
|
# Skip post-install scripts here, as a malicious
|
||||||
# script could steal NODE_AUTH_TOKEN.
|
# script could steal NODE_AUTH_TOKEN.
|
||||||
- run: npm install --ignore-scripts
|
- run: npm ci --ignore-scripts
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
# `npm rebuild` will run all those post-install scripts for us.
|
# `npm rebuild` will run all those post-install scripts for us.
|
||||||
|
|||||||
13459
package-lock.json
generated
13459
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-node",
|
"name": "setup-node",
|
||||||
"version": "2.0.0",
|
"version": "3.1.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup node action",
|
"description": "setup node action",
|
||||||
"main": "lib/setup-node.js",
|
"main": "lib/setup-node.js",
|
||||||
@@ -23,25 +23,25 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.7",
|
"@actions/cache": "^2.0.2",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^1.1.0",
|
"@actions/github": "^1.1.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/http-client": "^1.0.6",
|
"@actions/http-client": "^1.0.11",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^1.5.4",
|
"@actions/tool-cache": "^1.5.4",
|
||||||
"semver": "^6.1.1"
|
"semver": "^6.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@vercel/ncc": "^0.33.4",
|
||||||
"jest": "^24.9.0",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^27.2.5",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^24.3.0",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {
|
|||||||
PackageManagerInfo
|
PackageManagerInfo
|
||||||
} from './cache-utils';
|
} from './cache-utils';
|
||||||
|
|
||||||
export const restoreCache = async (packageManager: string) => {
|
export const restoreCache = async (
|
||||||
|
packageManager: string,
|
||||||
|
cacheDependencyPath?: string
|
||||||
|
) => {
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||||
@@ -22,15 +25,24 @@ export const restoreCache = async (packageManager: string) => {
|
|||||||
packageManagerInfo,
|
packageManagerInfo,
|
||||||
packageManager
|
packageManager
|
||||||
);
|
);
|
||||||
const lockFilePath = findLockFile(packageManagerInfo);
|
const lockFilePath = cacheDependencyPath
|
||||||
|
? cacheDependencyPath
|
||||||
|
: findLockFile(packageManagerInfo);
|
||||||
const fileHash = await glob.hashFiles(lockFilePath);
|
const fileHash = await glob.hashFiles(lockFilePath);
|
||||||
|
|
||||||
|
if (!fileHash) {
|
||||||
|
throw new Error(
|
||||||
|
'Some specified paths were not resolved, unable to cache dependencies.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
|
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
|
||||||
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
|
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
|
||||||
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`${packageManager} cache is not found`);
|
core.info(`${packageManager} cache is not found`);
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
|
import fs from 'fs';
|
||||||
import {State} from './constants';
|
import {State} from './constants';
|
||||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||||
|
|
||||||
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
|
process.on('uncaughtException', e => {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${e.message}`);
|
||||||
|
});
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const cacheLock = core.getInput('cache');
|
const cacheLock = core.getInput('cache');
|
||||||
@@ -26,6 +35,13 @@ const cachePackages = async (packageManager: string) => {
|
|||||||
packageManagerInfo,
|
packageManagerInfo,
|
||||||
packageManager
|
packageManager
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!fs.existsSync(cachePath)) {
|
||||||
|
throw new Error(
|
||||||
|
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (primaryKey === state) {
|
if (primaryKey === state) {
|
||||||
core.info(
|
core.info(
|
||||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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 cache from '@actions/cache';
|
||||||
|
|
||||||
type SupportedPackageManagers = {
|
type SupportedPackageManagers = {
|
||||||
[prop: string]: PackageManagerInfo;
|
[prop: string]: PackageManagerInfo;
|
||||||
@@ -15,6 +16,10 @@ export const supportedPackageManagers: SupportedPackageManagers = {
|
|||||||
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
|
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
|
||||||
getCacheFolderCommand: 'npm config get cache'
|
getCacheFolderCommand: 'npm config get cache'
|
||||||
},
|
},
|
||||||
|
pnpm: {
|
||||||
|
lockFilePatterns: ['pnpm-lock.yaml'],
|
||||||
|
getCacheFolderCommand: 'pnpm store path'
|
||||||
|
},
|
||||||
yarn1: {
|
yarn1: {
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['yarn.lock'],
|
||||||
getCacheFolderCommand: 'yarn cache dir'
|
getCacheFolderCommand: 'yarn cache dir'
|
||||||
@@ -26,13 +31,20 @@ export const supportedPackageManagers: SupportedPackageManagers = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getCommandOutput = async (toolCommand: string) => {
|
export const getCommandOutput = async (toolCommand: string) => {
|
||||||
const {stdout, stderr, exitCode} = await exec.getExecOutput(toolCommand);
|
let {stdout, stderr, exitCode} = await exec.getExecOutput(
|
||||||
|
toolCommand,
|
||||||
|
undefined,
|
||||||
|
{ignoreReturnCode: true}
|
||||||
|
);
|
||||||
|
|
||||||
if (stderr) {
|
if (exitCode) {
|
||||||
|
stderr = !stderr.trim()
|
||||||
|
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
||||||
|
: stderr;
|
||||||
throw new Error(stderr);
|
throw new Error(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdout;
|
return stdout.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPackageManagerVersion = async (
|
const getPackageManagerVersion = async (
|
||||||
@@ -51,6 +63,8 @@ const getPackageManagerVersion = async (
|
|||||||
export const getPackageManagerInfo = async (packageManager: string) => {
|
export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
if (packageManager === 'npm') {
|
if (packageManager === 'npm') {
|
||||||
return supportedPackageManagers.npm;
|
return supportedPackageManagers.npm;
|
||||||
|
} else if (packageManager === 'pnpm') {
|
||||||
|
return supportedPackageManagers.pnpm;
|
||||||
} else if (packageManager === 'yarn') {
|
} else if (packageManager === 'yarn') {
|
||||||
const yarnVersion = await getPackageManagerVersion('yarn', '--version');
|
const yarnVersion = await getPackageManagerVersion('yarn', '--version');
|
||||||
|
|
||||||
@@ -82,3 +96,28 @@ export const getCacheDirectoryPath = async (
|
|||||||
|
|
||||||
return stdOut;
|
return stdOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function isGhes(): boolean {
|
||||||
|
const ghUrl = new URL(
|
||||||
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
|
);
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
|
if (!cache.isFeatureAvailable()) {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error(
|
||||||
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.warning(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export enum LockType {
|
export enum LockType {
|
||||||
Npm = 'npm',
|
Npm = 'npm',
|
||||||
|
Pnpm = 'pnpm',
|
||||||
Yarn = 'yarn'
|
Yarn = 'yarn'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export async function getNode(
|
|||||||
) {
|
) {
|
||||||
// Store manifest data to avoid multiple calls
|
// Store manifest data to avoid multiple calls
|
||||||
let manifest: INodeRelease[] | undefined;
|
let manifest: INodeRelease[] | undefined;
|
||||||
|
let nodeVersions: INodeVersion[] | undefined;
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = translateArchToDistUrl(arch);
|
let osArch: string = translateArchToDistUrl(arch);
|
||||||
|
|
||||||
@@ -49,6 +50,12 @@ export async function getNode(
|
|||||||
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLatestSyntax(versionSpec)) {
|
||||||
|
nodeVersions = await getVersionsFromDist();
|
||||||
|
versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions);
|
||||||
|
core.info(`getting latest node version...`);
|
||||||
|
}
|
||||||
|
|
||||||
if (checkLatest) {
|
if (checkLatest) {
|
||||||
core.info('Attempt to resolve the latest version from manifest...');
|
core.info('Attempt to resolve the latest version from manifest...');
|
||||||
const resolvedVersion = await resolveVersionFromManifest(
|
const resolvedVersion = await resolveVersionFromManifest(
|
||||||
@@ -119,7 +126,7 @@ export async function getNode(
|
|||||||
// Download from nodejs.org
|
// Download from nodejs.org
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = await getInfoFromDist(versionSpec, arch);
|
info = await getInfoFromDist(versionSpec, arch, nodeVersions);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
||||||
@@ -216,13 +223,21 @@ function resolveLtsAliasFromManifest(
|
|||||||
|
|
||||||
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
|
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
|
||||||
|
|
||||||
// Supported formats are `lts/<alias>` and `lts/*`. Where asterisk means highest possible LTS.
|
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
|
||||||
|
const n = Number(alias);
|
||||||
|
const aliases = Object.fromEntries(
|
||||||
|
manifest
|
||||||
|
.filter(x => x.lts && x.stable === stable)
|
||||||
|
.map(x => [x.lts!.toLowerCase(), x])
|
||||||
|
.reverse()
|
||||||
|
);
|
||||||
|
const numbered = Object.values(aliases);
|
||||||
const release =
|
const release =
|
||||||
alias === '*'
|
alias === '*'
|
||||||
? manifest.find(x => !!x.lts && x.stable === stable)
|
? numbered[numbered.length - 1]
|
||||||
: manifest.find(
|
: n < 0
|
||||||
x => x.lts?.toLowerCase() === alias && x.stable === stable
|
? numbered[numbered.length - 1 + n]
|
||||||
);
|
: aliases[alias];
|
||||||
|
|
||||||
if (!release) {
|
if (!release) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -265,14 +280,18 @@ async function getInfoFromManifest(
|
|||||||
|
|
||||||
async function getInfoFromDist(
|
async function getInfoFromDist(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
arch: string = os.arch()
|
arch: string = os.arch(),
|
||||||
|
nodeVersions?: INodeVersion[]
|
||||||
): Promise<INodeVersionInfo | null> {
|
): Promise<INodeVersionInfo | null> {
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = translateArchToDistUrl(arch);
|
let osArch: string = translateArchToDistUrl(arch);
|
||||||
|
|
||||||
let version: string;
|
let version: string = await queryDistForMatch(
|
||||||
|
versionSpec,
|
||||||
|
arch,
|
||||||
|
nodeVersions
|
||||||
|
);
|
||||||
|
|
||||||
version = await queryDistForMatch(versionSpec, arch);
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -349,7 +368,8 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
|
|||||||
|
|
||||||
async function queryDistForMatch(
|
async function queryDistForMatch(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
arch: string = os.arch()
|
arch: string = os.arch(),
|
||||||
|
nodeVersions?: INodeVersion[]
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = translateArchToDistUrl(arch);
|
let osArch: string = translateArchToDistUrl(arch);
|
||||||
@@ -370,8 +390,17 @@ async function queryDistForMatch(
|
|||||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nodeVersions) {
|
||||||
|
core.debug('No dist manifest cached');
|
||||||
|
nodeVersions = await getVersionsFromDist();
|
||||||
|
}
|
||||||
|
|
||||||
let versions: string[] = [];
|
let versions: string[] = [];
|
||||||
let nodeVersions = await module.exports.getVersionsFromDist();
|
|
||||||
|
if (isLatestSyntax(versionSpec)) {
|
||||||
|
core.info(`getting latest node version...`);
|
||||||
|
return nodeVersions[0].version;
|
||||||
|
}
|
||||||
|
|
||||||
nodeVersions.forEach((nodeVersion: INodeVersion) => {
|
nodeVersions.forEach((nodeVersion: INodeVersion) => {
|
||||||
// ensure this version supports your os and platform
|
// ensure this version supports your os and platform
|
||||||
@@ -464,3 +493,16 @@ function translateArchToDistUrl(arch: string): string {
|
|||||||
return arch;
|
return arch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseNodeVersionFile(contents: string): string {
|
||||||
|
let nodeVersion = contents.trim();
|
||||||
|
|
||||||
|
if (/^v\d/.test(nodeVersion)) {
|
||||||
|
nodeVersion = nodeVersion.substring(1);
|
||||||
|
}
|
||||||
|
return nodeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLatestSyntax(versionSpec): boolean {
|
||||||
|
return ['current', 'latest', 'node'].includes(versionSpec);
|
||||||
|
}
|
||||||
|
|||||||
56
src/main.ts
56
src/main.ts
@@ -1,9 +1,10 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
|
import fs from 'fs';
|
||||||
import * as auth from './authutil';
|
import * as auth from './authutil';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache} from './cache-restore';
|
||||||
import {URL} from 'url';
|
import {isGhes, isCacheFeatureAvailable} from './cache-utils';
|
||||||
import os = require('os');
|
import os = require('os');
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
@@ -12,10 +13,7 @@ export async function run() {
|
|||||||
// Version is optional. If supplied, install / use from the tool cache
|
// Version is optional. If supplied, install / use from the tool cache
|
||||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||||
//
|
//
|
||||||
let version = core.getInput('node-version');
|
let version = resolveVersionInput();
|
||||||
if (!version) {
|
|
||||||
version = core.getInput('version');
|
|
||||||
}
|
|
||||||
|
|
||||||
let arch = core.getInput('architecture');
|
let arch = core.getInput('architecture');
|
||||||
const cache = core.getInput('cache');
|
const cache = core.getInput('cache');
|
||||||
@@ -47,11 +45,9 @@ export async function run() {
|
|||||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache) {
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
if (isGhes()) {
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
throw new Error('Caching is not supported on GHES');
|
await restoreCache(cache, cacheDependencyPath);
|
||||||
}
|
|
||||||
await restoreCache(cache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
@@ -62,14 +58,40 @@ export async function run() {
|
|||||||
core.info(
|
core.info(
|
||||||
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isGhes(): boolean {
|
function resolveVersionInput(): string {
|
||||||
const ghUrl = new URL(
|
let version = core.getInput('node-version');
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
const versionFileInput = core.getInput('node-version-file');
|
||||||
);
|
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
if (version && versionFileInput) {
|
||||||
|
core.warning(
|
||||||
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (versionFileInput) {
|
||||||
|
const versionFilePath = path.join(
|
||||||
|
process.env.GITHUB_WORKSPACE!,
|
||||||
|
versionFileInput
|
||||||
|
);
|
||||||
|
if (!fs.existsSync(versionFilePath)) {
|
||||||
|
throw new Error(
|
||||||
|
`The specified node version file at: ${versionFilePath} does not exist`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
version = installer.parseNodeVersionFile(
|
||||||
|
fs.readFileSync(versionFilePath, 'utf8')
|
||||||
|
);
|
||||||
|
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"lib": [
|
|
||||||
"es6"
|
|
||||||
],
|
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user