initial changes

This commit is contained in:
Shubham Tiwari 2022-03-29 12:54:34 +05:30
parent 6c048c7558
commit c1f6351648
5 changed files with 1805 additions and 1780 deletions

View file

@ -3728,10 +3728,7 @@ const options_1 = __webpack_require__(538);
const requestUtils_1 = __webpack_require__(899); const requestUtils_1 = __webpack_require__(899);
const versionSalt = '1.0'; const versionSalt = '1.0';
function getCacheApiUrl(resource) { function getCacheApiUrl(resource) {
// Ideally we just use ACTIONS_CACHE_URL const baseUrl = process.env['ACTIONS_CACHE_URL'] || '';
const baseUrl = (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.');
} }
@ -5920,7 +5917,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
// //
// 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
const maxSegmentSize = buffer.constants.MAX_LENGTH; // ~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 downloadProgress = new DownloadProgress(contentLength); const downloadProgress = new DownloadProgress(contentLength);
const fd = fs.openSync(archivePath, 'w'); const fd = fs.openSync(archivePath, 'w');
try { try {
@ -41451,6 +41449,15 @@ function checkKey(key) {
throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`); throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`);
} }
} }
/**
* isFeatureAvailable to check the presence of Actions cache service
*
* @returns boolean return true if Actions cache service feature is available, otherwise false
*/
function isFeatureAvailable() {
return !!process.env['ACTIONS_CACHE_URL'];
}
exports.isFeatureAvailable = isFeatureAvailable;
/** /**
* Restores cache from keys * Restores cache from keys
* *

3513
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

22
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "2.2.2", "version": "2.2.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.8", "@actions/cache": "^2.0.0",
"@actions/core": "^1.2.3", "@actions/core": "^1.2.3",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/glob": "^0.2.0", "@actions/glob": "^0.2.0",
@ -31,17 +31,17 @@
} }
}, },
"node_modules/@actions/cache": { "node_modules/@actions/cache": {
"version": "1.0.8", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz",
"integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.9", "@actions/http-client": "^1.0.9",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/ms-rest-js": "^2.0.7", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.1.2", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
"uuid": "^3.3.3" "uuid": "^3.3.3"
} }
@ -11338,17 +11338,17 @@
}, },
"dependencies": { "dependencies": {
"@actions/cache": { "@actions/cache": {
"version": "1.0.8", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz",
"integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==",
"requires": { "requires": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.9", "@actions/http-client": "^1.0.9",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/ms-rest-js": "^2.0.7", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.1.2", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
"uuid": "^3.3.3" "uuid": "^3.3.3"
}, },

View file

@ -23,7 +23,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.8", "@actions/cache": "^2.0.0",
"@actions/core": "^1.2.3", "@actions/core": "^1.2.3",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/glob": "^0.2.0", "@actions/glob": "^0.2.0",

View file

@ -1,3 +1,4 @@
import * as actionsCache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as finder from './find-python'; import * as finder from './find-python';
import * as finderPyPy from './find-pypy'; import * as finderPyPy from './find-pypy';
@ -11,8 +12,12 @@ function isPyPyVersion(versionSpec: string) {
} }
async function cacheDependencies(cache: string, pythonVersion: string) { async function cacheDependencies(cache: string, pythonVersion: string) {
if (!actionsCache.isFeatureAvailable()) {
if (isGhes()) { if (isGhes()) {
throw new Error('Caching is not supported on GHES'); throw new Error('Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
} else {
throw new Error('An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.');
}
} }
const cacheDependencyPath = const cacheDependencyPath =
core.getInput('cache-dependency-path') || undefined; core.getInput('cache-dependency-path') || undefined;