fix: bound release builds to one worker by default

This commit is contained in:
2026-08-11 12:10:15 +00:00
parent 3e938e17d6
commit 49970a0599
5 changed files with 30 additions and 6 deletions
@@ -26,7 +26,17 @@ export interface BuildRunner {
}
export const MAX_BUILD_OUTPUT_CHARS = 64 * 1024;
export const RELEASE_TURBO_CONCURRENCY = 2;
export const DEFAULT_RELEASE_TURBO_CONCURRENCY = 1;
export const resolveReleaseTurboConcurrency = (env?: Record<string, string>): number => {
const configured = env?.RELEASE_TURBO_CONCURRENCY?.trim();
if (!configured) return DEFAULT_RELEASE_TURBO_CONCURRENCY;
const parsed = Number(configured);
if (!Number.isInteger(parsed) || parsed <= 0) {
throw new Error('RELEASE_TURBO_CONCURRENCY must be a positive integer.');
}
return parsed;
};
export const resolveReleaseTurboCacheDir = (cacheAnchorRoot: string, env?: Record<string, string>): string => {
const configured = env?.TURBO_CACHE_DIR?.trim();
@@ -48,7 +58,7 @@ export const buildTurboReleaseCommand = (
'build',
...packageNames.map((packageName) => `--filter=${packageName}`),
`--cache-dir=${resolveReleaseTurboCacheDir(cacheAnchorRoot, env)}`,
`--concurrency=${RELEASE_TURBO_CONCURRENCY}`,
`--concurrency=${resolveReleaseTurboConcurrency(env)}`,
'--ui=stream',
'--output-logs=new-only',
],
+10 -1
View File
@@ -7,6 +7,7 @@ import {
MAX_BUILD_OUTPUT_CHARS,
PnpmBuildRunner,
resolveReleaseTurboCacheDir,
resolveReleaseTurboConcurrency,
} from '../src/orchestrator/buildRunner.js';
describe('Turbo release build plan', () => {
@@ -24,6 +25,14 @@ describe('Turbo release build plan', () => {
).toBe('/srv/core/repository/.cache/turbo');
});
it('defaults to one worker for bounded runtimes and accepts a larger-host override', () => {
expect(resolveReleaseTurboConcurrency()).toBe(1);
expect(resolveReleaseTurboConcurrency({ RELEASE_TURBO_CONCURRENCY: '2' })).toBe(2);
expect(() => resolveReleaseTurboConcurrency({ RELEASE_TURBO_CONCURRENCY: '0' })).toThrow(
'RELEASE_TURBO_CONCURRENCY must be a positive integer.'
);
});
it('uses a bounded streaming Turbo build for the selected packages', () => {
expect(
buildTurboReleaseCommand(
@@ -41,7 +50,7 @@ describe('Turbo release build plan', () => {
'build',
'--filter=@sammo-ts/game-api',
'--cache-dir=/srv/core/repository/.turbo/release-cache',
'--concurrency=2',
'--concurrency=1',
'--ui=stream',
'--output-logs=new-only',
],
@@ -237,7 +237,7 @@ describe('buildWorkspaceCommands', () => {
'--filter=@sammo-ts/game-api',
'--filter=@sammo-ts/gateway-api',
'--cache-dir=/srv/sammo/controller/.turbo/release-cache',
'--concurrency=2',
'--concurrency=1',
'--ui=stream',
'--output-logs=new-only',
],