Compare commits

..

4 Commits

Author SHA1 Message Date
Alex Dunae
6fcbc09dff Merge d23de777e0 into 22c0e7494f 2025-03-13 09:36:44 +11: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
11 changed files with 269 additions and 52 deletions

View File

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

39
.licenses/npm/uuid-3.4.0.dep.yml generated Normal file
View 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>

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

@@ -30,6 +30,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

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

159
dist/setup/index.js vendored
View File

@@ -10371,11 +10371,7 @@ function copyFile(srcFile, destFile, force) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -10388,7 +10384,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -10418,11 +10414,11 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
let file; let file;
for (const candidate of candidates) { for (const candidate of candidates) {
const version = candidate.version; const version = candidate.version;
(0, core_1.debug)(`check ${version} satisfies ${versionSpec}`); core_1.debug(`check ${version} satisfies ${versionSpec}`);
if (semver.satisfies(version, versionSpec) && if (semver.satisfies(version, versionSpec) &&
(!stable || candidate.stable === stable)) { (!stable || candidate.stable === stable)) {
file = candidate.files.find(item => { file = candidate.files.find(item => {
(0, core_1.debug)(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`); core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
let chk = item.arch === archFilter && item.platform === platFilter; let chk = item.arch === archFilter && item.platform === platFilter;
if (chk && item.platform_version) { if (chk && item.platform_version) {
const osVersion = module.exports._getOsVersion(); const osVersion = module.exports._getOsVersion();
@@ -10436,7 +10432,7 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
return chk; return chk;
}); });
if (file) { if (file) {
(0, core_1.debug)(`matched ${candidate.version}`); core_1.debug(`matched ${candidate.version}`);
match = candidate; match = candidate;
break; break;
} }
@@ -10474,7 +10470,10 @@ function _getOsVersion() {
if (parts.length === 2 && if (parts.length === 2 &&
(parts[0].trim() === 'VERSION_ID' || (parts[0].trim() === 'VERSION_ID' ||
parts[0].trim() === 'DISTRIB_RELEASE')) { parts[0].trim() === 'DISTRIB_RELEASE')) {
version = parts[1].trim().replace(/^"/, '').replace(/"$/, ''); version = parts[1]
.trim()
.replace(/^"/, '')
.replace(/"$/, '');
break; break;
} }
} }
@@ -10507,11 +10506,7 @@ exports._readLinuxVersionFile = _readLinuxVersionFile;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -10524,7 +10519,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -10601,11 +10596,7 @@ exports.RetryHelper = RetryHelper;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -10618,7 +10609,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -10631,11 +10622,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0; exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const io = __importStar(__nccwpck_require__(4994)); const io = __importStar(__nccwpck_require__(4994));
const crypto = __importStar(__nccwpck_require__(6982));
const fs = __importStar(__nccwpck_require__(9896)); const fs = __importStar(__nccwpck_require__(9896));
const mm = __importStar(__nccwpck_require__(8036)); const mm = __importStar(__nccwpck_require__(8036));
const os = __importStar(__nccwpck_require__(857)); const os = __importStar(__nccwpck_require__(857));
@@ -10645,6 +10638,7 @@ const semver = __importStar(__nccwpck_require__(6193));
const stream = __importStar(__nccwpck_require__(2203)); const stream = __importStar(__nccwpck_require__(2203));
const util = __importStar(__nccwpck_require__(9023)); const util = __importStar(__nccwpck_require__(9023));
const assert_1 = __nccwpck_require__(2613); const assert_1 = __nccwpck_require__(2613);
const v4_1 = __importDefault(__nccwpck_require__(1350));
const exec_1 = __nccwpck_require__(5236); const exec_1 = __nccwpck_require__(5236);
const retry_helper_1 = __nccwpck_require__(7380); const retry_helper_1 = __nccwpck_require__(7380);
class HTTPError extends Error { class HTTPError extends Error {
@@ -10669,7 +10663,7 @@ const userAgent = 'actions/tool-cache';
*/ */
function downloadTool(url, dest, auth, headers) { function downloadTool(url, dest, auth, headers) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
dest = dest || path.join(_getTempDirectory(), crypto.randomUUID()); dest = dest || path.join(_getTempDirectory(), v4_1.default());
yield io.mkdirP(path.dirname(dest)); yield io.mkdirP(path.dirname(dest));
core.debug(`Downloading ${url}`); core.debug(`Downloading ${url}`);
core.debug(`Destination ${dest}`); core.debug(`Destination ${dest}`);
@@ -10758,8 +10752,8 @@ function downloadToolAttempt(url, dest, auth, headers) {
*/ */
function extract7z(file, dest, _7zPath) { function extract7z(file, dest, _7zPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
(0, assert_1.ok)(IS_WINDOWS, 'extract7z() not supported on current OS'); assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
(0, assert_1.ok)(file, 'parameter "file" is required'); assert_1.ok(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
const originalCwd = process.cwd(); const originalCwd = process.cwd();
process.chdir(dest); process.chdir(dest);
@@ -10776,7 +10770,7 @@ function extract7z(file, dest, _7zPath) {
const options = { const options = {
silent: true silent: true
}; };
yield (0, exec_1.exec)(`"${_7zPath}"`, args, options); yield exec_1.exec(`"${_7zPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -10805,7 +10799,7 @@ function extract7z(file, dest, _7zPath) {
}; };
try { try {
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
yield (0, exec_1.exec)(`"${powershellPath}"`, args, options); yield exec_1.exec(`"${powershellPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -10833,7 +10827,7 @@ function extractTar(file, dest, flags = 'xz') {
// Determine whether GNU tar // Determine whether GNU tar
core.debug('Checking tar --version'); core.debug('Checking tar --version');
let versionOutput = ''; let versionOutput = '';
yield (0, exec_1.exec)('tar --version', [], { yield exec_1.exec('tar --version', [], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: true, silent: true,
listeners: { listeners: {
@@ -10869,7 +10863,7 @@ function extractTar(file, dest, flags = 'xz') {
args.push('--overwrite'); args.push('--overwrite');
} }
args.push('-C', destArg, '-f', fileArg); args.push('-C', destArg, '-f', fileArg);
yield (0, exec_1.exec)(`tar`, args); yield exec_1.exec(`tar`, args);
return dest; return dest;
}); });
} }
@@ -10884,8 +10878,8 @@ exports.extractTar = extractTar;
*/ */
function extractXar(file, dest, flags = []) { function extractXar(file, dest, flags = []) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
(0, assert_1.ok)(IS_MAC, 'extractXar() not supported on current OS'); assert_1.ok(IS_MAC, 'extractXar() not supported on current OS');
(0, assert_1.ok)(file, 'parameter "file" is required'); assert_1.ok(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
let args; let args;
if (flags instanceof Array) { if (flags instanceof Array) {
@@ -10899,7 +10893,7 @@ function extractXar(file, dest, flags = []) {
args.push('-v'); args.push('-v');
} }
const xarPath = yield io.which('xar', true); const xarPath = yield io.which('xar', true);
yield (0, exec_1.exec)(`"${xarPath}"`, _unique(args)); yield exec_1.exec(`"${xarPath}"`, _unique(args));
return dest; return dest;
}); });
} }
@@ -10953,7 +10947,7 @@ function extractZipWin(file, dest) {
pwshCommand pwshCommand
]; ];
core.debug(`Using pwsh at path: ${pwshPath}`); core.debug(`Using pwsh at path: ${pwshPath}`);
yield (0, exec_1.exec)(`"${pwshPath}"`, args); yield exec_1.exec(`"${pwshPath}"`, args);
} }
else { else {
const powershellCommand = [ const powershellCommand = [
@@ -10974,7 +10968,7 @@ function extractZipWin(file, dest) {
]; ];
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
core.debug(`Using powershell at path: ${powershellPath}`); core.debug(`Using powershell at path: ${powershellPath}`);
yield (0, exec_1.exec)(`"${powershellPath}"`, args); yield exec_1.exec(`"${powershellPath}"`, args);
} }
}); });
} }
@@ -10986,7 +10980,7 @@ function extractZipNix(file, dest) {
args.unshift('-q'); args.unshift('-q');
} }
args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run
yield (0, exec_1.exec)(`"${unzipPath}"`, args, { cwd: dest }); yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest });
}); });
} }
/** /**
@@ -11163,7 +11157,7 @@ function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!dest) { if (!dest) {
// create a temp dir // create a temp dir
dest = path.join(_getTempDirectory(), crypto.randomUUID()); dest = path.join(_getTempDirectory(), v4_1.default());
} }
yield io.mkdirP(dest); yield io.mkdirP(dest);
return dest; return dest;
@@ -11236,7 +11230,7 @@ exports.evaluateVersions = evaluateVersions;
*/ */
function _getCacheDirectory() { function _getCacheDirectory() {
const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || '';
(0, assert_1.ok)(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined');
return cacheDirectory; return cacheDirectory;
} }
/** /**
@@ -11244,7 +11238,7 @@ function _getCacheDirectory() {
*/ */
function _getTempDirectory() { function _getTempDirectory() {
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDirectory = process.env['RUNNER_TEMP'] || '';
(0, assert_1.ok)(tempDirectory, 'Expected RUNNER_TEMP to be defined'); assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
return tempDirectory; return tempDirectory;
} }
/** /**
@@ -12915,6 +12909,90 @@ function coerce (version, options) {
} }
/***/ }),
/***/ 2727:
/***/ ((module) => {
/**
* Convert array of 16 byte values to UUID string format of the form:
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex[i] = (i + 0x100).toString(16).substr(1);
}
function bytesToUuid(buf, offset) {
var i = offset || 0;
var bth = byteToHex;
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
return ([
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]]
]).join('');
}
module.exports = bytesToUuid;
/***/ }),
/***/ 9879:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
// Unique ID creation requires a high quality random # generator. In node.js
// this is pretty straight-forward - we use the crypto API.
var crypto = __nccwpck_require__(6982);
module.exports = function nodeRNG() {
return crypto.randomBytes(16);
};
/***/ }),
/***/ 1350:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var rng = __nccwpck_require__(9879);
var bytesToUuid = __nccwpck_require__(2727);
function v4(options, buf, offset) {
var i = buf && offset || 0;
if (typeof(options) == 'string') {
buf = options === 'binary' ? new Array(16) : null;
options = null;
}
options = options || {};
var rnds = options.random || (options.rng || rng)();
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = (rnds[6] & 0x0f) | 0x40;
rnds[8] = (rnds[8] & 0x3f) | 0x80;
// Copy bytes to buffer, if provided
if (buf) {
for (var ii = 0; ii < 16; ++ii) {
buf[i + ii] = rnds[ii];
}
}
return buf || bytesToUuid(rnds);
}
module.exports = v4;
/***/ }), /***/ }),
/***/ 8110: /***/ 8110:
@@ -96689,6 +96767,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) {
@@ -96699,6 +96778,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;

23
package-lock.json generated
View File

@@ -16,7 +16,7 @@
"@actions/glob": "^0.5.0", "@actions/glob": "^0.5.0",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.2", "@actions/tool-cache": "^2.0.1",
"semver": "^7.6.3", "semver": "^7.6.3",
"uuid": "^9.0.1" "uuid": "^9.0.1"
}, },
@@ -138,16 +138,16 @@
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
}, },
"node_modules/@actions/tool-cache": { "node_modules/@actions/tool-cache": {
"version": "2.0.2", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz", "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==", "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
"license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.11.1", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.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": { "node_modules/@actions/tool-cache/node_modules/semver": {
@@ -158,6 +158,15 @@
"semver": "bin/semver.js" "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": { "node_modules/@ampproject/remapping": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",

View File

@@ -32,7 +32,7 @@
"@actions/glob": "^0.5.0", "@actions/glob": "^0.5.0",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.2", "@actions/tool-cache": "^2.0.1",
"semver": "^7.6.3", "semver": "^7.6.3",
"uuid": "^9.0.1" "uuid": "^9.0.1"
}, },

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);