Compare commits

..
Author SHA1 Message Date
Shubham Tiwari fa58df4d07 Update cache.ts 2022-03-25 00:40:10 +05:30
Shubham Tiwari 7fb008ded6 Update cache.ts 2022-03-23 03:19:00 +05:30
9 changed files with 20049 additions and 127 deletions
+20035 -87
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -50,9 +50,3 @@
### 1.0.10 ### 1.0.10
- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022) - Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
### 1.0.11
- Fix file downloads > 2GB([issue](https://github.com/actions/cache/issues/773))
### 2.0.0
- Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028)
+2 -2
View File
@@ -3,10 +3,10 @@
const fs = require('fs'); const fs = require('fs');
const os = require('os'); const os = require('os');
const filePath = process.env[`GITHUB_ENV`] const filePath = process.env[`GITHUB_ENV`]
fs.appendFileSync(filePath, `ACTIONS_RUNTIME_TOKEN=${process.env.ACTIONS_RUNTIME_TOKEN}${os.EOL}`, { fs.appendFileSync(filePath, `ACTIONS_RUNTIME_URL=${process.env.ACTIONS_RUNTIME_URL}${os.EOL}`, {
encoding: 'utf8' encoding: 'utf8'
}) })
fs.appendFileSync(filePath, `ACTIONS_CACHE_URL=${process.env.ACTIONS_CACHE_URL}${os.EOL}`, { fs.appendFileSync(filePath, `ACTIONS_RUNTIME_TOKEN=${process.env.ACTIONS_RUNTIME_TOKEN}${os.EOL}`, {
encoding: 'utf8' encoding: 'utf8'
}) })
fs.appendFileSync(filePath, `GITHUB_RUN_ID=${process.env.GITHUB_RUN_ID}${os.EOL}`, { fs.appendFileSync(filePath, `GITHUB_RUN_ID=${process.env.GITHUB_RUN_ID}${os.EOL}`, {
-14
View File
@@ -1,14 +0,0 @@
import * as cache from '../src/cache'
test('isFeatureAvailable returns true if server url is set', () => {
try {
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com'
expect(cache.isFeatureAvailable()).toBe(true)
} finally {
delete process.env['ACTIONS_CACHE_URL']
}
})
test('isFeatureAvailable returns false if server url is not set', () => {
expect(cache.isFeatureAvailable()).toBe(false)
})
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "2.0.0", "version": "1.0.10",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/cache", "name": "@actions/cache",
"version": "2.0.0", "version": "1.0.10",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "2.0.0", "version": "1.0.10",
"preview": true, "preview": true,
"description": "Actions cache lib", "description": "Actions cache lib",
"keywords": [ "keywords": [
+1 -11
View File
@@ -43,16 +43,6 @@ function checkKey(key: string): void {
} }
} }
/**
* isFeatureAvailable to check the presence of Actions cache service
*
* @returns boolean return true if Actions cache service feature is available, otherwise false
*/
export function isFeatureAvailable(): boolean {
return !!process.env['ACTIONS_CACHE_URL']
}
/** /**
* Restores cache from keys * Restores cache from keys
* *
@@ -136,7 +126,7 @@ export async function restoreCache(
} }
/** /**
* Saves a list of files with the specified key * Saves a list of files test with the specified key.
* *
* @param paths a list of file paths to be cached * @param paths a list of file paths to be cached
* @param key an explicit key for restoring the cache * @param key an explicit key for restoring the cache
+6 -1
View File
@@ -31,7 +31,12 @@ import {
const versionSalt = '1.0' const versionSalt = '1.0'
function getCacheApiUrl(resource: string): string { function getCacheApiUrl(resource: string): string {
const baseUrl: string = process.env['ACTIONS_CACHE_URL'] || '' // Ideally we just use ACTIONS_CACHE_URL
const baseUrl: string = (
process.env['ACTIONS_CACHE_URL'] ||
process.env['ACTIONS_RUNTIME_URL'] ||
''
).replace('pipelines', 'artifactcache')
if (!baseUrl) { if (!baseUrl) {
throw new Error('Cache Service Url not found, unable to restore cache.') throw new Error('Cache Service Url not found, unable to restore cache.')
} }
+1 -2
View File
@@ -240,8 +240,7 @@ export async function downloadCacheStorageSDK(
// //
// If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB
// on 64-bit systems), split the download into multiple segments // on 64-bit systems), split the download into multiple segments
// ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. const maxSegmentSize = buffer.constants.MAX_LENGTH
const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH)
const downloadProgress = new DownloadProgress(contentLength) const downloadProgress = new DownloadProgress(contentLength)
const fd = fs.openSync(archivePath, 'w') const fd = fs.openSync(archivePath, 'w')