Files
gemini-cli/tools/gemini-cli-bot/metrics
gemini-cli[bot] 1a8c7ec226 # Actions Cost Reduction: CI Matrix and Pulse Optimization
This PR implements several measures to reduce the cost of GitHub Actions usage, focusing on the highest-impact areas identified through real per-workflow minutes consumption analysis.

### Summary of Changes

1.  **CI Matrix Optimization**: Reduced the `test_mac` matrix in `Testing: CI` to only run on Node.js 20.x.
    - **Reason**: macOS runners (especially `macos-latest-large`) are significantly more expensive than Linux runners. Node.js 22.x and 24.x are still covered by the `test_linux` matrix, ensuring core compatibility. OS-specific issues are likely to be caught on the recommended Node.js version (20.x).
    - **Impact**: Expected to reduce Mac runner usage by approximately 66% in the CI pipeline.

2.  **Pulse Workflow Optimization**:
    - Added a check to skip `npm ci` and subsequent steps if no reflex scripts are present in `tools/gemini-cli-bot/reflexes/scripts`.
    - Reduced `fetch-depth` from 0 (full clone) to 1 (shallow clone).
    - **Reason**: The Pulse workflow runs every 30 minutes. Installing dependencies when there is nothing to run is a waste of resources.
    - **Impact**: Eliminates unnecessary dependency installation and reduces clone time for the Pulse workflow.

3.  **Brain Workflow Optimization**:
    - Reduced `fetch-depth` from 0 to 1.
    - **Reason**: The Brain workflow does not require full repository history for its reasoning or metrics collection phases.
    - **Impact**: Reduces clone time for the daily Brain workflow runs.

4.  **Metrics Reporting Fix**:
    - Implemented pagination in `tools/gemini-cli-bot/metrics/scripts/actions_spend.ts` to ensure a full 7-day window is captured.
    - **Reason**: The previous 1000-run limit was causing significant under-reporting for constant-rate workflows like Pulse during CI surges, as the sample was saturated by bursty CI activity.
    - **Impact**: Provides more accurate cost metrics, revealing the true scale of constant "heartbeat" costs.

### Data-Driven Justification

Analysis of the last 7 days of metrics (`actions_spend_minutes`) showed:
- **Testing: CI**: 4074 minutes (approx. 64% of total spend).
- **macOS Runners**: The primary driver of CI cost due to high per-minute rates on large runners.
- **Pulse Workflow**: Previously under-reported due to sampling limits, but now identified as a consistent baseline cost that can be significantly optimized.

These changes prioritize high-impact reductions in expensive runner minutes while maintaining robust cross-platform testing on the primary supported Node.js version.
2026-05-06 00:03:36 +00:00
..
2026-05-01 19:20:02 +00:00