Compare commits

...

5 Commits

Author SHA1 Message Date
Alex Dunae
4b0bdc3f1f
Merge d23de777e0 into 65beceff8e 2025-07-25 15:26:47 +10:00
dependabot[bot]
65beceff8e
Bump undici from 5.28.5 to 5.29.0 (#1295)
* Bump undici from 5.28.5 to 5.29.0

Bumps [undici](https://github.com/nodejs/undici) from 5.28.5 to 5.29.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.28.5...v5.29.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 5.29.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* check failures fix

* check-failures fix

* check failures fix

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aparna Jyothi <aparnajyothi-y@github.com>
Co-authored-by: “gowridurgad” <“hgowridurgad@github.com>
2025-07-24 21:39:27 -05:00
Alex Dunae
d23de777e0 Add output cache-matched-key 2025-01-15 12:03:24 -08:00
Alex Dunae
82af78e9c4 Add dist 2025-01-14 10:46:08 -08:00
Alex Dunae
870d3d8e13 Add cache-key as output 2025-01-14 10:40:03 -08:00
9 changed files with 161 additions and 70 deletions

View File

@ -1,6 +1,6 @@
--- ---
name: undici name: undici
version: 5.28.5 version: 5.29.0
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

View File

@ -131,6 +131,7 @@ 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;
@ -142,12 +143,20 @@ 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: node-cache-${platform}-${arch}-${packageManager}-${fileHash}` `Cache restored from key: ${expectedCacheKey}`
); );
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
);
} }
); );
}); });
@ -161,6 +170,7 @@ 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;
@ -176,10 +186,72 @@ 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();

View File

@ -27,6 +27,7 @@ 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;
@ -53,6 +54,8 @@ 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) => {
@ -228,6 +231,7 @@ 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();
}); });
@ -258,6 +262,7 @@ 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();
}); });
@ -288,6 +293,7 @@ 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();
}); });
@ -297,9 +303,9 @@ describe('run', () => {
key === State.CachePackageManager key === State.CachePackageManager
? inputs['cache'] ? inputs['cache']
: key === State.CacheMatchedKey : key === State.CacheMatchedKey
? pnpmFileHash ? 'no-match'
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? npmFileHash ? pnpmFileHash
: key === State.CachePaths : key === State.CachePaths
? '["/foo/bar"]' ? '["/foo/bar"]'
: 'not expected' : 'not expected'
@ -316,8 +322,9 @@ describe('run', () => {
); );
expect(saveCacheSpy).toHaveBeenCalled(); expect(saveCacheSpy).toHaveBeenCalled();
expect(infoSpy).toHaveBeenLastCalledWith( 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(); expect(setFailedSpy).not.toHaveBeenCalled();
}); });

View File

@ -34,6 +34,10 @@ 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:

View File

@ -64080,7 +64080,7 @@ module.exports = {
const { parseSetCookie } = __nccwpck_require__(8915) const { parseSetCookie } = __nccwpck_require__(8915)
const { stringify, getHeadersList } = __nccwpck_require__(3834) const { stringify } = __nccwpck_require__(3834)
const { webidl } = __nccwpck_require__(4222) const { webidl } = __nccwpck_require__(4222)
const { Headers } = __nccwpck_require__(6349) const { Headers } = __nccwpck_require__(6349)
@ -64156,14 +64156,13 @@ function getSetCookies (headers) {
webidl.brandCheck(headers, Headers, { strict: false }) webidl.brandCheck(headers, Headers, { strict: false })
const cookies = getHeadersList(headers).cookies const cookies = headers.getSetCookie()
if (!cookies) { if (!cookies) {
return [] return []
} }
// In older versions of undici, cookies is a list of name:value. return cookies.map((pair) => parseSetCookie(pair))
return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
} }
/** /**
@ -64591,14 +64590,15 @@ module.exports = {
/***/ }), /***/ }),
/***/ 3834: /***/ 3834:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /***/ ((module) => {
"use strict"; "use strict";
const assert = __nccwpck_require__(2613) /**
const { kHeadersList } = __nccwpck_require__(6443) * @param {string} value
* @returns {boolean}
*/
function isCTLExcludingHtab (value) { function isCTLExcludingHtab (value) {
if (value.length === 0) { if (value.length === 0) {
return false return false
@ -64859,31 +64859,13 @@ function stringify (cookie) {
return out.join('; ') return out.join('; ')
} }
let kHeadersListNode
function getHeadersList (headers) {
if (headers[kHeadersList]) {
return headers[kHeadersList]
}
if (!kHeadersListNode) {
kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
(symbol) => symbol.description === 'headers list'
)
assert(kHeadersListNode, 'Headers cannot be parsed')
}
const headersList = headers[kHeadersListNode]
assert(headersList)
return headersList
}
module.exports = { module.exports = {
isCTLExcludingHtab, isCTLExcludingHtab,
stringify, validateCookieName,
getHeadersList validateCookiePath,
validateCookieValue,
toIMFDate,
stringify
} }
@ -68887,6 +68869,7 @@ const {
isValidHeaderName, isValidHeaderName,
isValidHeaderValue isValidHeaderValue
} = __nccwpck_require__(5523) } = __nccwpck_require__(5523)
const util = __nccwpck_require__(9023)
const { webidl } = __nccwpck_require__(4222) const { webidl } = __nccwpck_require__(4222)
const assert = __nccwpck_require__(2613) const assert = __nccwpck_require__(2613)
@ -69440,6 +69423,9 @@ Object.defineProperties(Headers.prototype, {
[Symbol.toStringTag]: { [Symbol.toStringTag]: {
value: 'Headers', value: 'Headers',
configurable: true configurable: true
},
[util.inspect.custom]: {
enumerable: false
} }
}) })
@ -78616,6 +78602,20 @@ class Pool extends PoolBase {
? { ...options.interceptors } ? { ...options.interceptors }
: undefined : undefined
this[kFactory] = factory this[kFactory] = factory
this.on('connectionError', (origin, targets, error) => {
// If a connection error occurs, we remove the client from the pool,
// and emit a connectionError event. They will not be re-used.
// Fixes https://github.com/nodejs/undici/issues/3895
for (const target of targets) {
// Do not use kRemoveClient here, as it will close the client,
// but the client cannot be closed in this state.
const idx = this[kClients].indexOf(target)
if (idx !== -1) {
this[kClients].splice(idx, 1)
}
}
})
} }
[kGetDispatcher] () { [kGetDispatcher] () {
@ -87983,6 +87983,7 @@ const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, func
return; return;
} }
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);

65
dist/setup/index.js vendored
View File

@ -73388,7 +73388,7 @@ module.exports = {
const { parseSetCookie } = __nccwpck_require__(8915) const { parseSetCookie } = __nccwpck_require__(8915)
const { stringify, getHeadersList } = __nccwpck_require__(3834) const { stringify } = __nccwpck_require__(3834)
const { webidl } = __nccwpck_require__(4222) const { webidl } = __nccwpck_require__(4222)
const { Headers } = __nccwpck_require__(6349) const { Headers } = __nccwpck_require__(6349)
@ -73464,14 +73464,13 @@ function getSetCookies (headers) {
webidl.brandCheck(headers, Headers, { strict: false }) webidl.brandCheck(headers, Headers, { strict: false })
const cookies = getHeadersList(headers).cookies const cookies = headers.getSetCookie()
if (!cookies) { if (!cookies) {
return [] return []
} }
// In older versions of undici, cookies is a list of name:value. return cookies.map((pair) => parseSetCookie(pair))
return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
} }
/** /**
@ -73899,14 +73898,15 @@ module.exports = {
/***/ }), /***/ }),
/***/ 3834: /***/ 3834:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /***/ ((module) => {
"use strict"; "use strict";
const assert = __nccwpck_require__(2613) /**
const { kHeadersList } = __nccwpck_require__(6443) * @param {string} value
* @returns {boolean}
*/
function isCTLExcludingHtab (value) { function isCTLExcludingHtab (value) {
if (value.length === 0) { if (value.length === 0) {
return false return false
@ -74167,31 +74167,13 @@ function stringify (cookie) {
return out.join('; ') return out.join('; ')
} }
let kHeadersListNode
function getHeadersList (headers) {
if (headers[kHeadersList]) {
return headers[kHeadersList]
}
if (!kHeadersListNode) {
kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
(symbol) => symbol.description === 'headers list'
)
assert(kHeadersListNode, 'Headers cannot be parsed')
}
const headersList = headers[kHeadersListNode]
assert(headersList)
return headersList
}
module.exports = { module.exports = {
isCTLExcludingHtab, isCTLExcludingHtab,
stringify, validateCookieName,
getHeadersList validateCookiePath,
validateCookieValue,
toIMFDate,
stringify
} }
@ -78195,6 +78177,7 @@ const {
isValidHeaderName, isValidHeaderName,
isValidHeaderValue isValidHeaderValue
} = __nccwpck_require__(5523) } = __nccwpck_require__(5523)
const util = __nccwpck_require__(9023)
const { webidl } = __nccwpck_require__(4222) const { webidl } = __nccwpck_require__(4222)
const assert = __nccwpck_require__(2613) const assert = __nccwpck_require__(2613)
@ -78748,6 +78731,9 @@ Object.defineProperties(Headers.prototype, {
[Symbol.toStringTag]: { [Symbol.toStringTag]: {
value: 'Headers', value: 'Headers',
configurable: true configurable: true
},
[util.inspect.custom]: {
enumerable: false
} }
}) })
@ -87924,6 +87910,20 @@ class Pool extends PoolBase {
? { ...options.interceptors } ? { ...options.interceptors }
: undefined : undefined
this[kFactory] = factory this[kFactory] = factory
this.on('connectionError', (origin, targets, error) => {
// If a connection error occurs, we remove the client from the pool,
// and emit a connectionError event. They will not be re-used.
// Fixes https://github.com/nodejs/undici/issues/3895
for (const target of targets) {
// Do not use kRemoveClient here, as it will close the client,
// but the client cannot be closed in this state.
const idx = this[kClients].indexOf(target)
if (idx !== -1) {
this[kClients].splice(idx, 1)
}
}
})
} }
[kGetDispatcher] () { [kGetDispatcher] () {
@ -97411,6 +97411,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
const primaryKey = `${keyPrefix}-${fileHash}`; const primaryKey = `${keyPrefix}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`); core.debug(`primary key is ${primaryKey}`);
core.saveState(constants_1.State.CachePrimaryKey, primaryKey); core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
core.setOutput('cache-key', primaryKey);
const isManagedByYarnBerry = yield (0, cache_utils_1.repoHasYarnBerryManagedDependencies)(packageManagerInfo, cacheDependencyPath); const isManagedByYarnBerry = yield (0, cache_utils_1.repoHasYarnBerryManagedDependencies)(packageManagerInfo, cacheDependencyPath);
let cacheKey; let cacheKey;
if (isManagedByYarnBerry) { if (isManagedByYarnBerry) {
@ -97421,6 +97422,8 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
cacheKey = yield cache.restoreCache(cachePaths, primaryKey); cacheKey = yield cache.restoreCache(cachePaths, primaryKey);
} }
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`);
return; return;

6
package-lock.json generated
View File

@ -5371,9 +5371,9 @@
} }
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.28.5", "version": "5.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==", "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fastify/busboy": "^2.0.0" "@fastify/busboy": "^2.0.0"

View File

@ -45,6 +45,7 @@ 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,
@ -61,6 +62,8 @@ 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`);

View File

@ -66,6 +66,7 @@ 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);