Skip to content

Commit a60734c

Browse files
fix(ci): keep bundle-size base build turbo-only
1 parent 6c656c7 commit a60734c

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

.github/workflows/bundle-size.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ jobs:
5555
run: |
5656
BASE_REF=${CI_LOCAL_BASE_REF:-origin/main}
5757
BASE_PATH=".ci-local-base-${RANDOM}-${RANDOM}"
58+
LOCAL_BASE_REF="${BASE_REF#origin/}"
5859
echo "BASE_REF=$BASE_REF" >> "$GITHUB_ENV"
5960
echo "BASE_PATH=$BASE_PATH" >> "$GITHUB_ENV"
61+
echo "LOCAL_BASE_REF=$LOCAL_BASE_REF" >> "$GITHUB_ENV"
6062
git worktree add "$BASE_PATH" "$BASE_REF"
63+
git -C "$BASE_PATH" branch -f "$LOCAL_BASE_REF" "$BASE_REF" || true
6164
6265
- name: Restore Turborepo cache (base worktree)
6366
uses: actions/cache@v5
@@ -81,8 +84,8 @@ jobs:
8184
echo "Falling back to Turbo package build on base worktree."
8285
pnpm exec turbo run build --filter=./packages/** --concurrency=10
8386
else
84-
echo "Falling back to Nx package build on base worktree."
85-
NX_TUI=false npx nx run-many --target=build --parallel=10 --projects=tag:type:pkg
87+
echo "Unable to build base packages: missing build:packages script and turbo.json" >&2
88+
exit 1
8689
fi
8790
working-directory: ${{ env.BASE_PATH }}
8891

tools/scripts/ci-local.mjs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,23 @@ const jobs = [
547547
),
548548
step('Prepare base worktree', async (ctx) => {
549549
const baseRef = process.env.CI_LOCAL_BASE_REF ?? 'origin/main';
550+
const localBaseRef = baseRef.startsWith('origin/')
551+
? baseRef.slice('origin/'.length)
552+
: baseRef;
550553
const basePath = join(ROOT, `.ci-local-base-${Date.now()}`);
551554
if (existsSync(basePath)) {
552555
throw new Error(`Base worktree path already exists: ${basePath}`);
553556
}
554557
ctx.state.baseRef = baseRef;
558+
ctx.state.localBaseRef = localBaseRef;
555559
ctx.state.basePath = basePath;
556560
console.log(`[ci:local] Using base ref ${baseRef}`);
557561
await runCommand('git', ['worktree', 'add', basePath, baseRef], ctx);
562+
await runCommand(
563+
'git',
564+
['-C', basePath, 'branch', '-f', localBaseRef, baseRef],
565+
ctx,
566+
);
558567
}),
559568
step('Install dependencies (base)', (ctx) =>
560569
runCommand('pnpm', ['install', '--frozen-lockfile'], {
@@ -651,21 +660,6 @@ async function runBasePackagesBuild(ctx) {
651660

652661
const buildPackagesScript = basePackageJson?.scripts?.['build:packages'];
653662
if (typeof buildPackagesScript === 'string' && buildPackagesScript.trim()) {
654-
if (/\bnx\b/.test(buildPackagesScript)) {
655-
await runCommand(
656-
'npx',
657-
[
658-
'nx',
659-
'run-many',
660-
'--target=build',
661-
'--parallel=10',
662-
'--projects=tag:type:pkg',
663-
],
664-
{ ...baseCtx, env: { ...baseCtx.env, NX_TUI: 'false' } },
665-
);
666-
return;
667-
}
668-
669663
await runCommand('pnpm', ['run', 'build:packages'], baseCtx);
670664
return;
671665
}
@@ -686,16 +680,8 @@ async function runBasePackagesBuild(ctx) {
686680
return;
687681
}
688682

689-
await runCommand(
690-
'npx',
691-
[
692-
'nx',
693-
'run-many',
694-
'--target=build',
695-
'--parallel=10',
696-
'--projects=tag:type:pkg',
697-
],
698-
{ ...baseCtx, env: { ...baseCtx.env, NX_TUI: 'false' } },
683+
throw new Error(
684+
'[ci:local] Base worktree has no build:packages script and no turbo.json; cannot build base packages.',
699685
);
700686
}
701687

0 commit comments

Comments
 (0)