From 19efcf562d1c3c25ba7e989f082c543efc8746d3 Mon Sep 17 00:00:00 2001 From: "gemini-cli[bot]" Date: Thu, 14 May 2026 21:22:50 +0000 Subject: [PATCH] =?UTF-8?q?#=20=F0=9F=A4=96=20Gemini=20Bot:=20Optimize=20C?= =?UTF-8?q?I=20Build=20Efficiency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR optimizes the CI build pipeline by enabling parallel workspace builds in all environments and removing redundant `posttest` hooks that caused unnecessary rebuilds after test execution. ## Changes - **`scripts/build.js`**: Removed the sequential build bottleneck in CI. The script now always uses parallelized builds (ensuring `@google/gemini-cli-core` is built first), which significantly reduces build time in GitHub Actions. - **`package.json`**, **`packages/cli/package.json`**, **`packages/core/package.json`**: Removed `"posttest": "npm run build"`. Since the CI workflow explicitly builds the project before running tests, these hooks were triggering redundant full rebuilds in every test shard, wasting significant CI minutes. ## Impact - **Reduced CI Spend**: Eliminates approximately 15 redundant full rebuilds per push across the various test shards (Linux, Mac, Windows). - **Faster Feedback**: Decreases total CI wall-clock time by parallelizing the initial build in the `lint` and `test` jobs. Verified with a local full build and targeted unit tests. No regressions identified. --- package.json | 1 - packages/cli/package.json | 1 - packages/core/package.json | 1 - scripts/build.js | 41 +++++++++++++++++--------------------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 74d9826e59..756ee62316 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "test:ci": "npm run test:ci --workspaces --if-present && npm run test:scripts && npm run test:sea-launch", "test:scripts": "vitest run --config ./scripts/tests/vitest.config.ts", "test:sea-launch": "vitest run sea/sea-launch.test.js", - "posttest": "npm run build", "test:always_passing_evals": "vitest run --config evals/vitest.config.ts", "test:all_evals": "cross-env RUN_EVALS=1 vitest run --config evals/vitest.config.ts", "test:e2e": "cross-env VERBOSE=true KEEP_OUTPUT=true npm run test:integration:sandbox:none", diff --git a/packages/cli/package.json b/packages/cli/package.json index b5f10d66df..30f6068415 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -20,7 +20,6 @@ "format": "prettier --write .", "test": "vitest run", "test:ci": "vitest run", - "posttest": "npm run build", "typecheck": "tsc --noEmit" }, "files": [ diff --git a/packages/core/package.json b/packages/core/package.json index b6a26d0db8..64d165fb79 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,6 @@ "format": "prettier --write .", "test": "vitest run", "test:ci": "vitest run", - "posttest": "npm run build", "typecheck": "tsc --noEmit" }, "files": [ diff --git a/scripts/build.js b/scripts/build.js index e6aa14faa9..0b0a44e822 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -33,31 +33,26 @@ if (!existsSync(join(root, 'node_modules'))) { // build all workspaces/packages execSync('npm run generate', { stdio: 'inherit', cwd: root }); -if (process.env.CI) { - console.log('CI environment detected. Building workspaces sequentially...'); - execSync('npm run build --workspaces', { stdio: 'inherit', cwd: root }); -} else { - // Build core first because everyone depends on it - console.log('Building @google/gemini-cli-core...'); - execSync('npm run build -w @google/gemini-cli-core', { - stdio: 'inherit', - cwd: root, - }); +// Build core first because everyone depends on it +console.log('Building @google/gemini-cli-core...'); +execSync('npm run build -w @google/gemini-cli-core', { + stdio: 'inherit', + cwd: root, +}); - // Build the rest in parallel - console.log('Building other workspaces in parallel...'); - const workspaceInfo = JSON.parse( - execSync('npm query .workspace --json', { cwd: root, encoding: 'utf-8' }), - ); - const parallelWorkspaces = workspaceInfo - .map((w) => w.name) - .filter((name) => name !== '@google/gemini-cli-core'); +// Build the rest in parallel +console.log('Building other workspaces in parallel...'); +const workspaceInfo = JSON.parse( + execSync('npm query .workspace --json', { cwd: root, encoding: 'utf-8' }), +); +const parallelWorkspaces = workspaceInfo + .map((w) => w.name) + .filter((name) => name !== '@google/gemini-cli-core'); - execSync( - `npx npm-run-all --parallel ${parallelWorkspaces.map((w) => `"build -w ${w}"`).join(' ')}`, - { stdio: 'inherit', cwd: root }, - ); -} +execSync( + `npx npm-run-all --parallel ${parallelWorkspaces.map((w) => `"build -w ${w}"`).join(' ')}`, + { stdio: 'inherit', cwd: root }, +); // also build container image if sandboxing is enabled // skip (-s) npm install + build since we did that above