mirror of
https://github.com/actions/setup-node.git
synced 2026-02-17 03:44:43 +08:00
Compare commits
4 Commits
v4.3.0
...
b4decb98bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4decb98bb | ||
|
|
d23de777e0 | ||
|
|
82af78e9c4 | ||
|
|
870d3d8e13 |
2
.licenses/npm/@actions/tool-cache.dep.yml
generated
2
.licenses/npm/@actions/tool-cache.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/tool-cache"
|
||||
version: 2.0.2
|
||||
version: 2.0.1
|
||||
type: npm
|
||||
summary: Actions tool-cache lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache
|
||||
|
||||
39
.licenses/npm/uuid-3.4.0.dep.yml
generated
Normal file
39
.licenses/npm/uuid-3.4.0.dep.yml
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
name: uuid
|
||||
version: 3.4.0
|
||||
type: npm
|
||||
summary: RFC4122 (v1, v4, and v5) UUIDs
|
||||
homepage: https://github.com/uuidjs/uuid#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
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
|
||||
SOFTWARE.
|
||||
notices:
|
||||
- sources: AUTHORS
|
||||
text: |-
|
||||
Robert Kieffer <robert@broofa.com>
|
||||
Christoph Tavan <dev@tavan.de>
|
||||
AJ ONeal <coolaj86@gmail.com>
|
||||
Vincent Voyer <vincent@zeroload.net>
|
||||
Roman Shtylman <shtylman@gmail.com>
|
||||
@@ -131,6 +131,7 @@ describe('cache-restore', () => {
|
||||
])(
|
||||
'restored dependencies for %s',
|
||||
async (packageManager, toolVersion, fileHash) => {
|
||||
const expectedCacheKey = `node-cache-${platform}-${arch}-${packageManager}-${fileHash}`;
|
||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||
if (command.includes('version')) {
|
||||
return toolVersion;
|
||||
@@ -142,12 +143,20 @@ describe('cache-restore', () => {
|
||||
await restoreCache(packageManager, '');
|
||||
expect(hashFilesSpy).toHaveBeenCalled();
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: node-cache-${platform}-${arch}-${packageManager}-${fileHash}`
|
||||
`Cache restored from key: ${expectedCacheKey}`
|
||||
);
|
||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||
`${packageManager} cache is not found`
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'cache-key',
|
||||
expectedCacheKey
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'cache-matched-key',
|
||||
expectedCacheKey
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -161,6 +170,7 @@ describe('cache-restore', () => {
|
||||
])(
|
||||
'dependencies are changed %s',
|
||||
async (packageManager, toolVersion, fileHash) => {
|
||||
const expectedCacheKey = `node-cache-${platform}-${arch}-${packageManager}-${fileHash}`;
|
||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||
if (command.includes('version')) {
|
||||
return toolVersion;
|
||||
@@ -176,10 +186,72 @@ describe('cache-restore', () => {
|
||||
`${packageManager} cache is not found`
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'cache-key',
|
||||
expectedCacheKey
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'cache-matched-key',
|
||||
undefined
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('Cache key output', () => {
|
||||
const packageManager = 'npm';
|
||||
const cacheDependencyPath = 'package-lock.json';
|
||||
const primaryKey = `node-cache-${platform}-${arch}-${packageManager}-${npmFileHash}`;
|
||||
const cacheKey = `node-cache-${platform}-${arch}-${packageManager}-abc123`;
|
||||
|
||||
beforeEach(() => {
|
||||
getCommandOutputSpy.mockImplementation(command => {
|
||||
if (command.includes('npm config get cache')) return npmCachePath;
|
||||
});
|
||||
});
|
||||
|
||||
it('sets the cache-key output', async () => {
|
||||
restoreCacheSpy.mockResolvedValue(cacheKey);
|
||||
await restoreCache(packageManager, cacheDependencyPath);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-key', primaryKey);
|
||||
});
|
||||
|
||||
it('sets the cache-hit output to true when cache is found', async () => {
|
||||
restoreCacheSpy.mockResolvedValue(cacheKey);
|
||||
await restoreCache(packageManager, cacheDependencyPath);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||
});
|
||||
|
||||
it('sets the cache-hit output to false when cache is not found', async () => {
|
||||
restoreCacheSpy.mockResolvedValue(undefined);
|
||||
await restoreCache(packageManager, cacheDependencyPath);
|
||||
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
||||
});
|
||||
|
||||
it('sets the cache-matched-key output when cache is found', async () => {
|
||||
(cache.restoreCache as jest.Mock).mockResolvedValue(cacheKey);
|
||||
|
||||
await restoreCache(packageManager, cacheDependencyPath);
|
||||
|
||||
expect(core.setOutput).toHaveBeenCalledWith(
|
||||
'cache-matched-key',
|
||||
cacheKey
|
||||
);
|
||||
});
|
||||
|
||||
it('sets the cache-matched-key output to undefined when cache is not found', async () => {
|
||||
(cache.restoreCache as jest.Mock).mockResolvedValue(undefined);
|
||||
|
||||
await restoreCache(packageManager, cacheDependencyPath);
|
||||
|
||||
expect(core.setOutput).toHaveBeenCalledWith(
|
||||
'cache-matched-key',
|
||||
undefined
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
|
||||
@@ -27,6 +27,7 @@ describe('run', () => {
|
||||
let setFailedSpy: jest.SpyInstance;
|
||||
let getStateSpy: jest.SpyInstance;
|
||||
let saveCacheSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
let getCommandOutputSpy: jest.SpyInstance;
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let existsSpy: jest.SpyInstance;
|
||||
@@ -53,6 +54,8 @@ describe('run', () => {
|
||||
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
||||
saveCacheSpy.mockImplementation(() => undefined);
|
||||
|
||||
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
|
||||
// glob
|
||||
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||
@@ -228,6 +231,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -258,6 +262,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -288,6 +293,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${yarnFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', yarnFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -297,9 +303,9 @@ describe('run', () => {
|
||||
key === State.CachePackageManager
|
||||
? inputs['cache']
|
||||
: key === State.CacheMatchedKey
|
||||
? pnpmFileHash
|
||||
? 'no-match'
|
||||
: key === State.CachePrimaryKey
|
||||
? npmFileHash
|
||||
? pnpmFileHash
|
||||
: key === State.CachePaths
|
||||
? '["/foo/bar"]'
|
||||
: 'not expected'
|
||||
@@ -316,8 +322,9 @@ describe('run', () => {
|
||||
);
|
||||
expect(saveCacheSpy).toHaveBeenCalled();
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
`Cache saved with the key: ${pnpmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', pnpmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ inputs:
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate if a cache was hit.'
|
||||
cache-key:
|
||||
description: 'The key used for the cache.'
|
||||
cache-matched-key:
|
||||
description: 'The key used for the cache that resulted in a cache hit.'
|
||||
node-version:
|
||||
description: 'The installed node version.'
|
||||
runs:
|
||||
|
||||
2837
dist/cache-save/index.js
vendored
2837
dist/cache-save/index.js
vendored
File diff suppressed because one or more lines are too long
3659
dist/setup/index.js
vendored
3659
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
32
package-lock.json
generated
32
package-lock.json
generated
@@ -16,7 +16,7 @@
|
||||
"@actions/glob": "^0.5.0",
|
||||
"@actions/http-client": "^2.2.1",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"semver": "^7.6.3",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
@@ -26,7 +26,7 @@
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"@vercel/ncc": "^0.38.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
@@ -138,16 +138,16 @@
|
||||
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
|
||||
},
|
||||
"node_modules/@actions/tool-cache": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
|
||||
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
|
||||
"license": "MIT",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
|
||||
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/io": "^1.1.1",
|
||||
"semver": "^6.1.0"
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/tool-cache/node_modules/semver": {
|
||||
@@ -158,6 +158,15 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/tool-cache/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
|
||||
@@ -2123,11 +2132,10 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.38.3",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.3.tgz",
|
||||
"integrity": "sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==",
|
||||
"version": "0.38.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz",
|
||||
"integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"@actions/glob": "^0.5.0",
|
||||
"@actions/http-client": "^2.2.1",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"semver": "^7.6.3",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
@@ -42,7 +42,7 @@
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"@vercel/ncc": "^0.38.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
|
||||
@@ -45,6 +45,7 @@ export const restoreCache = async (
|
||||
core.debug(`primary key is ${primaryKey}`);
|
||||
|
||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||
core.setOutput('cache-key', primaryKey);
|
||||
|
||||
const isManagedByYarnBerry = await repoHasYarnBerryManagedDependencies(
|
||||
packageManagerInfo,
|
||||
@@ -61,6 +62,8 @@ export const restoreCache = async (
|
||||
}
|
||||
|
||||
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||
core.setOutput('cache-matched-key', cacheKey);
|
||||
core.debug(`cache-matched-key is ${cacheKey}`);
|
||||
|
||||
if (!cacheKey) {
|
||||
core.info(`${packageManager} cache is not found`);
|
||||
|
||||
@@ -66,6 +66,7 @@ const cachePackages = async (packageManager: string) => {
|
||||
}
|
||||
|
||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||
core.setOutput('cache-key', primaryKey);
|
||||
};
|
||||
|
||||
run(true);
|
||||
|
||||
Reference in New Issue
Block a user