@@ -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 ( / \b n x \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