mirror of
				https://gitea.com/actions/cache.git
				synced 2025-11-02 07:47:08 +00:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			vsvipul/fi
			...
			tiwarishub
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					402b512df8 | ||
| 
						 | 
					71e3ee5cce | ||
| 
						 | 
					c316eb7911 | ||
| 
						 | 
					0865c47f36 | ||
| 
						 | 
					354a2ae15e | ||
| 
						 | 
					baed3516c3 | ||
| 
						 | 
					8829e97be1 | ||
| 
						 | 
					eec8cd3f5f | ||
| 
						 | 
					2086306d9c | 
							
								
								
									
										1
									
								
								.github/auto_assign.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/auto_assign.yml
									
									
									
									
										vendored
									
									
								
							@@ -6,6 +6,7 @@ addAssignees: false
 | 
			
		||||
 | 
			
		||||
# A list of reviewers to be added to pull requests (GitHub user name)
 | 
			
		||||
reviewers:
 | 
			
		||||
  - phantsure
 | 
			
		||||
  - kotewar
 | 
			
		||||
  - aparna-ravindra
 | 
			
		||||
  - tiwarishub
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/workflows/auto-assign-issues.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/auto-assign-issues.yml
									
									
									
									
										vendored
									
									
								
							@@ -11,5 +11,5 @@ jobs:
 | 
			
		||||
            - name: 'Auto-assign issue'
 | 
			
		||||
              uses: pozil/auto-assign-issue@v1.4.0
 | 
			
		||||
              with:
 | 
			
		||||
                  assignees: kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
 | 
			
		||||
                  assignees: phantsure,kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
 | 
			
		||||
                  numOfAssignee: 1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/cache"
 | 
			
		||||
version: 2.0.6
 | 
			
		||||
version: 3.0.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
 
 | 
			
		||||
@@ -72,6 +72,8 @@ jobs:
 | 
			
		||||
      run: /primes.sh -d prime-numbers
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` doesn't match an existing cache, a new cache is automatically created if the job completes successfully.
 | 
			
		||||
 | 
			
		||||
## Implementation Examples
 | 
			
		||||
 | 
			
		||||
Every programming language and framework has its own way of caching.
 | 
			
		||||
 
 | 
			
		||||
@@ -15,3 +15,6 @@
 | 
			
		||||
 | 
			
		||||
### 3.0.4
 | 
			
		||||
- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689))
 | 
			
		||||
 | 
			
		||||
### 3.0.5
 | 
			
		||||
- Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. ([PR](https://github.com/actions/cache/pull/834))
 | 
			
		||||
@@ -227,40 +227,6 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("restore with server error should fail", async () => {
 | 
			
		||||
    const path = "node_modules";
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const logWarningMock = jest.spyOn(actionUtils, "logWarning");
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
    const stateMock = jest.spyOn(core, "saveState");
 | 
			
		||||
    const restoreCacheMock = jest
 | 
			
		||||
        .spyOn(cache, "restoreCache")
 | 
			
		||||
        .mockImplementationOnce(() => {
 | 
			
		||||
            throw new Error("HTTP Error Occurred");
 | 
			
		||||
        });
 | 
			
		||||
    const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
 | 
			
		||||
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred");
 | 
			
		||||
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
 | 
			
		||||
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    const path = "node_modules";
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
 
 | 
			
		||||
@@ -267,7 +267,6 @@ test("save with large cache outputs warning", async () => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("save with reserve cache failure outputs warning", async () => {
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
    const logWarningMock = jest.spyOn(actionUtils, "logWarning");
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
 | 
			
		||||
@@ -306,10 +305,10 @@ test("save with reserve cache failure outputs warning", async () => {
 | 
			
		||||
        expect.anything()
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(infoMock).toHaveBeenCalledWith(
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledWith(
 | 
			
		||||
        `Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`
 | 
			
		||||
    );
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								actions-cache-3.0.1.tgz
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								actions-cache-3.0.1.tgz
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										124
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										124
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							@@ -1113,7 +1113,13 @@ function resolvePaths(patterns) {
 | 
			
		||||
                    .replace(new RegExp(`\\${path.sep}`, 'g'), '/');
 | 
			
		||||
                core.debug(`Matched: ${relativeFile}`);
 | 
			
		||||
                // Paths are made relative so the tar entries are all relative to the root of the workspace.
 | 
			
		||||
                paths.push(`${relativeFile}`);
 | 
			
		||||
                if (relativeFile === '') {
 | 
			
		||||
                    // path.relative returns empty string if workspace and file are equal
 | 
			
		||||
                    paths.push('.');
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    paths.push(`${relativeFile}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
 | 
			
		||||
