1
0
Fork 0

Rename the prefix to be more specific

pull/1928/head
Yang Cao 2025-01-08 20:32:45 +00:00
parent d4385a64a7
commit e55409315f
2 changed files with 17 additions and 17 deletions

View File

@ -42,13 +42,13 @@ describe('uploadChunkTimeoutEnv', () => {
expect(config.getUploadChunkTimeout()).toBe(300000)
})
it('should return value set in ACTIONS_UPLOAD_TIMEOUT_MS', () => {
process.env.ACTIONS_UPLOAD_TIMEOUT_MS = '150000'
it('should return value set in ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS', () => {
process.env.ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS = '150000'
expect(config.getUploadChunkTimeout()).toBe(150000)
})
it('should throw if value set in ACTIONS_UPLOAD_TIMEOUT_MS is invalid', () => {
process.env.ACTIONS_UPLOAD_TIMEOUT_MS = 'abc'
it('should throw if value set in ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS is invalid', () => {
process.env.ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS = 'abc'
expect(() => {
config.getUploadChunkTimeout()
}).toThrow()
@ -71,23 +71,23 @@ describe('uploadConcurrencyEnv', () => {
expect(config.getConcurrency()).toBe(300)
})
it('should return override value when ACTIONS_UPLOAD_CONCURRENCY is set', () => {
it('should return override value when ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY is set', () => {
;(os.cpus as jest.Mock).mockReturnValue(new Array(4))
process.env.ACTIONS_UPLOAD_CONCURRENCY = '10'
process.env.ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY = '10'
expect(config.getConcurrency()).toBe(10)
})
it('should throw with invalid value of ACTIONS_UPLOAD_CONCURRENCY', () => {
it('should throw with invalid value of ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY', () => {
;(os.cpus as jest.Mock).mockReturnValue(new Array(4))
process.env.ACTIONS_UPLOAD_CONCURRENCY = 'abc'
process.env.ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY = 'abc'
expect(() => {
config.getConcurrency()
}).toThrow()
})
it('should throw if ACTIONS_UPLOAD_CONCURRENCY is < 1', () => {
it('should throw if ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY is < 1', () => {
;(os.cpus as jest.Mock).mockReturnValue(new Array(4))
process.env.ACTIONS_UPLOAD_CONCURRENCY = '0'
process.env.ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY = '0'
expect(() => {
config.getConcurrency()
}).toThrow()
@ -95,7 +95,7 @@ describe('uploadConcurrencyEnv', () => {
it('cannot go over currency cap when override value is greater', () => {
;(os.cpus as jest.Mock).mockReturnValue(new Array(4))
process.env.ACTIONS_UPLOAD_CONCURRENCY = '40'
process.env.ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY = '40'
expect(config.getConcurrency()).toBe(32)
})
})

View File

@ -48,7 +48,7 @@ export function getGitHubWorkspaceDir(): string {
// Mimics behavior of azcopy: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize
// If your machine has fewer than 5 CPUs, then the value of this variable is set to 32.
// Otherwise, the default value is equal to 16 multiplied by the number of CPUs. The maximum value of this variable is 300.
// This value can be lowered with ACTIONS_UPLOAD_CONCURRENCY variable.
// This value can be lowered with ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY variable.
export function getConcurrency(): number {
const numCPUs = os.cpus().length
let concurrencyCap = 32
@ -58,12 +58,12 @@ export function getConcurrency(): number {
concurrencyCap = concurrency > 300 ? 300 : concurrency
}
const concurrencyOverride = process.env['ACTIONS_UPLOAD_CONCURRENCY']
const concurrencyOverride = process.env['ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY']
if (concurrencyOverride) {
const concurrency = parseInt(concurrencyOverride)
if (isNaN(concurrency) || concurrency < 1) {
throw new Error(
'Invalid value set for ACTIONS_UPLOAD_CONCURRENCY env variable'
'Invalid value set for ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY env variable'
)
}
@ -72,7 +72,7 @@ export function getConcurrency(): number {
}
info(
`ACTIONS_UPLOAD_CONCURRENCY is higher than the cap of ${concurrencyCap} based on the number of cpus. Lowering it to the cap.`
`ACTIONS_ARTIFACT_UPLOAD_CONCURRENCY is higher than the cap of ${concurrencyCap} based on the number of cpus. Lowering it to the cap.`
)
}
@ -80,7 +80,7 @@ export function getConcurrency(): number {
}
export function getUploadChunkTimeout(): number {
const timeoutVar = process.env['ACTIONS_UPLOAD_TIMEOUT_MS']
const timeoutVar = process.env['ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS']
if (!timeoutVar) {
return 300000 // 5 minutes
}
@ -88,7 +88,7 @@ export function getUploadChunkTimeout(): number {
const timeout = parseInt(timeoutVar)
if (isNaN(timeout)) {
throw new Error(
'Invalid value set for ACTIONS_UPLOAD_TIMEOUT_MS env variable'
'Invalid value set for ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS env variable'
)
}