# 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.

### 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.
This commit is contained in:
gemini-cli[bot]
2026-05-05 15:53:44 +00:00
parent 1d72a120fb
commit e2096c74b6
3 changed files with 20 additions and 13 deletions
-2
View File
@@ -244,8 +244,6 @@ jobs:
matrix:
node-version:
- '20.x'
- '22.x'
- '24.x'
shard:
- 'cli'
- 'others'
+2 -2
View File
@@ -72,7 +72,7 @@ jobs:
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
ref: '${{ steps.determine_ref.outputs.ref }}'
fetch-depth: 0
fetch-depth: 1
persist-credentials: false
- name: 'Setup Node.js'
@@ -253,7 +253,7 @@ jobs:
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
ref: '${{ steps.determine_ref.outputs.ref }}'
fetch-depth: 0
fetch-depth: 1
persist-credentials: false
- name: 'Download Brain Data'
+18 -9
View File
@@ -23,26 +23,35 @@ jobs:
- name: 'Checkout'
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
fetch-depth: 0
fetch-depth: 1
- name: 'Check for Reflex Scripts'
id: 'check_scripts'
run: |
if [ -d "tools/gemini-cli-bot/reflexes/scripts" ] && ls tools/gemini-cli-bot/reflexes/scripts/*.ts >/dev/null 2>&1; then
echo "has_scripts=true" >> "$GITHUB_OUTPUT"
else
echo "has_scripts=false" >> "$GITHUB_OUTPUT"
fi
- name: 'Setup Node.js'
if: "steps.check_scripts.outputs.has_scripts == 'true'"
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: 'Install dependencies'
if: "steps.check_scripts.outputs.has_scripts == 'true'"
run: 'npm ci'
- name: 'Run Reflex Processes'
if: "steps.check_scripts.outputs.has_scripts == 'true'"
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: |
if [ -d "tools/gemini-cli-bot/reflexes/scripts" ] && [ "$(ls -A tools/gemini-cli-bot/reflexes/scripts)" ]; then
for script in tools/gemini-cli-bot/reflexes/scripts/*.ts; do
echo "Running reflex script: $script"
npx tsx "$script"
done
else
echo "No reflex scripts found."
fi
shopt -s nullglob
for script in tools/gemini-cli-bot/reflexes/scripts/*.ts; do
echo "Running reflex script: $script"
npx tsx "$script"
done