1
0
Fork 0

Concurrency has a min of 1

pull/1928/head
Yang Cao 2025-01-08 18:14:04 +00:00
parent ede05b95d7
commit d4385a64a7
2 changed files with 9 additions and 1 deletions

View File

@ -85,6 +85,14 @@ describe('uploadConcurrencyEnv', () => {
}).toThrow()
})
it('should throw if ACTIONS_UPLOAD_CONCURRENCY is < 1', () => {
;(os.cpus as jest.Mock).mockReturnValue(new Array(4))
process.env.ACTIONS_UPLOAD_CONCURRENCY = '0'
expect(() => {
config.getConcurrency()
}).toThrow()
})
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'

View File

@ -61,7 +61,7 @@ export function getConcurrency(): number {
const concurrencyOverride = process.env['ACTIONS_UPLOAD_CONCURRENCY']
if (concurrencyOverride) {
const concurrency = parseInt(concurrencyOverride)
if (isNaN(concurrency)) {
if (isNaN(concurrency) || concurrency < 1) {
throw new Error(
'Invalid value set for ACTIONS_UPLOAD_CONCURRENCY env variable'
)