Compare commits

..

5 Commits

Author SHA1 Message Date
Shubham Tiwari
3d236ac88e dist 2022-06-25 20:05:15 +00:00
Shubham Tiwari
b8ddf3df10 resolve package 2022-06-25 20:00:53 +00:00
Shubham Tiwari
0c5d98e6bb updated package version 2022-06-25 13:18:28 +00:00
Shubham Tiwari
7c59aeb02d formatting and error 2022-06-24 05:04:57 +00:00
Shubham Tiwari
c75dca6de7 Consuming 3.0 actions/cache 2022-06-24 04:06:33 +00:00
11 changed files with 44 additions and 103 deletions

View File

@@ -7,7 +7,6 @@ addAssignees: false
# A list of reviewers to be added to pull requests (GitHub user name) # A list of reviewers to be added to pull requests (GitHub user name)
reviewers: reviewers:
- phantsure - phantsure
- kotewar
- aparna-ravindra - aparna-ravindra
- tiwarishub - tiwarishub
- vsvipul - vsvipul

View File

@@ -11,5 +11,5 @@ jobs:
- name: 'Auto-assign issue' - name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1.4.0 uses: pozil/auto-assign-issue@v1.4.0
with: with:
assignees: phantsure,kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft assignees: phantsure,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
numOfAssignee: 1 numOfAssignee: 1

View File

@@ -72,8 +72,6 @@ jobs:
run: /primes.sh -d prime-numbers 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 ## Implementation Examples
Every programming language and framework has its own way of caching. Every programming language and framework has its own way of caching.

View File

@@ -15,6 +15,3 @@
### 3.0.4 ### 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)) - 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))

Binary file not shown.

34
dist/restore/index.js vendored
View File

