Skip to content

Commit 6c656c7

Browse files
fix(ci): harden format and bundle-size base builds
1 parent dc26e39 commit 6c656c7

File tree

3 files changed

+72
-8
lines changed

3 files changed

+72
-8
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: npx cypress install
5454

5555
- name: Check code format
56-
run: pnpm exec prettier --check .
56+
run: git ls-files -z | xargs -0 pnpm exec prettier --check --ignore-unknown
5757

5858
- name: Verify Rslib Template Publint Wiring
5959
run: node packages/create-module-federation/scripts/verify-rslib-templates.mjs

.github/workflows/bundle-size.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@ jobs:
7474
working-directory: ${{ env.BASE_PATH }}
7575

7676
- name: Build packages (base)
77-
run: pnpm run build:packages
77+
run: |
78+
if pnpm run build:packages; then
79+
echo "Built base packages with root build:packages script."
80+
elif [ -f turbo.json ]; then
81+
echo "Falling back to Turbo package build on base worktree."
82+
pnpm exec turbo run build --filter=./packages/** --concurrency=10
83+
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
86+
fi
7887
working-directory: ${{ env.BASE_PATH }}
7988

8089
- name: Measure bundle sizes (base)

tools/scripts/ci-local.mjs

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,7 @@ const jobs = [
562562
cwd: ctx.state.basePath,
563563
}),
564564
),
565-
step('Build packages (base)', (ctx) =>
566-
runCommand('pnpm', ['run', 'build:packages'], {
567-
...ctx,
568-
cwd: ctx.state.basePath,
569-
}),
570-
),
565+
step('Build packages (base)', (ctx) => runBasePackagesBuild(ctx)),
571566
step('Measure bundle sizes (base)', (ctx) =>
572567
runCommand(
573568
'node',
@@ -644,6 +639,66 @@ async function main() {
644639
}
645640
}
646641

642+
async function runBasePackagesBuild(ctx) {
643+
const baseCtx = { ...ctx, cwd: ctx.state.basePath };
644+
const rootPackageJsonPath = join(ctx.state.basePath, 'package.json');
645+
let basePackageJson = null;
646+
try {
647+
basePackageJson = JSON.parse(readFileSync(rootPackageJsonPath, 'utf-8'));
648+
} catch {
649+
basePackageJson = null;
650+
}
651+
652+
const buildPackagesScript = basePackageJson?.scripts?.['build:packages'];
653+
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+
669+
await runCommand('pnpm', ['run', 'build:packages'], baseCtx);
670+
return;
671+
}
672+
673+
if (existsSync(join(ctx.state.basePath, 'turbo.json'))) {
674+
await runCommand(
675+
'pnpm',
676+
[
677+
'exec',
678+
'turbo',
679+
'run',
680+
'build',
681+
'--filter=./packages/**',
682+
'--concurrency=10',
683+
],
684+
baseCtx,
685+
);
686+
return;
687+
}
688+
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' } },
699+
);
700+
}
701+
647702
function preflight() {
648703
const nodeMajor = Number(process.versions.node.split('.')[0]);
649704
const parityIssues = [];

0 commit comments

Comments
 (0)