@@ -5464,6 +5470,7 @@ const buffer = __importStar(__webpack_require__(293));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const stream = __importStar(__webpack_require__(794));
 | 
			
		||||
const util = __importStar(__webpack_require__(669));
 | 
			
		||||
const timer = __importStar(__webpack_require__(581));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@@ -5654,10 +5661,14 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
 | 
			
		||||
                    const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
 | 
			
		||||
                    const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
 | 
			
		||||
                    downloadProgress.nextSegment(segmentSize);
 | 
			
		||||
                    const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
 | 
			
		||||
                        concurrency: options.downloadConcurrency,
 | 
			
		||||
                        onProgress: downloadProgress.onProgress()
 | 
			
		||||
                    });
 | 
			
		||||
                    const result = yield Promise.race([client.downloadToBuffer(segmentStart, segmentSize, {
 | 
			
		||||
                            concurrency: options.downloadConcurrency,
 | 
			
		||||
                            onProgress: downloadProgress.onProgress()
 | 
			
		||||
                        }),
 | 
			
		||||
                        timer.setTimeout(60 * 60 * 1000, 'timeout')]);
 | 
			
		||||
                    if (result === 'timeout') {
 | 
			
		||||
                        throw new Error("Segment download timed out");
 | 
			
		||||
                    }
 | 
			
		||||
                    fs.writeFileSync(fd, result);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -37272,9 +37283,9 @@ function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -37305,9 +37316,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -T0 --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'zstdmt --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -T0'];
 | 
			
		||||
                    return ['--use-compress-program', 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -37338,9 +37349,9 @@ function listTar(archivePath, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -42343,7 +42354,12 @@ function clean(key)
 | 
			
		||||
/* 578 */,
 | 
			
		||||
/* 579 */,
 | 
			
		||||
/* 580 */,
 | 
			
		||||
/* 581 */,
 | 
			
		||||
/* 581 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
module.exports = require("timers/promises");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 582 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
@@ -46850,17 +46866,18 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
            checkKey(key);
 | 
			
		||||
        }
 | 
			
		||||
        const compressionMethod = yield utils.getCompressionMethod();
 | 
			
		||||
        // path are needed to compute version
 | 
			
		||||
        const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
            compressionMethod
 | 
			
		||||
        });
 | 
			
		||||
        if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
            // Cache not found
 | 
			
		||||
            return undefined;
 | 
			
		||||
        }
 | 
			
		||||
        const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
 | 
			
		||||
        core.debug(`Archive Path: ${archivePath}`);
 | 
			
		||||
        let archivePath = '';
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
                return undefined;
 | 
			
		||||
            }
 | 
			
		||||
            archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
 | 
			
		||||
            core.debug(`Archive Path: ${archivePath}`);
 | 
			
		||||
            // Download the cache from the cache entry
 | 
			
		||||
            yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
@@ -46870,6 +46887,17 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
            core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
 | 
			
		||||
            yield tar_1.extractTar(archivePath, compressionMethod);
 | 
			
		||||
            core.info('Cache restored successfully');
 | 
			
		||||
            return cacheEntry.cacheKey;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            const typedError = error;
 | 
			
		||||
            if (typedError.name === ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                // Supress all non-validation cache related errors because caching should be optional
 | 
			
		||||
                core.warning(`Failed to restore: ${error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        finally {
 | 
			
		||||
            // Try to delete the archive to save space
 | 
			
		||||
@@ -46880,7 +46908,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
                core.debug(`Failed to delete archive: ${error}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return cacheEntry.cacheKey;
 | 
			
		||||
        return undefined;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.restoreCache = restoreCache;
 | 
			
		||||
@@ -46898,7 +46926,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        checkKey(key);
 | 
			
		||||
        const compressionMethod = yield utils.getCompressionMethod();
 | 
			
		||||
        let cacheId = null;
 | 
			
		||||
        let cacheId = -1;
 | 
			
		||||
        const cachePaths = yield utils.resolvePaths(paths);
 | 
			
		||||
        core.debug('Cache Paths:');
 | 
			
		||||
        core.debug(`${JSON.stringify(cachePaths)}`);
 | 
			
		||||
@@ -46937,6 +46965,18 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug(`Saving Cache (ID: ${cacheId})`);
 | 
			
		||||
            yield cacheHttpClient.saveCache(cacheId, archivePath, options);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            const typedError = error;
 | 
			
		||||
            if (typedError.name === ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            }
 | 
			
		||||
            else if (typedError.name === ReserveCacheError.name) {
 | 
			
		||||
                core.info(`Failed to save: ${typedError.message}`);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                core.warning(`Failed to save: ${typedError.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        finally {
 | 
			
		||||
            // Try to delete the archive to save space
 | 
			
		||||
            try {
 | 
			
		||||
@@ -48996,31 +49036,19 @@ function run() {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            try {
 | 
			
		||||
                const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
                if (!cacheKey) {
 | 
			
		||||
                    core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                        primaryKey,
 | 
			
		||||
                        ...restoreKeys
 | 
			
		||||
                    ].join(", ")}`);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                // Store the matched cache key
 | 
			
		||||
                utils.setCacheState(cacheKey);
 | 
			
		||||
                const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
                utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
                core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                const typedError = error;
 | 
			
		||||
                if (typedError.name === cache.ValidationError.name) {
 | 
			
		||||
                    throw error;
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    utils.logWarning(typedError.message);
 | 
			
		||||
                    utils.setCacheHitOutput(false);
 | 
			
		||||
                }
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										108
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										108
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							@@ -1113,7 +1113,13 @@ function resolvePaths(patterns) {
 | 
			
		||||
                    .replace(new RegExp(`\\${path.sep}`, 'g'), '/');
 | 
			
		||||
                core.debug(`Matched: ${relativeFile}`);
 | 
			
		||||
                // Paths are made relative so the tar entries are all relative to the root of the workspace.
 | 
			
		||||
                paths.push(`${relativeFile}`);
 | 
			
		||||
                if (relativeFile === '') {
 | 
			
		||||
                    // path.relative returns empty string if workspace and file are equal
 | 
			
		||||
                    paths.push('.');
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    paths.push(`${relativeFile}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
 | 
			
		||||
@@ -5464,6 +5470,7 @@ const buffer = __importStar(__webpack_require__(293));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const stream = __importStar(__webpack_require__(794));
 | 
			
		||||
const util = __importStar(__webpack_require__(669));
 | 
			
		||||
const timer = __importStar(__webpack_require__(581));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@@ -5654,10 +5661,14 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
 | 
			
		||||
                    const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
 | 
			
		||||
                    const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
 | 
			
		||||
                    downloadProgress.nextSegment(segmentSize);
 | 
			
		||||
                    const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
 | 
			
		||||
                        concurrency: options.downloadConcurrency,
 | 
			
		||||
                        onProgress: downloadProgress.onProgress()
 | 
			
		||||
                    });
 | 
			
		||||
                    const result = yield Promise.race([client.downloadToBuffer(segmentStart, segmentSize, {
 | 
			
		||||
                            concurrency: options.downloadConcurrency,
 | 
			
		||||
                            onProgress: downloadProgress.onProgress()
 | 
			
		||||
                        }),
 | 
			
		||||
                        timer.setTimeout(60 * 60 * 1000, 'timeout')]);
 | 
			
		||||
                    if (result === 'timeout') {
 | 
			
		||||
                        throw new Error("Segment download timed out");
 | 
			
		||||
                    }
 | 
			
		||||
                    fs.writeFileSync(fd, result);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -37272,9 +37283,9 @@ function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -37305,9 +37316,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -T0 --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'zstdmt --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -T0'];
 | 
			
		||||
                    return ['--use-compress-program', 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -37338,9 +37349,9 @@ function listTar(archivePath, compressionMethod) {
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d --long=30'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd --long=30'];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', 'zstd -d'];
 | 
			
		||||
                    return ['--use-compress-program', 'unzstd'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
@@ -42343,7 +42354,12 @@ function clean(key)
 | 
			
		||||
/* 578 */,
 | 
			
		||||
/* 579 */,
 | 
			
		||||
/* 580 */,
 | 
			
		||||
/* 581 */,
 | 
			
		||||
/* 581 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
module.exports = require("timers/promises");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 582 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
@@ -46792,24 +46808,12 @@ function run() {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            try {
 | 
			
		||||
                yield cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                    uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
 | 
			
		||||
                });
 | 
			
		||||
            const cacheId = yield cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
 | 
			
		||||
            });
 | 
			
		||||
            if (cacheId != -1) {
 | 
			
		||||
                core.info(`Cache saved with key: ${primaryKey}`);
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                const typedError = error;
 | 
			
		||||
                if (typedError.name === cache.ValidationError.name) {
 | 
			
		||||
                    throw error;
 | 
			
		||||
                }
 | 
			
		||||
                else if (typedError.name === cache.ReserveCacheError.name) {
 | 
			
		||||
                    core.info(typedError.message);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    utils.logWarning(typedError.message);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            utils.logWarning(error.message);
 | 
			
		||||
@@ -46948,17 +46952,18 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
            checkKey(key);
 | 
			
		||||
        }
 | 
			
		||||
        const compressionMethod = yield utils.getCompressionMethod();
 | 
			
		||||
        // path are needed to compute version
 | 
			
		||||
        const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
            compressionMethod
 | 
			
		||||
        });
 | 
			
		||||
        if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
            // Cache not found
 | 
			
		||||
            return undefined;
 | 
			
		||||
        }
 | 
			
		||||
        const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
 | 
			
		||||
        core.debug(`Archive Path: ${archivePath}`);
 | 
			
		||||
        let archivePath = '';
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
                return undefined;
 | 
			
		||||
            }
 | 
			
		||||
            archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
 | 
			
		||||
            core.debug(`Archive Path: ${archivePath}`);
 | 
			
		||||
            // Download the cache from the cache entry
 | 
			
		||||
            yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
@@ -46968,6 +46973,17 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
            core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
 | 
			
		||||
            yield tar_1.extractTar(archivePath, compressionMethod);
 | 
			
		||||
            core.info('Cache restored successfully');
 | 
			
		||||
            return cacheEntry.cacheKey;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            const typedError = error;
 | 
			
		||||
            if (typedError.name === ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                // Supress all non-validation cache related errors because caching should be optional
 | 
			
		||||
                core.warning(`Failed to restore: ${error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        finally {
 | 
			
		||||
            // Try to delete the archive to save space
 | 
			
		||||
@@ -46978,7 +46994,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
                core.debug(`Failed to delete archive: ${error}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return cacheEntry.cacheKey;
 | 
			
		||||
        return undefined;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.restoreCache = restoreCache;
 | 
			
		||||
@@ -46996,7 +47012,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        checkKey(key);
 | 
			
		||||
        const compressionMethod = yield utils.getCompressionMethod();
 | 
			
		||||
        let cacheId = null;
 | 
			
		||||
        let cacheId = -1;
 | 
			
		||||
        const cachePaths = yield utils.resolvePaths(paths);
 | 
			
		||||
        core.debug('Cache Paths:');
 | 
			
		||||
        core.debug(`${JSON.stringify(cachePaths)}`);
 | 
			
		||||
@@ -47035,6 +47051,18 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug(`Saving Cache (ID: ${cacheId})`);
 | 
			
		||||
            yield cacheHttpClient.saveCache(cacheId, archivePath, options);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            const typedError = error;
 | 
			
		||||
            if (typedError.name === ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            }
 | 
			
		||||
            else if (typedError.name === ReserveCacheError.name) {
 | 
			
		||||
                core.info(`Failed to save: ${typedError.message}`);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                core.warning(`Failed to save: ${typedError.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        finally {
 | 
			
		||||
            // Try to delete the archive to save space
 | 
			
		||||
            try {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,15 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.0.4",
 | 
			
		||||
  "version": "3.0.5",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "cache",
 | 
			
		||||
      "version": "3.0.4",
 | 
			
		||||
      "version": "3.0.5",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/cache": "^2.0.6",
 | 
			
		||||
        "@actions/cache": "file:actions-cache-3.0.1.tgz",
 | 
			
		||||
        "@actions/core": "^1.7.0",
 | 
			
		||||
        "@actions/exec": "^1.1.1",
 | 
			
		||||
        "@actions/io": "^1.1.2"
 | 
			
		||||
@@ -36,9 +36,10 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@actions/cache": {
 | 
			
		||||
      "version": "2.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-Z39ZrWaTRRPaV/AOQdY7hve+Iy/HloH5prpz+k+0lZgGQs/3SeO0UYSIakVuXOk2pdMZnl0Nv0PoK1rmh9YfGQ==",
 | 
			
		||||
      "version": "3.0.1",
 | 
			
		||||
      "resolved": "file:actions-cache-3.0.1.tgz",
 | 
			
		||||
      "integrity": "sha512-ucvw0xvFpe0/vfNQ/rc11ste0nidCdBAJ5j5F01BxBqjxmGH2doVzfPlqSIGhcN7wKI074x2ATb9+7HSrTqGHg==",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/core": "^1.2.6",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
@@ -9533,9 +9534,8 @@
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": {
 | 
			
		||||
      "version": "2.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-Z39ZrWaTRRPaV/AOQdY7hve+Iy/HloH5prpz+k+0lZgGQs/3SeO0UYSIakVuXOk2pdMZnl0Nv0PoK1rmh9YfGQ==",
 | 
			
		||||
      "version": "file:actions-cache-3.0.1.tgz",
 | 
			
		||||
      "integrity": "sha512-ucvw0xvFpe0/vfNQ/rc11ste0nidCdBAJ5j5F01BxBqjxmGH2doVzfPlqSIGhcN7wKI074x2ATb9+7HSrTqGHg==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "@actions/core": "^1.2.6",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.0.4",
 | 
			
		||||
  "version": "3.0.5",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "description": "Cache dependencies and build outputs",
 | 
			
		||||
  "main": "dist/restore/index.js",
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
  "author": "GitHub",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": "^2.0.6",
 | 
			
		||||
    "@actions/cache": "file:actions-cache-3.0.1.tgz",
 | 
			
		||||
    "@actions/core": "^1.7.0",
 | 
			
		||||
    "@actions/exec": "^1.1.1",
 | 
			
		||||
    "@actions/io": "^1.1.2"
 | 
			
		||||
 
 | 
			
		||||
@@ -29,38 +29,29 @@ async function run(): Promise<void> {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            const cacheKey = await cache.restoreCache(
 | 
			
		||||
                cachePaths,
 | 
			
		||||
                primaryKey,
 | 
			
		||||
                restoreKeys
 | 
			
		||||
        const cacheKey = await cache.restoreCache(
 | 
			
		||||
            cachePaths,
 | 
			
		||||
            primaryKey,
 | 
			
		||||
            restoreKeys
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (!cacheKey) {
 | 
			
		||||
            core.info(
 | 
			
		||||
                `Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`
 | 
			
		||||
            );
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                core.info(
 | 
			
		||||
                    `Cache not found for input keys: ${[
 | 
			
		||||
                        primaryKey,
 | 
			
		||||
                        ...restoreKeys
 | 
			
		||||
                    ].join(", ")}`
 | 
			
		||||
                );
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        } catch (error: unknown) {
 | 
			
		||||
            const typedError = error as Error;
 | 
			
		||||
            if (typedError.name === cache.ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            } else {
 | 
			
		||||
                utils.logWarning(typedError.message);
 | 
			
		||||
                utils.setCacheHitOutput(false);
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Store the matched cache key
 | 
			
		||||
        utils.setCacheState(cacheKey);
 | 
			
		||||
 | 
			
		||||
        const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
        utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
        core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        core.setFailed((error as Error).message);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/save.ts
									
									
									
									
									
								
							@@ -44,20 +44,12 @@ async function run(): Promise<void> {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            await cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
			
		||||
            });
 | 
			
		||||
        const cacheId = await cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
            uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        if (cacheId != -1) {
 | 
			
		||||
            core.info(`Cache saved with key: ${primaryKey}`);
 | 
			
		||||
        } catch (error: unknown) {
 | 
			
		||||
            const typedError = error as Error;
 | 
			
		||||
            if (typedError.name === cache.ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
            } else if (typedError.name === cache.ReserveCacheError.name) {
 | 
			
		||||
                core.info(typedError.message);
 | 
			
		||||
            } else {
 | 
			
		||||
                utils.logWarning(typedError.message);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        utils.logWarning((error as Error).message);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user