Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@actions/cache

Package Overview
Dependencies
Maintainers
5
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actions/cache - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

27

lib/cache.js

@@ -129,2 +129,3 @@ "use strict";

function saveCache(paths, key, options) {
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function* () {

@@ -134,10 +135,3 @@ checkPaths(paths);

const compressionMethod = yield utils.getCompressionMethod();
core.debug('Reserving Cache');
const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod
});
if (cacheId === -1) {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
}
core.debug(`Cache ID: ${cacheId}`);
let cacheId = null;
const cachePaths = yield utils.resolvePaths(paths);

@@ -157,5 +151,20 @@ core.debug('Cache Paths:');

core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) {
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
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.`);
}
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
cacheSize: archiveFileSize
});
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
}
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
throw new ReserveCacheError((_d = (_c = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`);
}
core.debug(`Saving Cache (ID: ${cacheId})`);

@@ -162,0 +171,0 @@ yield cacheHttpClient.saveCache(cacheId, archivePath, options);

import { CompressionMethod } from './constants';
import { ArtifactCacheEntry, InternalCacheOptions } from './contracts';
import { ArtifactCacheEntry, InternalCacheOptions, ReserveCacheResponse, ITypedResponseWithError } from './contracts';
import { DownloadOptions, UploadOptions } from '../options';

@@ -7,3 +7,3 @@ export declare function getCacheVersion(paths: string[], compressionMethod?: CompressionMethod): string;

export declare function downloadCache(archiveLocation: string, archivePath: string, options?: DownloadOptions): Promise<void>;
export declare function reserveCache(key: string, paths: string[], options?: InternalCacheOptions): Promise<number>;
export declare function reserveCache(key: string, paths: string[], options?: InternalCacheOptions): Promise<ITypedResponseWithError<ReserveCacheResponse>>;
export declare function saveCache(cacheId: number, archivePath: string, options?: UploadOptions): Promise<void>;

@@ -110,3 +110,2 @@ "use strict";

function reserveCache(key, paths, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {

@@ -117,3 +116,4 @@ const httpClient = createHttpClient();

key,
version
version,
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
};

@@ -123,3 +123,3 @@ const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {

}));
return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1;
return response;
});

@@ -126,0 +126,0 @@ }

@@ -12,1 +12,2 @@ /// <reference types="node" />

export declare function assertDefined<T>(name: string, value?: T): T;
export declare function isGhes(): boolean;

@@ -170,2 +170,7 @@ "use strict";

exports.assertDefined = assertDefined;
function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
exports.isGhes = isGhes;
//# sourceMappingURL=cacheUtils.js.map

@@ -1,2 +0,3 @@

import { IHttpClientResponse, ITypedResponse } from '@actions/http-client/interfaces';
import { IHttpClientResponse } from '@actions/http-client/interfaces';
import { ITypedResponseWithError } from './contracts';
export declare function isSuccessStatusCode(statusCode?: number): boolean;

@@ -6,3 +7,3 @@ export declare function isServerErrorStatusCode(statusCode?: number): boolean;

export declare function retry<T>(name: string, method: () => Promise<T>, getStatusCode: (arg0: T) => number | undefined, maxAttempts?: number, delay?: number, onError?: ((arg0: Error) => T | undefined) | undefined): Promise<T>;
export declare function retryTypedResponse<T>(name: string, method: () => Promise<ITypedResponse<T>>, maxAttempts?: number, delay?: number): Promise<ITypedResponse<T>>;
export declare function retryTypedResponse<T>(name: string, method: () => Promise<ITypedResponseWithError<T>>, maxAttempts?: number, delay?: number): Promise<ITypedResponseWithError<T>>;
export declare function retryHttpClientResponse(name: string, method: () => Promise<IHttpClientResponse>, maxAttempts?: number, delay?: number): Promise<IHttpClientResponse>;

@@ -103,3 +103,4 @@ "use strict";

result: null,
headers: {}
headers: {},
error
};

@@ -106,0 +107,0 @@ }

{
"name": "@actions/cache",
"version": "2.0.0",
"version": "2.0.1",
"preview": true,

@@ -5,0 +5,0 @@ "description": "Actions cache lib",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc