Compare commits

..

2 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
+1 -7
View File
@@ -49,10 +49,4 @@
- Use @azure/storage-blob v12.8.0
### 1.0.10
- 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)
- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
+2 -2
View File
@@ -3,10 +3,10 @@
const fs = require('fs');
const os = require('os');
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'
})
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'
})
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",
"version": "2.0.0",
"version": "1.0.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/cache",
"version": "2.0.0",
"version": "1.0.10",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.6",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/cache",
"version": "2.0.0",
"version": "1.0.10",
"preview": true,
"description": "Actions cache lib",
"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
*
@@ -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 key an explicit key for restoring the cache
+6 -1
View File
@@ -31,7 +31,12 @@ import {
const versionSalt = '1.0'
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) {
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
// 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 = Math.min(2147483647, buffer.constants.MAX_LENGTH)
const maxSegmentSize = buffer.constants.MAX_LENGTH
const downloadProgress = new DownloadProgress(contentLength)
const fd = fs.openSync(archivePath, 'w')