mirror of
https://github.com/actions/cache.git
synced 2026-07-02 18:34:40 +00:00
Compare commits
6 Commits
ae34eeee40
...
47d1e90e1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47d1e90e1c | ||
|
|
0c45773b62 | ||
|
|
8a55f839aa | ||
|
|
3884cace14 | ||
|
|
e29dad3e36 | ||
|
|
0eb01d12a1 |
@ -1,5 +1,9 @@
|
|||||||
# Releases
|
# Releases
|
||||||
|
|
||||||
|
### 4.0.2
|
||||||
|
|
||||||
|
- Fixed restore `fail-on-cache-miss` not working.
|
||||||
|
|
||||||
### 4.0.1
|
### 4.0.1
|
||||||
|
|
||||||
- Updated `isGhes` check
|
- Updated `isGhes` check
|
||||||
|
|||||||
@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => {
|
|||||||
);
|
);
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("restore failure with earlyExit should call process exit", async () => {
|
||||||
|
testUtils.setInput(Inputs.Path, "node_modules");
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||||
|
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
|
||||||
|
|
||||||
|
// call restoreImpl with `earlyExit` set to true
|
||||||
|
await restoreImpl(new StateProvider(), true);
|
||||||
|
|
||||||
|
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
|
||||||
|
expect(failedMock).toHaveBeenCalledWith(
|
||||||
|
"Input required and not supplied: key"
|
||||||
|
);
|
||||||
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
||||||
|
});
|
||||||
|
|||||||
20
dist/restore-only/index.js
vendored
20
dist/restore-only/index.js
vendored
@ -189,12 +189,13 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
const fileSizeMultiplierGb = 10 // 10GB per repo limit
|
||||||
|
const fileSizeLimit = fileSizeMultiplierGb * 1024 * 1024 * 1024;
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.debug(`File Size: ${archiveFileSize}`);
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the ${fileSizeMultiplierGb}GB limit, not saving cache.`);
|
||||||
}
|
}
|
||||||
core.debug('Reserving Cache');
|
core.debug('Reserving Cache');
|
||||||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||||||
@ -59392,7 +59393,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const stateProvider_1 = __nccwpck_require__(1527);
|
const stateProvider_1 = __nccwpck_require__(1527);
|
||||||
const utils = __importStar(__nccwpck_require__(6850));
|
const utils = __importStar(__nccwpck_require__(6850));
|
||||||
function restoreImpl(stateProvider) {
|
function restoreImpl(stateProvider, earlyExit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
@ -59438,21 +59439,16 @@ function restoreImpl(stateProvider) {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.restoreImpl = restoreImpl;
|
exports.restoreImpl = restoreImpl;
|
||||||
function run(stateProvider, earlyExit) {
|
function run(stateProvider, earlyExit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
yield restoreImpl(stateProvider, earlyExit);
|
||||||
yield restoreImpl(stateProvider);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
if (earlyExit) {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// node will stay alive if any promises are not resolved,
|
// node will stay alive if any promises are not resolved,
|
||||||
// which is a possibility if HTTP requests are dangling
|
// which is a possibility if HTTP requests are dangling
|
||||||
// due to retries or timeouts. We know that if we got here
|
// due to retries or timeouts. We know that if we got here
|
||||||
|
|||||||
20
dist/restore/index.js
vendored
20
dist/restore/index.js
vendored
@ -189,12 +189,13 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
const fileSizeMultiplierGb = 10 // 10GB per repo limit
|
||||||
|
const fileSizeLimit = fileSizeMultiplierGb * 1024 * 1024 * 1024;
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.debug(`File Size: ${archiveFileSize}`);
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the ${fileSizeMultiplierGb}GB limit, not saving cache.`);
|
||||||
}
|
}
|
||||||
core.debug('Reserving Cache');
|
core.debug('Reserving Cache');
|
||||||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||||||
@ -59392,7 +59393,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const stateProvider_1 = __nccwpck_require__(1527);
|
const stateProvider_1 = __nccwpck_require__(1527);
|
||||||
const utils = __importStar(__nccwpck_require__(6850));
|
const utils = __importStar(__nccwpck_require__(6850));
|
||||||
function restoreImpl(stateProvider) {
|
function restoreImpl(stateProvider, earlyExit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
@ -59438,21 +59439,16 @@ function restoreImpl(stateProvider) {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.restoreImpl = restoreImpl;
|
exports.restoreImpl = restoreImpl;
|
||||||
function run(stateProvider, earlyExit) {
|
function run(stateProvider, earlyExit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
yield restoreImpl(stateProvider, earlyExit);
|
||||||
yield restoreImpl(stateProvider);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
if (earlyExit) {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// node will stay alive if any promises are not resolved,
|
// node will stay alive if any promises are not resolved,
|
||||||
// which is a possibility if HTTP requests are dangling
|
// which is a possibility if HTTP requests are dangling
|
||||||
// due to retries or timeouts. We know that if we got here
|
// due to retries or timeouts. We know that if we got here
|
||||||
|
|||||||
5
dist/save-only/index.js
vendored
5
dist/save-only/index.js
vendored
@ -189,12 +189,13 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
const fileSizeMultiplierGb = 10 // 10GB per repo limit
|
||||||
|
const fileSizeLimit = fileSizeMultiplierGb * 1024 * 1024 * 1024;
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.debug(`File Size: ${archiveFileSize}`);
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the ${fileSizeMultiplierGb}GB limit, not saving cache.`);
|
||||||
}
|
}
|
||||||
core.debug('Reserving Cache');
|
core.debug('Reserving Cache');
|
||||||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||||||
|
|||||||
5
dist/save/index.js
vendored
5
dist/save/index.js
vendored
@ -189,12 +189,13 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
const fileSizeMultiplierGb = 10 // 10GB per repo limit
|
||||||
|
const fileSizeLimit = fileSizeMultiplierGb * 1024 * 1024 * 1024;
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.debug(`File Size: ${archiveFileSize}`);
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the ${fileSizeMultiplierGb}GB limit, not saving cache.`);
|
||||||
}
|
}
|
||||||
core.debug('Reserving Cache');
|
core.debug('Reserving Cache');
|
||||||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "4.0.1",
|
"version": "4.0.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "4.0.1",
|
"version": "4.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.2.3",
|
"@actions/cache": "^3.2.3",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "4.0.1",
|
"version": "4.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
|
|||||||
@ -10,7 +10,8 @@ import {
|
|||||||
import * as utils from "./utils/actionUtils";
|
import * as utils from "./utils/actionUtils";
|
||||||
|
|
||||||
export async function restoreImpl(
|
export async function restoreImpl(
|
||||||
stateProvider: IStateProvider
|
stateProvider: IStateProvider,
|
||||||
|
earlyExit?: boolean | undefined
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
@ -83,6 +84,9 @@ export async function restoreImpl(
|
|||||||
return cacheKey;
|
return cacheKey;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
core.setFailed((error as Error).message);
|
core.setFailed((error as Error).message);
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,14 +94,7 @@ async function run(
|
|||||||
stateProvider: IStateProvider,
|
stateProvider: IStateProvider,
|
||||||
earlyExit: boolean | undefined
|
earlyExit: boolean | undefined
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
await restoreImpl(stateProvider, earlyExit);
|
||||||
await restoreImpl(stateProvider);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
if (earlyExit) {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// node will stay alive if any promises are not resolved,
|
// node will stay alive if any promises are not resolved,
|
||||||
// which is a possibility if HTTP requests are dangling
|
// which is a possibility if HTTP requests are dangling
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user