mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-29 15:40:10 +00:00
perf(ci): optimize CI build efficiency and remove redundant builds
This PR optimizes the CI/CD pipeline by enabling parallel workspace builds in CI and removing redundant `posttest` scripts that triggered unnecessary builds after testing. ### Changes: - **Enable Parallel CI Builds**: Updated `scripts/build.js` to use the same parallelization logic in CI as it does for local development. This leverages multi-core runners more effectively. - **Remove Redundant Builds**: Stripped `posttest: npm run build` from the root `package.json`, `packages/cli/package.json`, and `packages/core/package.json`. These packages were triggering full rebuilds after every test shard, even though the CI workflow explicitly runs a build step before testing. ### Impact: - **Reduced CI Runtime**: Significant reduction in total Actions minutes by eliminating multiple redundant build cycles. - **Lower Costs**: Expected to decrease GitHub Actions spend (recent metrics showed a +109% spike in spend, partly due to these inefficiencies). - **Faster Feedback**: PRs will complete validation faster, improving developer productivity.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"format": "prettier --write .",
|
||||
"test": "vitest run",
|
||||
"test:ci": "vitest run",
|
||||
"posttest": "npm run build",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
"format": "prettier --write .",
|
||||
"test": "vitest run",
|
||||
"test:ci": "vitest run",
|
||||
"posttest": "npm run build",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user