feat(bot): add actions spend metric script#26463
Conversation
Summary of ChangesHello, 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 introduces a new utility to track and report GitHub Actions usage metrics. By analyzing recent workflow runs, the tool provides visibility into execution time, enabling better monitoring of resource consumption and potential cost optimization opportunities. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new metric for tracking GitHub Actions spend minutes and updates the metrics documentation to include cost savings as a priority. The implementation includes a script that queries the GitHub CLI for workflow run durations over the past seven days. Feedback from the review highlights several critical issues: the current data collection may be incomplete due to hardcoded limits, the cost calculation is inaccurate because it uses wall-clock time instead of billable job minutes (ignoring parallelism and rounding), and the detailed per-workflow breakdown is currently discarded by the metric runner.
| if (start < sevenDaysAgo) continue; | ||
| const end = new Date(r.updatedAt).getTime(); | ||
| const durationMinutes = (end - start) / (1000 * 60); | ||
|
|
There was a problem hiding this comment.
The calculation of durationMinutes using the difference between updatedAt and startedAt reflects the wall-clock duration of the workflow run. This is an inaccurate proxy for "spend" for two critical reasons:
- Parallelism: GitHub Actions bills for the sum of the durations of all individual jobs. If a workflow runs 10 jobs in parallel for 5 minutes, the actual billable spend is 50 minutes, but this script will only report 5 minutes.
- Rounding: GitHub bills each job by rounding up to the nearest minute (e.g., a 10-second job costs 1 minute). This script calculates fractional minutes based on wall-clock time, further undercounting the actual cost.
Since this metric is intended to drive "Cost Savings" recommendations (as per metrics.md), these discrepancies make the data misleading and ineffective for identifying real savings (e.g., optimizing a non-critical-path parallel job won't change this metric at all).
|
Size Change: -4 B (0%) Total Size: 34 MB
ℹ️ View Unchanged
|
Summary
Adds a new metric script to track total GitHub Actions spend. It fetches the last 1000 workflow runs, filters for those within the last 7 days, and calculates the total execution time in minutes.
Details
gh run listto fetch workflow runs.MetricOutputJSON format used by thegemini-cli-bot.Related Issues
None.
How to Validate
Run the script locally to see the metrics output:
Pre-Merge Checklist