This PR focuses strictly on reducing GitHub Actions costs by optimizing the CI matrix, as requested.
### Summary of Changes
1. **CI Matrix Optimization**:
- **Linux**: Retained the full matrix of Node.js versions (20.x, 22.x, 24.x) with sharding (`cli`, `others`) to ensure robust coverage on the primary platform.
- **macOS**: Reduced to a single job running Node.js 20.x (the recommended version). This eliminates the matrix and sharding for Mac, significantly reducing the usage of expensive Mac runners.
- **Impact**: Expected to reduce Mac runner usage by approximately 83% (from 6 jobs per run to 1 job per run) while maintaining core cross-platform compatibility checks.
2. **Scope Refinement**:
- Reverted unrelated changes to policy engines, documentation, and tests that were inadvertently included in previous iterations of this branch.
- Confirmed that optimizations in `gemini-cli-bot-pulse.yml` and `gemini-cli-bot-brain.yml` have been fully reverted to their baseline state.
### Data-Driven Justification
- **Mac Runner Cost**: macOS runners are significantly more expensive than Linux runners. By consolidating Mac testing into a single job for the recommended Node.js version, we maintain essential platform verification while minimizing cost.
- **Linux Matrix**: Moving the heavier matrix testing (multiple Node versions) to Linux leverages more cost-effective runners without sacrificing compatibility verification.
This PR focuses on reducing GitHub Actions costs by optimizing the CI test matrix.
### Summary of Changes
1. **CI Matrix Optimization**: Reduced the `test_mac` matrix in `Testing: CI` to only run on Node.js 20.x. Node.js 22.x and 24.x are still covered by the `test_linux` matrix.
- **Reason**: macOS runners (especially `macos-latest-large`) are significantly more expensive than Linux runners.
- **Impact**: Expected to reduce Mac runner usage by approximately 66% in the CI pipeline, leading to a significant reduction in overall Actions spend.
Other workflow optimizations previously included in this PR (Pulse and Brain) have been reverted to keep the scope focused on CI matrix changes.
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.
### 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**: While frequent, it was not in the top list of spenders, but still represents low-hanging fruit for optimization.
These changes prioritize high-impact reductions in expensive runner minutes while maintaining robust cross-platform testing on the primary supported Node.js version.