Skip to content

fix(ci): optimize workflows, fix build ordering, and add caching#24611

Closed
hiSandog wants to merge 1 commit intogoogle-gemini:mainfrom
hiSandog:fix/ci-performance-and-cache
Closed

fix(ci): optimize workflows, fix build ordering, and add caching#24611
hiSandog wants to merge 1 commit intogoogle-gemini:mainfrom
hiSandog:fix/ci-performance-and-cache

Conversation

@hiSandog
Copy link
Copy Markdown

@hiSandog hiSandog commented Apr 3, 2026

Summary

This PR addresses several issues in the CI workflows that cause unnecessary build times and includes a correctness fix for a critical build ordering bug.

Changes

1. Critical: Fix npm ci / npm run build ordering in ci.yml

On Linux and Mac CI jobs, npm run build was running before npm ci. This means builds were using potentially stale cached artifacts from previous workflow runs instead of freshly installed dependencies. Fixed by moving npm ci to run before npm run build.

2. Add TypeScript build caching to all major workflows

Added actions/cache@v4 for TypeScript build outputs (packages/*/dist, packages/*/*.tsbuildinfo) to:

  • ci.yml (Linux + Mac)
  • chained_e2e.yml (Linux + Mac + Evals)
  • deflake.yml (Linux + Mac)

This avoids redundant tsc --build recompilation across workflow runs that use the same commit SHA.

3. Add npm dependency caching to E2E workflows

Added cache: 'npm' to setup-node in chained_e2e.yml and deflake.yml, which were missing npm cache configuration entirely.

4. Remove npm cache clean --force on macOS E2E jobs

Both chained_e2e.yml and deflake.yml had a step that forcibly destroyed the npm cache on macOS runners. Removing this allows subsequent workflow runs to benefit from npm dependency caching.

5. Increase vitest thread limits for large packages

Increased maxThreads from 4 to 8 for:

  • packages/core/vitest.config.ts (909 test files)
  • packages/cli/vitest.config.ts (233 test files)

The 4-thread limit was unnecessarily constraining test parallelism on 16-core CI runners.

6. Add LRU eviction to CacheService

Added maxCapacity option to CacheOptions interface in packages/core/src/utils/cache.ts. When the cache exceeds the configured capacity, the least recently used entry is evicted. This prevents unbounded memory growth in long-running or high-throughput scenarios.

- Fix critical npm ci/build ordering bug in ci.yml (Linux + Mac)
- Add TypeScript build cache to ci.yml, chained_e2e.yml, deflake.yml
- Add npm cache to E2E workflows (was missing entirely)
- Remove wasteful npm cache clean --force on macOS E2E jobs
- Increase vitest maxThreads 4->8 for core and cli packages
- Add LRU eviction (maxCapacity) to CacheService

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@hiSandog hiSandog requested review from a team as code owners April 3, 2026 15:51
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on optimizing the continuous integration pipeline and enhancing the internal caching utility. By correcting build sequences, introducing comprehensive caching strategies, and tuning test parallelism, the changes aim to significantly reduce build times and resource consumption. Additionally, the introduction of an LRU eviction policy for the CacheService ensures better memory management in high-throughput environments.

Highlights

  • CI Workflow Optimization: Corrected build ordering in CI jobs, added TypeScript and npm dependency caching, and removed unnecessary cache clearing steps to improve build performance.
  • Test Parallelism: Increased Vitest thread limits from 4 to 8 for core and CLI packages to better utilize available CI runner resources.
  • CacheService Improvements: Implemented an LRU (Least Recently Used) eviction strategy in CacheService to prevent unbounded memory growth.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/chained_e2e.yml
    • .github/workflows/ci.yml
    • .github/workflows/deflake.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a Least Recently Used (LRU) eviction strategy for the CacheService in packages/core by introducing a maxCapacity option and tracking access order for Map-based storage. Additionally, the Vitest configuration for packages/cli and packages/core has been updated to increase maxThreads from 4 to 8. I have no feedback to provide.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Apr 3, 2026
@hiSandog hiSandog closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant