Files
toolkit/packages/artifact/src/internal/shared/config.ts
T

65 lines
1.9 KiB
TypeScript
Raw Normal View History

import os from 'os'
// Used for controlling the highWaterMark value of the zip that is being streamed
// The same value is used as the chunk size that is use during upload to blob storage
export function getUploadChunkSize(): number {
return 8 * 1024 * 1024 // 8 MB Chunks
}
2023-08-04 09:23:14 -07:00
export function getRuntimeToken(): string {
const token = process.env['ACTIONS_RUNTIME_TOKEN']
if (!token) {
throw new Error('Unable to get the ACTIONS_RUNTIME_TOKEN env variable')
2023-08-04 09:23:14 -07:00
}
return token
}
export function getResultsServiceUrl(): string {
const resultsUrl = process.env['ACTIONS_RESULTS_URL']
if (!resultsUrl) {
throw new Error('Unable to get the ACTIONS_RESULTS_URL env variable')
2023-08-04 09:23:14 -07:00
}
2023-11-20 18:06:44 +00:00
return new URL(resultsUrl).origin
2023-08-04 09:23:14 -07:00
}
2023-08-09 17:42:14 -07:00
export function isGhes(): boolean {
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
)
2024-01-30 21:55:50 +00:00
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
2024-01-31 16:51:04 +00:00
const isGitHubHost = hostname === 'GITHUB.COM'
const isGheHost = hostname.endsWith('.GHE.COM')
const isLocalHost = hostname.endsWith('.LOCALHOST')
2024-01-30 21:55:50 +00:00
return !isGitHubHost && !isGheHost && !isLocalHost
2023-08-09 17:42:14 -07:00
}
export function getGitHubWorkspaceDir(): string {
const ghWorkspaceDir = process.env['GITHUB_WORKSPACE']
if (!ghWorkspaceDir) {
throw new Error('Unable to get the GITHUB_WORKSPACE env variable')
}
return ghWorkspaceDir
}
// From testing, setting this value to 10 yielded best results in terms of reliability and there are no impact on performance either
2023-11-20 16:46:08 +00:00
export function getConcurrency(): number {
return 10
}
export function getUploadChunkTimeout(): number {
const timeoutVar = process.env['ACTIONS_UPLOAD_TIMEOUT_MS']
if (!timeoutVar) {
return 300000 // 5 minutes
}
const timeout = parseInt(timeoutVar)
if (isNaN(timeout)) {
throw new Error('Invalid value set for ACTIONS_UPLOAD_TIMEOUT_MS env variable')
}
2024-07-23 21:57:39 -04:00
return timeout
2024-07-23 21:57:39 -04:00
}