Skip to content

Commit 9742269

Browse files
committed
Expose env vars to controll concurrency and timeout
1 parent 6f51ac0 commit 9742269

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-21
lines changed

dist/merge/index.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29992999
Object.defineProperty(exports, "__esModule", ({ value: true }));
30003000
exports.getUploadChunkTimeout = exports.getConcurrency = exports.getGitHubWorkspaceDir = exports.isGhes = exports.getResultsServiceUrl = exports.getRuntimeToken = exports.getUploadChunkSize = void 0;
30013001
const os_1 = __importDefault(__nccwpck_require__(22037));
3002+
const core_1 = __nccwpck_require__(42186);
30023003
// Used for controlling the highWaterMark value of the zip that is being streamed
30033004
// The same value is used as the chunk size that is use during upload to blob storage
30043005
function getUploadChunkSize() {
@@ -3041,17 +3042,38 @@ exports.getGitHubWorkspaceDir = getGitHubWorkspaceDir;
30413042
// Mimics behavior of azcopy: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize
30423043
// If your machine has fewer than 5 CPUs, then the value of this variable is set to 32.
30433044
// Otherwise, the default value is equal to 16 multiplied by the number of CPUs. The maximum value of this variable is 300.
3045+
// This value can be lowered with ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY variable.
30443046
function getConcurrency() {
30453047
const numCPUs = os_1.default.cpus().length;
3046-
if (numCPUs <= 4) {
3047-
return 32;
3048+
let concurrencyCap = 32;
3049+
if (numCPUs > 4) {
3050+
const concurrency = 16 * numCPUs;
3051+
concurrencyCap = concurrency > 300 ? 300 : concurrency;
3052+
}
3053+
const concurrencyOverride = process.env['ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY'];
3054+
if (concurrencyOverride) {
3055+
const concurrency = parseInt(concurrencyOverride);
3056+
if (isNaN(concurrency) || concurrency < 1) {
3057+
throw new Error('Invalid value set for ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY env variable');
3058+
}
3059+
if (concurrency < concurrencyCap) {
3060+
return concurrency;
3061+
}
3062+
(0, core_1.info)(`ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY is higher than the cap of ${concurrencyCap} based on the number of cpus. Lowering it to the cap.`);
30483063
}
3049-
const concurrency = 16 * numCPUs;
3050-
return concurrency > 300 ? 300 : concurrency;
3064+
return concurrencyCap;
30513065
}
30523066
exports.getConcurrency = getConcurrency;
30533067
function getUploadChunkTimeout() {
3054-
return 300000; // 5 minutes
3068+
const timeoutVar = process.env['ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS'];
3069+
if (!timeoutVar) {
3070+
return 300000; // 5 minutes
3071+
}
3072+
const timeout = parseInt(timeoutVar);
3073+
if (isNaN(timeout)) {
3074+
throw new Error('Invalid value set for ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS env variable');
3075+
}
3076+
return timeout;
30553077
}
30563078
exports.getUploadChunkTimeout = getUploadChunkTimeout;
30573079
//# sourceMappingURL=config.js.map
@@ -137606,7 +137628,7 @@ module.exports = index;
137606137628
/***/ ((module) => {
137607137629

137608137630
"use strict";
137609-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.0","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137631+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.1","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137610137632

137611137633
/***/ }),
137612137634

dist/upload/index.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29992999
Object.defineProperty(exports, "__esModule", ({ value: true }));
30003000
exports.getUploadChunkTimeout = exports.getConcurrency = exports.getGitHubWorkspaceDir = exports.isGhes = exports.getResultsServiceUrl = exports.getRuntimeToken = exports.getUploadChunkSize = void 0;
30013001
const os_1 = __importDefault(__nccwpck_require__(22037));
3002+
const core_1 = __nccwpck_require__(42186);
30023003
// Used for controlling the highWaterMark value of the zip that is being streamed
30033004
// The same value is used as the chunk size that is use during upload to blob storage
30043005
function getUploadChunkSize() {
@@ -3041,17 +3042,38 @@ exports.getGitHubWorkspaceDir = getGitHubWorkspaceDir;
30413042
// Mimics behavior of azcopy: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize
30423043
// If your machine has fewer than 5 CPUs, then the value of this variable is set to 32.
30433044
// Otherwise, the default value is equal to 16 multiplied by the number of CPUs. The maximum value of this variable is 300.
3045+
// This value can be lowered with ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY variable.
30443046
function getConcurrency() {
30453047
const numCPUs = os_1.default.cpus().length;
3046-
if (numCPUs <= 4) {
3047-
return 32;
3048+
let concurrencyCap = 32;
3049+
if (numCPUs > 4) {
3050+
const concurrency = 16 * numCPUs;
3051+
concurrencyCap = concurrency > 300 ? 300 : concurrency;
3052+
}
3053+
const concurrencyOverride = process.env['ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY'];
3054+
if (concurrencyOverride) {
3055+
const concurrency = parseInt(concurrencyOverride);
3056+
if (isNaN(concurrency) || concurrency < 1) {
3057+
throw new Error('Invalid value set for ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY env variable');
3058+
}
3059+
if (concurrency < concurrencyCap) {
3060+
return concurrency;
3061+
}
3062+
(0, core_1.info)(`ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY is higher than the cap of ${concurrencyCap} based on the number of cpus. Lowering it to the cap.`);
30483063
}
3049-
const concurrency = 16 * numCPUs;
3050-
return concurrency > 300 ? 300 : concurrency;
3064+
return concurrencyCap;
30513065
}
30523066
exports.getConcurrency = getConcurrency;
30533067
function getUploadChunkTimeout() {
3054-
return 300000; // 5 minutes
3068+
const timeoutVar = process.env['ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS'];
3069+
if (!timeoutVar) {
3070+
return 300000; // 5 minutes
3071+
}
3072+
const timeout = parseInt(timeoutVar);
3073+
if (isNaN(timeout)) {
3074+
throw new Error('Invalid value set for ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS env variable');
3075+
}
3076+
return timeout;
30553077
}
30563078
exports.getUploadChunkTimeout = getUploadChunkTimeout;
30573079
//# sourceMappingURL=config.js.map
@@ -137616,7 +137638,7 @@ module.exports = index;
137616137638
/***/ ((module) => {
137617137639

137618137640
"use strict";
137619-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.0","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137641+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.1","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137620137642

137621137643
/***/ }),
137622137644

package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/actions/upload-artifact#readme",
3131
"dependencies": {
32-
"@actions/artifact": "^2.2.0",
32+
"@actions/artifact": "^2.2.1",
3333
"@actions/core": "^1.11.1",
3434
"@actions/github": "^6.0.0",
3535
"@actions/glob": "^0.5.0",

0 commit comments

Comments
 (0)