Compare commits

..

10 Commits

Author SHA1 Message Date
56337c4255 Updated @actions/cache (#460)
* Updated @actions/cache

* Licensed cache

* new build

* Updated version
2022-04-11 19:06:18 +05:30
76d3665dc0 Convert CONDUCT to CODE_OF_CONDUCT.md (#391)
* Rename CONDUCT to CODE_OF_CONDUCT.md

* Update CODE_OF_CONDUCT link
2022-04-05 11:16:57 -04:00
5b52f097d3 Bump actions/checkout@v3 within advanced usage examples documentation (#456) 2022-04-01 10:41:49 +02:00
75716637dc Bump to actions/checkout@v3 (#437) 2022-04-01 10:13:52 +02:00
546fd45825 Updated documentation/workflows to use actions/setup-node@v3 (#433)
* Update documentation `actions/setup-node@v2` -> `actions/setup-node@v3`

* Bump workflows to `actions/setup-node@v3`

* Update `README.md` workflow status badges to new format
2022-03-31 15:14:07 -04:00
bacd6b4b3a Caching on GHES (#452)
* add support for ghes caching

* fix licesnses

* work on resolving comments

* change internal error to warning

* fix warning for internal errors

* update version
2022-03-31 15:10:37 -04:00
bed538bd04 Merge pull request #448 from actions/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-03-24 09:33:20 -04:00
f3e93d1b9d Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 11:54:46 +00:00
ed960c9656 Merge pull request #440 from actions/joshmgross/service-codeowners
Update CODEOWNERS to actions-service
2022-03-10 13:32:59 -05:00
77f43a4400 Update CODEOWNERS to actions-service 2022-03-10 13:27:02 -05:00
27 changed files with 8885 additions and 5927 deletions

View File

@ -18,9 +18,9 @@ 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 16 - name: Setup Node 16.x
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 16.x node-version: 16.x
cache: npm cache: npm

View File

@ -21,10 +21,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set Node.js 16.x - name: Setup Node 16.x
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 16.x node-version: 16.x
cache: npm cache: npm
@ -45,7 +45,7 @@ jobs:
id: diff id: diff
# If index.js was different than expected, upload the expected version as an artifact # If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }} if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with: with:
name: dist name: dist

View File

@ -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
@ -44,7 +44,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [12, 14, 16] node-version: [12, 14, 16]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v2 uses: pnpm/action-setup@v2
with: with:
@ -77,7 +77,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [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
@ -109,7 +109,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: Update yarn - name: Update yarn
run: yarn set version berry run: yarn set version berry
- name: Yarn version - name: Yarn version

View File

@ -13,7 +13,7 @@ jobs:
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: |

View File

@ -25,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
@ -41,7 +41,7 @@ jobs:
https_proxy: http://no-such-proxy:3128 https_proxy: http://no-such-proxy:3128
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
steps: steps:
- uses: actions/checkout@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

View File

@ -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:
@ -37,7 +37,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*] node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -51,7 +51,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 +68,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:
@ -85,7 +85,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
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -101,7 +101,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:
@ -117,7 +117,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: ./
@ -130,7 +130,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:

View File

@ -1,6 +1,6 @@
--- ---
name: "@actions/cache" name: "@actions/cache"
version: 1.0.8 version: 2.0.2
type: npm type: npm
summary: Actions cache lib summary: Actions cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/cache homepage: https://github.com/actions/toolkit/tree/main/packages/cache

View File

@ -1,32 +1,32 @@
--- ---
name: "@azure/core-asynciterator-polyfill" name: "@azure/core-asynciterator-polyfill"
version: 1.0.0 version: 1.0.2
type: npm type: npm
summary: Polyfill for IE/Node 8 for Symbol.asyncIterator summary: Polyfill for IE/Node 8 for Symbol.asyncIterator
homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-asynciterator-polyfill homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-asynciterator-polyfill/README.md
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
text: |2 text: |
MIT License The MIT License (MIT)
Copyright (c) Microsoft Corporation. All rights reserved. Copyright (c) 2020 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE SOFTWARE.
notices: [] notices: []

View File

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-http" name: "@azure/core-http"
version: 2.2.2 version: 2.2.4
type: npm type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest libraries generated using AutoRest

View File

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-lro" name: "@azure/core-lro"
version: 2.2.1 version: 2.2.4
type: npm type: npm
summary: Isomorphic client library for supporting long-running operations in node.js summary: Isomorphic client library for supporting long-running operations in node.js
and browser. and browser.

View File

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-paging" name: "@azure/core-paging"
version: 1.2.0 version: 1.2.1
type: npm type: npm
summary: Core types for paging async iterable iterators summary: Core types for paging async iterable iterators
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md

View File

@ -1,6 +1,6 @@
--- ---
name: "@azure/ms-rest-js" name: "@azure/ms-rest-js"
version: 2.6.0 version: 2.6.1
type: npm type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest libraries generated using AutoRest

View File

@ -1,6 +1,6 @@
--- ---
name: "@azure/storage-blob" name: "@azure/storage-blob"
version: 12.8.0 version: 12.9.0
type: npm type: npm
summary: Microsoft Azure Storage SDK for JavaScript - Blob summary: Microsoft Azure Storage SDK for JavaScript - Blob
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/ homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/

View File

@ -1,6 +1,6 @@
--- ---
name: "@opentelemetry/api" name: "@opentelemetry/api"
version: 1.0.3 version: 1.0.4
type: npm type: npm
summary: Public API for OpenTelemetry summary: Public API for OpenTelemetry
homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme
@ -218,10 +218,6 @@ licenses:
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE [license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg?type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api?type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/api [npm-url]: https://www.npmjs.com/package/@opentelemetry/api
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md [docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md

View File

@ -1,6 +1,6 @@
--- ---
name: "@types/node-fetch" name: "@types/node-fetch"
version: 2.5.12 version: 2.6.1
type: npm type: npm
summary: TypeScript definitions for node-fetch summary: TypeScript definitions for node-fetch
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch

View File

@ -1 +1 @@
* @actions/spark * @actions/actions-service

View File

@ -1,8 +1,8 @@
# setup-node # setup-node
<p align="left"> [![build-test](https://github.com/actions/setup-node/actions/workflows/build-test.yml/badge.svg)](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> [![versions](https://github.com/actions/setup-node/actions/workflows/versions.yml/badge.svg)](https://github.com/actions/setup-node/actions/workflows/versions.yml)
</p> [![proxy](https://github.com/actions/setup-node/actions/workflows/proxy.yml/badge.svg)](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:
@ -16,10 +16,11 @@ This action provides the following functionality for GitHub Actions users:
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 install
@ -33,6 +34,7 @@ The action will first check the local cache for a semver match. If unable to fin
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: The `node-version` input supports the following syntax:
major versions: `12`, `14`, `16` major versions: `12`, `14`, `16`
@ -48,10 +50,11 @@ The action defaults to search for the dependency file (`package-lock.json` or `y
See the examples of using cache for `yarn` / `pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-dependencies) guide. See the examples of using cache for `yarn` / `pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-dependencies) 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'
@ -60,10 +63,11 @@ steps:
``` ```
**Caching npm dependencies in monorepos:** **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: 'npm' cache: 'npm'
@ -73,6 +77,7 @@ steps:
``` ```
## Matrix Testing: ## Matrix Testing:
```yaml ```yaml
jobs: jobs:
build: build:
@ -82,14 +87,15 @@ jobs:
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 install
- 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)
@ -111,4 +117,4 @@ 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)

View File

@ -1,37 +1,28 @@
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.pnpm.getCacheFolderCommand
) {
return `${commonPath}/pnpm`;
} 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');
}); });
@ -51,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();
}); });

View File

@ -2,6 +2,7 @@ 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 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');
@ -36,6 +37,7 @@ describe('setup-node', () => {
let execSpy: jest.SpyInstance; let execSpy: jest.SpyInstance;
let authSpy: jest.SpyInstance; let authSpy: jest.SpyInstance;
let parseNodeVersionSpy: jest.SpyInstance; let parseNodeVersionSpy: jest.SpyInstance;
let isCacheActionAvailable: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
// @actions/core // @actions/core
@ -67,6 +69,9 @@ describe('setup-node', () => {
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(() => {});
@ -644,6 +649,49 @@ describe('setup-node', () => {
); );
}); });
}); });
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';

9058
dist/cache-save/index.js vendored

File diff suppressed because it is too large Load Diff

5253
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,8 @@ 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
@ -27,8 +27,8 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
```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-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm install - run: npm install
@ -46,8 +46,8 @@ 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
@ -62,8 +62,8 @@ The action follows [actions/cache](https://github.com/actions/cache/blob/main/ex
Yarn caching handles both yarn versions: 1 or 2. Yarn caching handles both yarn versions: 1 or 2.
```yaml ```yaml
steps: steps:
- uses: actions/checkout@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: 'yarn'
@ -81,11 +81,11 @@ steps:
# NOTE: pnpm caching support requires pnpm version >= 6.10.0 # NOTE: pnpm caching support requires pnpm version >= 6.10.0
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2 - uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with: with:
version: 6.10.0 version: 6.10.0
- uses: actions/setup-node@v2 - uses: actions/setup-node@v3
with: with:
node-version: '14' node-version: '14'
cache: 'pnpm' cache: 'pnpm'
@ -96,8 +96,8 @@ steps:
**Using wildcard patterns to cache dependencies** **Using wildcard patterns to cache 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'
@ -109,8 +109,8 @@ steps:
**Using a list of file paths to cache dependencies** **Using a list of file paths to cache dependencies**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@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'
@ -146,9 +146,9 @@ jobs:
architecture: x86 architecture: x86
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }} name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@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 }}
@ -159,8 +159,8 @@ jobs:
## 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'
@ -168,7 +168,7 @@ steps:
- run: npm publish - run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@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
@ -179,8 +179,8 @@ steps:
## 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>
@ -188,7 +188,7 @@ steps:
- run: yarn publish - run: yarn publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
- uses: actions/setup-node@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
@ -199,8 +199,8 @@ steps:
## 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'

145
package-lock.json generated
View File

@ -1,15 +1,15 @@
{ {
"name": "setup-node", "name": "setup-node",
"version": "2.0.0", "version": "3.1.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "setup-node", "name": "setup-node",
"version": "2.0.0", "version": "3.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.8", "@actions/cache": "^2.0.2",
"@actions/core": "^1.6.0", "@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",
@ -32,17 +32,17 @@
} }
}, },
"node_modules/@actions/cache": { "node_modules/@actions/cache": {
"version": "1.0.8", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
"integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.9", "@actions/http-client": "^1.0.9",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/ms-rest-js": "^2.0.7", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.1.2", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
"uuid": "^3.3.3" "uuid": "^3.3.3"
} }
@ -142,9 +142,12 @@
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}, },
"node_modules/@azure/core-asynciterator-polyfill": { "node_modules/@azure/core-asynciterator-polyfill": {
"version": "1.0.0", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.2.tgz",
"integrity": "sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg==" "integrity": "sha512-3rkP4LnnlWawl0LZptJOdXNrT/fHp2eQMadoasa6afspXdpGrtPZuAQc2PD0cpgyuoXtUWyC3tv7xfntjGS5Dw==",
"engines": {
"node": ">=12.0.0"
}
}, },
"node_modules/@azure/core-auth": { "node_modules/@azure/core-auth": {
"version": "1.3.2", "version": "1.3.2",
@ -164,9 +167,9 @@
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}, },
"node_modules/@azure/core-http": { "node_modules/@azure/core-http": {
"version": "2.2.2", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.2.tgz", "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz",
"integrity": "sha512-V1DdoO9V/sFimKpdWoNBgsE+QUjQgpXYnxrTdUp5RyhsTJjvEVn/HKmTQXIHuLUUo6IyIWj+B+Dg4VaXse9dIA==", "integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==",
"dependencies": { "dependencies": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0",
@ -176,7 +179,7 @@
"@types/node-fetch": "^2.5.0", "@types/node-fetch": "^2.5.0",
"@types/tunnel": "^0.0.3", "@types/tunnel": "^0.0.3",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.7",
"process": "^0.11.10", "process": "^0.11.10",
"tough-cookie": "^4.0.0", "tough-cookie": "^4.0.0",
"tslib": "^2.2.0", "tslib": "^2.2.0",
@ -215,9 +218,9 @@
} }
}, },
"node_modules/@azure/core-lro": { "node_modules/@azure/core-lro": {
"version": "2.2.1", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.1.tgz", "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.4.tgz",
"integrity": "sha512-HE6PBl+mlKa0eBsLwusHqAqjLc5n9ByxeDo3Hz4kF3B1hqHvRkBr4oMgoT6tX7Hc3q97KfDctDUon7EhvoeHPA==", "integrity": "sha512-e1I2v2CZM0mQo8+RSix0x091Av493e4bnT22ds2fcQGslTHzM2oTbswkB65nP4iEpCxBrFxOSDPKExmTmjCVtQ==",
"dependencies": { "dependencies": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.13", "@azure/core-tracing": "1.0.0-preview.13",
@ -234,9 +237,9 @@
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}, },
"node_modules/@azure/core-paging": { "node_modules/@azure/core-paging": {
"version": "1.2.0", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.1.tgz",
"integrity": "sha512-ZX1bCjm/MjKPCN6kQD/9GJErYSoKA8YWp6YWoo5EIzcTWlSBLXu3gNaBTUl8usGl+UShiKo7b4Gdy1NSTIlpZg==", "integrity": "sha512-UtH5iMlYsvg+nQYIl4UHlvvSrsBjOlRF4fs0j7mxd3rWdAStrKYrh2durOpHs5C9yZbVhsVDaisoyaf/lL1EVA==",
"dependencies": { "dependencies": {
"@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0",
"tslib": "^2.2.0" "tslib": "^2.2.0"
@ -284,14 +287,14 @@
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}, },
"node_modules/@azure/ms-rest-js": { "node_modules/@azure/ms-rest-js": {
"version": "2.6.0", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.0.tgz", "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.1.tgz",
"integrity": "sha512-4C5FCtvEzWudblB+h92/TYYPiq7tuElX8icVYToxOdggnYqeec4Se14mjse5miInKtZahiFHdl8lZA/jziEc5g==", "integrity": "sha512-LLi4jRe/qy5IM8U2CkoDgSZp2OH+MgDe2wePmhz8uY84Svc53EhHaamVyoU6BjjHBxvCRh1vcD1urJDccrxqIw==",
"dependencies": { "dependencies": {
"@azure/core-auth": "^1.1.4", "@azure/core-auth": "^1.1.4",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"form-data": "^2.5.0", "form-data": "^2.5.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.7",
"tough-cookie": "^3.0.1", "tough-cookie": "^3.0.1",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"tunnel": "0.0.6", "tunnel": "0.0.6",
@ -334,9 +337,9 @@
} }
}, },
"node_modules/@azure/storage-blob": { "node_modules/@azure/storage-blob": {
"version": "12.8.0", "version": "12.9.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.8.0.tgz", "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.9.0.tgz",
"integrity": "sha512-c8+Wz19xauW0bGkTCoqZH4dYfbtBniPiGiRQOn1ca6G5jsjr4azwaTk9gwjVY8r3vY2Taf95eivLzipfIfiS4A==", "integrity": "sha512-ank38FdCLfJ+EoeMzCz3hkYJuZAd63ARvDKkxZYRDb+beBYf+/+gx8jNTqkq/hfyUl4dJQ/a7tECU0Y0F98CHg==",
"dependencies": { "dependencies": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-http": "^2.0.0", "@azure/core-http": "^2.0.0",
@ -1359,9 +1362,9 @@
} }
}, },
"node_modules/@opentelemetry/api": { "node_modules/@opentelemetry/api": {
"version": "1.0.3", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz",
"integrity": "sha512-puWxACExDe9nxbBB3lOymQFrLYml2dVOrd7USiVRnSbgXE+KwBu+HxFvxrzfqsiSda9IWsXJG1ef7C1O2/GmKQ==", "integrity": "sha512-BuJuXRSJNQ3QoKA6GWWDyuLpOUck+9hAXNMCnrloc1aWVoy6Xq6t9PUV08aBZ4Lutqq2LEHM486bpZqoViScog==",
"engines": { "engines": {
"node": ">=8.0.0" "node": ">=8.0.0"
} }
@ -1483,9 +1486,9 @@
"integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ==" "integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ=="
}, },
"node_modules/@types/node-fetch": { "node_modules/@types/node-fetch": {
"version": "2.5.12", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz", "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==", "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
"dependencies": { "dependencies": {
"@types/node": "*", "@types/node": "*",
"form-data": "^3.0.0" "form-data": "^3.0.0"
@ -3939,9 +3942,9 @@
} }
}, },
"node_modules/minimist": { "node_modules/minimist": {
"version": "1.2.5", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true "dev": true
}, },
"node_modules/ms": { "node_modules/ms": {
@ -5077,17 +5080,17 @@
}, },
"dependencies": { "dependencies": {
"@actions/cache": { "@actions/cache": {
"version": "1.0.8", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
"integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
"requires": { "requires": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.9", "@actions/http-client": "^1.0.9",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/ms-rest-js": "^2.0.7", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.1.2", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
"uuid": "^3.3.3" "uuid": "^3.3.3"
}, },
@ -5184,9 +5187,9 @@
} }
}, },
"@azure/core-asynciterator-polyfill": { "@azure/core-asynciterator-polyfill": {
"version": "1.0.0", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.2.tgz",
"integrity": "sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg==" "integrity": "sha512-3rkP4LnnlWawl0LZptJOdXNrT/fHp2eQMadoasa6afspXdpGrtPZuAQc2PD0cpgyuoXtUWyC3tv7xfntjGS5Dw=="
}, },
"@azure/core-auth": { "@azure/core-auth": {
"version": "1.3.2", "version": "1.3.2",
@ -5205,9 +5208,9 @@
} }
}, },
"@azure/core-http": { "@azure/core-http": {
"version": "2.2.2", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.2.tgz", "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz",
"integrity": "sha512-V1DdoO9V/sFimKpdWoNBgsE+QUjQgpXYnxrTdUp5RyhsTJjvEVn/HKmTQXIHuLUUo6IyIWj+B+Dg4VaXse9dIA==", "integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==",
"requires": { "requires": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0",
@ -5217,7 +5220,7 @@
"@types/node-fetch": "^2.5.0", "@types/node-fetch": "^2.5.0",
"@types/tunnel": "^0.0.3", "@types/tunnel": "^0.0.3",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.7",
"process": "^0.11.10", "process": "^0.11.10",
"tough-cookie": "^4.0.0", "tough-cookie": "^4.0.0",
"tslib": "^2.2.0", "tslib": "^2.2.0",
@ -5249,9 +5252,9 @@
} }
}, },
"@azure/core-lro": { "@azure/core-lro": {
"version": "2.2.1", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.1.tgz", "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.4.tgz",
"integrity": "sha512-HE6PBl+mlKa0eBsLwusHqAqjLc5n9ByxeDo3Hz4kF3B1hqHvRkBr4oMgoT6tX7Hc3q97KfDctDUon7EhvoeHPA==", "integrity": "sha512-e1I2v2CZM0mQo8+RSix0x091Av493e4bnT22ds2fcQGslTHzM2oTbswkB65nP4iEpCxBrFxOSDPKExmTmjCVtQ==",
"requires": { "requires": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.13", "@azure/core-tracing": "1.0.0-preview.13",
@ -5267,9 +5270,9 @@
} }
}, },
"@azure/core-paging": { "@azure/core-paging": {
"version": "1.2.0", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.1.tgz",
"integrity": "sha512-ZX1bCjm/MjKPCN6kQD/9GJErYSoKA8YWp6YWoo5EIzcTWlSBLXu3gNaBTUl8usGl+UShiKo7b4Gdy1NSTIlpZg==", "integrity": "sha512-UtH5iMlYsvg+nQYIl4UHlvvSrsBjOlRF4fs0j7mxd3rWdAStrKYrh2durOpHs5C9yZbVhsVDaisoyaf/lL1EVA==",
"requires": { "requires": {
"@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0",
"tslib": "^2.2.0" "tslib": "^2.2.0"
@ -5314,14 +5317,14 @@
} }
}, },
"@azure/ms-rest-js": { "@azure/ms-rest-js": {
"version": "2.6.0", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.0.tgz", "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.1.tgz",
"integrity": "sha512-4C5FCtvEzWudblB+h92/TYYPiq7tuElX8icVYToxOdggnYqeec4Se14mjse5miInKtZahiFHdl8lZA/jziEc5g==", "integrity": "sha512-LLi4jRe/qy5IM8U2CkoDgSZp2OH+MgDe2wePmhz8uY84Svc53EhHaamVyoU6BjjHBxvCRh1vcD1urJDccrxqIw==",
"requires": { "requires": {
"@azure/core-auth": "^1.1.4", "@azure/core-auth": "^1.1.4",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"form-data": "^2.5.0", "form-data": "^2.5.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.7",
"tough-cookie": "^3.0.1", "tough-cookie": "^3.0.1",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"tunnel": "0.0.6", "tunnel": "0.0.6",
@ -5357,9 +5360,9 @@
} }
}, },
"@azure/storage-blob": { "@azure/storage-blob": {
"version": "12.8.0", "version": "12.9.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.8.0.tgz", "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.9.0.tgz",
"integrity": "sha512-c8+Wz19xauW0bGkTCoqZH4dYfbtBniPiGiRQOn1ca6G5jsjr4azwaTk9gwjVY8r3vY2Taf95eivLzipfIfiS4A==", "integrity": "sha512-ank38FdCLfJ+EoeMzCz3hkYJuZAd63ARvDKkxZYRDb+beBYf+/+gx8jNTqkq/hfyUl4dJQ/a7tECU0Y0F98CHg==",
"requires": { "requires": {
"@azure/abort-controller": "^1.0.0", "@azure/abort-controller": "^1.0.0",
"@azure/core-http": "^2.0.0", "@azure/core-http": "^2.0.0",
@ -6177,9 +6180,9 @@
} }
}, },
"@opentelemetry/api": { "@opentelemetry/api": {
"version": "1.0.3", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz",
"integrity": "sha512-puWxACExDe9nxbBB3lOymQFrLYml2dVOrd7USiVRnSbgXE+KwBu+HxFvxrzfqsiSda9IWsXJG1ef7C1O2/GmKQ==" "integrity": "sha512-BuJuXRSJNQ3QoKA6GWWDyuLpOUck+9hAXNMCnrloc1aWVoy6Xq6t9PUV08aBZ4Lutqq2LEHM486bpZqoViScog=="
}, },
"@sinonjs/commons": { "@sinonjs/commons": {
"version": "1.8.3", "version": "1.8.3",
@ -6295,9 +6298,9 @@
"integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ==" "integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ=="
}, },
"@types/node-fetch": { "@types/node-fetch": {
"version": "2.5.12", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz", "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==", "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
"requires": { "requires": {
"@types/node": "*", "@types/node": "*",
"form-data": "^3.0.0" "form-data": "^3.0.0"
@ -8179,9 +8182,9 @@
} }
}, },
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true "dev": true
}, },
"ms": { "ms": {

View File

@ -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,7 +23,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.8", "@actions/cache": "^2.0.2",
"@actions/core": "^1.6.0", "@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",

View File

@ -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;
@ -95,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;
}

View File

@ -4,7 +4,7 @@ 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() {
@ -45,10 +45,7 @@ export async function run() {
auth.configAuthentication(registryUrl, alwaysAuth); auth.configAuthentication(registryUrl, alwaysAuth);
} }
if (cache) { if (cache && isCacheFeatureAvailable()) {
if (isGhes()) {
throw new Error('Caching is not supported on GHES');
}
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(cache, cacheDependencyPath); await restoreCache(cache, cacheDependencyPath);
} }
@ -66,13 +63,6 @@ export async function run() {
} }
} }
function isGhes(): boolean {
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
);
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
function resolveVersionInput(): string { function resolveVersionInput(): string {
let version = core.getInput('node-version'); let version = core.getInput('node-version');
const versionFileInput = core.getInput('node-version-file'); const versionFileInput = core.getInput('node-version-file');