BUILD-11298 Add CI metrics job-completed hook for WarpBuild runners#270
BUILD-11298 Add CI metrics job-completed hook for WarpBuild runners#270matemoln wants to merge 1 commit into
Conversation
Publish runner-side job-completed.sh for download by ci-ami-images AMIs. Branch BUILD-11298-ci-metrics-hook is pinned by the consumer until a tag is cut.
Agentic Analysis: Early ResultsAgentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action. 15 issue(s) found across 1 file(s):
Analyzed by SonarQube Agentic Analysis in 3.1 s |
|
There was a problem hiding this comment.
Pull request overview
Adds a runner-side “job completed” metrics hook script under ci-metrics/ intended to be downloaded and executed by WarpBuild runner images, and documents how consumers should enable and fetch it.
Changes:
- Added
ci-metrics/job-completed.shto collect cgroup v2 + network totals, writejob-metrics.json, and append a step-summary table (fail-open). - Documented the hook’s purpose, feature flag, and the pinned raw URL in
README.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
README.md |
Documents the new ci-metrics/ hook, usage, feature flag, and consumer raw URL. |
ci-metrics/job-completed.sh |
Introduces the job-completed hook script that collects and emits CI metrics + optional cache aggregation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Reads cgroup v2 + /proc/net/dev as totals (no baseline; ephemeral runners), writes ${CI_METRICS_DIR}/job-metrics.json, and appends a | ||
| # metrics table to $GITHUB_STEP_SUMMARY. |
| # Fail-open: any unexpected error returns rc=0. | ||
| # The script also has an explicit `exit 0` at the bottom, so the trap only fires on errors. | ||
| # No EXIT trap: it would suppress non-zero returns if the hook is sourced. | ||
| trap 'exit 0' ERR |
| for iface in "${!net_rx[@]}"; do | ||
| json_by_interface+="${sep}\"${iface}\":{\"rx_bytes\":${net_rx[$iface]},\"tx_bytes\":${net_tx[$iface]}}" | ||
| sep="," | ||
| done |
| #!/usr/bin/env bash | ||
| # CI metrics completion hook. | ||
| # | ||
| # Reads cgroup v2 + /proc/net/dev as totals (no baseline; ephemeral runners), writes ${CI_METRICS_DIR}/job-metrics.json, and appends a | ||
| # metrics table to $GITHUB_STEP_SUMMARY. | ||
| # Fail-open: any error → exit 0 without breaking the job. |
CI failed: Pre-commit checks failed: shellcheck found an unused function in the new job-completed.sh script (SC2329), and markdownlint flagged 3 lines in README.md exceeding the 140-character limit.OverviewAnalyzed 1 CI log from the pre-commit job. The PR introduces a new CI metrics job-completed hook for WarpBuild runners, but the pre-commit validation detected code quality issues in both the new bash script and the updated documentation. FailuresShellCheck violation in job-completed.sh (confidence: high)
Markdown line length violations in README.md (confidence: high)
Summary
Code Review ✅ ApprovedPublishes job-completed.sh hook for WarpBuild CI metrics collection, copied from github-runners-infra. Script enables fail-open cgroup/network metrics gathering when CI_METRICS_ENABLED=true, with no issues found. Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |



Summary
Publish
job-completed.shfor WarpBuild CI metrics (BUILD-11298). The script is copied verbatim fromgithub-runners-infra(infra/applications/github-runners/hooks/job-completed.sh).This is not a GitHub Action — it lives under
ci-metrics/and is downloaded at job start by WarpBuild runner AMIs built in SonarSource/ci-ami-images#369.Contents
ci-metrics/job-completed.sh— cgroup/network metrics hook (fail-open)Consumer pin
ci-ami-imagesdownloads from:https://raw.githubusercontent.com/SonarSource/ci-github-actions/BUILD-11298-ci-metrics-hook/ci-metrics/job-completed.shThis branch is intentionally long-lived until the hook is promoted to a release tag; update the consumer URL when merging to
master/ cutting a tag.Feature flag
Set
CI_METRICS_ENABLED=trueto collect metrics. Output:${CI_METRICS_DIR}/job-metrics.jsonand a## CI Metricsstep summary table.Out of scope
ACTIONS_RUNNER_HOOK_JOB_COMPLETEDwiring (BUILD-11299)github-runners-infra(ARC still uses it)Test plan
ci-ami-imagesci-metrics-test.ymlon WarpBuild PoC runner