@@ -1113,15 +1113,9 @@ function resolvePaths(patterns) {
.replace(new RegExp(`\\${path.sep}`, 'g'), '/'); .replace(new RegExp(`\\${path.sep}`, 'g'), '/');
core.debug(`Matched: ${relativeFile}`); core.debug(`Matched: ${relativeFile}`);
// Paths are made relative so the tar entries are all relative to the root of the workspace. // Paths are made relative so the tar entries are all relative to the root of the workspace.
if (relativeFile === '') {
// path.relative returns empty string if workspace and file are equal
paths.push('.');
}
else {
paths.push(`${relativeFile}`); paths.push(`${relativeFile}`);
} }
} }
}
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
@@ -5470,7 +5464,6 @@ const buffer = __importStar(__webpack_require__(293));
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const stream = __importStar(__webpack_require__(794)); const stream = __importStar(__webpack_require__(794));
const util = __importStar(__webpack_require__(669)); const util = __importStar(__webpack_require__(669));
const timer = __importStar(__webpack_require__(581));
const utils = __importStar(__webpack_require__(15)); const utils = __importStar(__webpack_require__(15));
const constants_1 = __webpack_require__(931); const constants_1 = __webpack_require__(931);
const requestUtils_1 = __webpack_require__(899); const requestUtils_1 = __webpack_require__(899);
@@ -5661,14 +5654,10 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
downloadProgress.nextSegment(segmentSize); downloadProgress.nextSegment(segmentSize);
const result = yield Promise.race([client.downloadToBuffer(segmentStart, segmentSize, { const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
concurrency: options.downloadConcurrency, concurrency: options.downloadConcurrency,
onProgress: downloadProgress.onProgress() onProgress: downloadProgress.onProgress()
}), });
timer.setTimeout(60 * 60 * 1000, 'timeout')]);
if (result === 'timeout') {
throw new Error("Segment download timed out");
}
fs.writeFileSync(fd, result); fs.writeFileSync(fd, result);
} }
} }
@@ -37283,9 +37272,9 @@ function extractTar(archivePath, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']; return ['--use-compress-program', 'zstd -d --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']; return ['--use-compress-program', 'zstd -d'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -37316,9 +37305,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'zstdmt --long=30']; return ['--use-compress-program', 'zstd -T0 --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'zstdmt']; return ['--use-compress-program', 'zstd -T0'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -37349,9 +37338,9 @@ function listTar(archivePath, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']; return ['--use-compress-program', 'zstd -d --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']; return ['--use-compress-program', 'zstd -d'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -42354,12 +42343,7 @@ function clean(key)
/* 578 */, /* 578 */,
/* 579 */, /* 579 */,
/* 580 */, /* 580 */,
/* 581 */ /* 581 */,
/***/ (function(module) {
module.exports = require("timers/promises");
/***/ }),
/* 582 */ /* 582 */
/***/ (function(module) { /***/ (function(module) {

39
dist/save/index.js vendored
View File

@@ -1113,15 +1113,9 @@ function resolvePaths(patterns) {
.replace(new RegExp(`\\${path.sep}`, 'g'), '/'); .replace(new RegExp(`\\${path.sep}`, 'g'), '/');
core.debug(`Matched: ${relativeFile}`); core.debug(`Matched: ${relativeFile}`);
// Paths are made relative so the tar entries are all relative to the root of the workspace. // Paths are made relative so the tar entries are all relative to the root of the workspace.
if (relativeFile === '') {
// path.relative returns empty string if workspace and file are equal
paths.push('.');
}
else {
paths.push(`${relativeFile}`); paths.push(`${relativeFile}`);
} }
} }
}
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
@@ -5470,7 +5464,6 @@ const buffer = __importStar(__webpack_require__(293));
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const stream = __importStar(__webpack_require__(794)); const stream = __importStar(__webpack_require__(794));
const util = __importStar(__webpack_require__(669)); const util = __importStar(__webpack_require__(669));
const timer = __importStar(__webpack_require__(581));
const utils = __importStar(__webpack_require__(15)); const utils = __importStar(__webpack_require__(15));
const constants_1 = __webpack_require__(931); const constants_1 = __webpack_require__(931);
const requestUtils_1 = __webpack_require__(899); const requestUtils_1 = __webpack_require__(899);
@@ -5661,14 +5654,10 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
downloadProgress.nextSegment(segmentSize); downloadProgress.nextSegment(segmentSize);
const result = yield Promise.race([client.downloadToBuffer(segmentStart, segmentSize, { const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
concurrency: options.downloadConcurrency, concurrency: options.downloadConcurrency,
onProgress: downloadProgress.onProgress() onProgress: downloadProgress.onProgress()
}), });
timer.setTimeout(60 * 60 * 1000, 'timeout')]);
if (result === 'timeout') {
throw new Error("Segment download timed out");
}
fs.writeFileSync(fd, result); fs.writeFileSync(fd, result);
} }
} }
@@ -37283,9 +37272,9 @@ function extractTar(archivePath, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']; return ['--use-compress-program', 'zstd -d --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']; return ['--use-compress-program', 'zstd -d'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -37316,9 +37305,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'zstdmt --long=30']; return ['--use-compress-program', 'zstd -T0 --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'zstdmt']; return ['--use-compress-program', 'zstd -T0'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -37349,9 +37338,9 @@ function listTar(archivePath, compressionMethod) {
function getCompressionProgram() { function getCompressionProgram() {
switch (compressionMethod) { switch (compressionMethod) {
case constants_1.CompressionMethod.Zstd: case constants_1.CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']; return ['--use-compress-program', 'zstd -d --long=30'];
case constants_1.CompressionMethod.ZstdWithoutLong: case constants_1.CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']; return ['--use-compress-program', 'zstd -d'];
default: default:
return ['-z']; return ['-z'];
} }
@@ -42354,12 +42343,7 @@ function clean(key)
/* 578 */, /* 578 */,
/* 579 */, /* 579 */,
/* 580 */, /* 580 */,
/* 581 */ /* 581 */,
/***/ (function(module) {
module.exports = require("timers/promises");
/***/ }),
/* 582 */ /* 582 */
/***/ (function(module) { /***/ (function(module) {
@@ -46811,9 +46795,10 @@ function run() {
const cacheId = yield cache.saveCache(cachePaths, primaryKey, { const cacheId = yield cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
}); });
if (cacheId != -1) { if (cacheId == -1) {
core.info(`Cache saved with key: ${primaryKey}`); return;
} }
core.info(`Cache saved with key: ${primaryKey}`);
} }
catch (error) { catch (error) {
utils.logWarning(error.message); utils.logWarning(error.message);

View File

@@ -223,8 +223,6 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
## Haskell - Stack ## Haskell - Stack
### Linux or macOS
```yaml ```yaml
- uses: actions/cache@v3 - uses: actions/cache@v3
name: Cache ~/.stack name: Cache ~/.stack
@@ -242,27 +240,6 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
${{ runner.os }}-stack-work- ${{ runner.os }}-stack-work-
``` ```
### Windows
```yaml
- uses: actions/cache@v3
name: Cache %APPDATA%\stack %LOCALAPPDATA%\Programs\stack
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-stack-work-
```
## Java - Gradle ## Java - Gradle
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons. >Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.

18
package-lock.json generated
View File

@@ -1,15 +1,15 @@
{ {
"name": "cache", "name": "cache",
"version": "3.0.5", "version": "3.0.4",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cache", "name": "cache",
"version": "3.0.5", "version": "3.0.4",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "file:actions-cache-3.0.1.tgz", "@actions/cache": "^3.0.0",
"@actions/core": "^1.7.0", "@actions/core": "^1.7.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2" "@actions/io": "^1.1.2"
@@ -36,10 +36,9 @@
} }
}, },
"node_modules/@actions/cache": { "node_modules/@actions/cache": {
"version": "3.0.1", "version": "3.0.0",
"resolved": "file:actions-cache-3.0.1.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
"integrity": "sha512-ucvw0xvFpe0/vfNQ/rc11ste0nidCdBAJ5j5F01BxBqjxmGH2doVzfPlqSIGhcN7wKI074x2ATb9+7HSrTqGHg==", "integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
"license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
@@ -9534,8 +9533,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/cache": { "@actions/cache": {
"version": "file:actions-cache-3.0.1.tgz", "version": "3.0.0",
"integrity": "sha512-ucvw0xvFpe0/vfNQ/rc11ste0nidCdBAJ5j5F01BxBqjxmGH2doVzfPlqSIGhcN7wKI074x2ATb9+7HSrTqGHg==", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
"requires": { "requires": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "cache", "name": "cache",
"version": "3.0.5", "version": "3.0.4",
"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",
@@ -23,7 +23,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "file:actions-cache-3.0.1.tgz", "@actions/cache": "^3.0.0",
"@actions/core": "^1.7.0", "@actions/core": "^1.7.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2" "@actions/io": "^1.1.2"

View File

@@ -47,10 +47,11 @@ async function run(): Promise<void> {
const cacheId = await cache.saveCache(cachePaths, primaryKey, { const cacheId = await cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
}); });
if (cacheId == -1) {
if (cacheId != -1) { return;
core.info(`Cache saved with key: ${primaryKey}`);
} }
core.info(`Cache saved with key: ${primaryKey}`);
} catch (error: unknown) { } catch (error: unknown) {
utils.logWarning((error as Error).message); utils.logWarning((error as Error).message);
} }