mirror of
https://github.com/actions/setup-node.git
synced 2026-02-22 06:34:44 +08:00
Compare commits
1 Commits
c4d149c413
...
v4.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d0ff469b7 |
4
.licenses/npm/@fastify/busboy.dep.yml
generated
4
.licenses/npm/@fastify/busboy.dep.yml
generated
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: "@fastify/busboy"
|
name: "@fastify/busboy"
|
||||||
version: 2.0.0
|
version: 2.1.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: A streaming parser for HTML form data for node.js
|
summary: A streaming parser for HTML form data for node.js
|
||||||
homepage:
|
homepage:
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
- sources: LICENSE
|
- sources: LICENSE
|
||||||
|
|||||||
2
.licenses/npm/undici.dep.yml
generated
2
.licenses/npm/undici.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: undici
|
name: undici
|
||||||
version: 5.28.4
|
version: 5.28.5
|
||||||
type: npm
|
type: npm
|
||||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ describe('cache-restore', () => {
|
|||||||
])(
|
])(
|
||||||
'restored dependencies for %s',
|
'restored dependencies for %s',
|
||||||
async (packageManager, toolVersion, fileHash) => {
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
const expectedCacheKey = `node-cache-${platform}-${arch}-${packageManager}-${fileHash}`;
|
|
||||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||||
if (command.includes('version')) {
|
if (command.includes('version')) {
|
||||||
return toolVersion;
|
return toolVersion;
|
||||||
@@ -143,20 +142,12 @@ describe('cache-restore', () => {
|
|||||||
await restoreCache(packageManager, '');
|
await restoreCache(packageManager, '');
|
||||||
expect(hashFilesSpy).toHaveBeenCalled();
|
expect(hashFilesSpy).toHaveBeenCalled();
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: ${expectedCacheKey}`
|
`Cache restored from key: node-cache-${platform}-${arch}-${packageManager}-${fileHash}`
|
||||||
);
|
);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
|
||||||
'cache-key',
|
|
||||||
expectedCacheKey
|
|
||||||
);
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
|
||||||
'cache-matched-key',
|
|
||||||
expectedCacheKey
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -170,7 +161,6 @@ describe('cache-restore', () => {
|
|||||||
])(
|
])(
|
||||||
'dependencies are changed %s',
|
'dependencies are changed %s',
|
||||||
async (packageManager, toolVersion, fileHash) => {
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
const expectedCacheKey = `node-cache-${platform}-${arch}-${packageManager}-${fileHash}`;
|
|
||||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||||
if (command.includes('version')) {
|
if (command.includes('version')) {
|
||||||
return toolVersion;
|
return toolVersion;
|
||||||
@@ -186,72 +176,10 @@ describe('cache-restore', () => {
|
|||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
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(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ describe('run', () => {
|
|||||||
let setFailedSpy: jest.SpyInstance;
|
let setFailedSpy: jest.SpyInstance;
|
||||||
let getStateSpy: jest.SpyInstance;
|
let getStateSpy: jest.SpyInstance;
|
||||||
let saveCacheSpy: jest.SpyInstance;
|
let saveCacheSpy: jest.SpyInstance;
|
||||||
let setOutputSpy: jest.SpyInstance;
|
|
||||||
let getCommandOutputSpy: jest.SpyInstance;
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
let hashFilesSpy: jest.SpyInstance;
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
let existsSpy: jest.SpyInstance;
|
let existsSpy: jest.SpyInstance;
|
||||||
@@ -54,8 +53,6 @@ describe('run', () => {
|
|||||||
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
||||||
saveCacheSpy.mockImplementation(() => undefined);
|
saveCacheSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
||||||
|
|
||||||
// glob
|
// glob
|
||||||
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||||
hashFilesSpy.mockImplementation((pattern: string) => {
|
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||||
@@ -231,7 +228,6 @@ describe('run', () => {
|
|||||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
`Cache saved with the key: ${npmFileHash}`
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
);
|
);
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -262,7 +258,6 @@ describe('run', () => {
|
|||||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
`Cache saved with the key: ${npmFileHash}`
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
);
|
);
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -293,7 +288,6 @@ describe('run', () => {
|
|||||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
`Cache saved with the key: ${yarnFileHash}`
|
`Cache saved with the key: ${yarnFileHash}`
|
||||||
);
|
);
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', yarnFileHash);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -303,9 +297,9 @@ describe('run', () => {
|
|||||||
key === State.CachePackageManager
|
key === State.CachePackageManager
|
||||||
? inputs['cache']
|
? inputs['cache']
|
||||||
: key === State.CacheMatchedKey
|
: key === State.CacheMatchedKey
|
||||||
? 'no-match'
|
|
||||||
: key === State.CachePrimaryKey
|
|
||||||
? pnpmFileHash
|
? pnpmFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? npmFileHash
|
||||||
: key === State.CachePaths
|
: key === State.CachePaths
|
||||||
? '["/foo/bar"]'
|
? '["/foo/bar"]'
|
||||||
: 'not expected'
|
: 'not expected'
|
||||||
@@ -322,9 +316,8 @@ describe('run', () => {
|
|||||||
);
|
);
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
`Cache saved with the key: ${pnpmFileHash}`
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
);
|
);
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', pnpmFileHash);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate if a cache was 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:
|
node-version:
|
||||||
description: 'The installed node version.'
|
description: 'The installed node version.'
|
||||||
runs:
|
runs:
|
||||||
|
|||||||
3076
dist/cache-save/index.js
vendored
3076
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load Diff
3078
dist/setup/index.js
vendored
3078
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
14
package-lock.json
generated
14
package-lock.json
generated
@@ -1061,9 +1061,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fastify/busboy": {
|
"node_modules/@fastify/busboy": {
|
||||||
"version": "2.0.0",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
||||||
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
|
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
||||||
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
@@ -5584,9 +5585,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.4",
|
"version": "5.28.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ export const restoreCache = async (
|
|||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
core.setOutput('cache-key', primaryKey);
|
|
||||||
|
|
||||||
const isManagedByYarnBerry = await repoHasYarnBerryManagedDependencies(
|
const isManagedByYarnBerry = await repoHasYarnBerryManagedDependencies(
|
||||||
packageManagerInfo,
|
packageManagerInfo,
|
||||||
@@ -62,8 +61,6 @@ export const restoreCache = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.setOutput('cache-hit', Boolean(cacheKey));
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
core.setOutput('cache-matched-key', cacheKey);
|
|
||||||
core.debug(`cache-matched-key is ${cacheKey}`);
|
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`${packageManager} cache is not found`);
|
core.info(`${packageManager} cache is not found`);
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ const cachePackages = async (packageManager: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
core.setOutput('cache-key', primaryKey);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
run(true);
|
run(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user