Skip to content

chore: include the build-duration-milliseconds github runner monitoring in the reusable workflow#751

Open
Kerruba wants to merge 1 commit into
mainfrom
infra-1080-duration-in-reusable-workflow
Open

chore: include the build-duration-milliseconds github runner monitoring in the reusable workflow#751
Kerruba wants to merge 1 commit into
mainfrom
infra-1080-duration-in-reusable-workflow

Conversation

@Kerruba

@Kerruba Kerruba commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Centralize build-duration collection in the shared submit-build-status action

Previously repositories were calculating build_duration_millis in its own observe-build-status wrapper (duplicated logic, relying on an unreliable GITHUB_ACTION_PATH directory mtime). This moves the calculation into the shared start-build-monitor / submit-build-status actions.

What changed:

  • start-build-monitor now records the job start time with millisecond precision (date +%s%3N) into a shared temp file, and clears any stale monitor state (PID/log/timestamp) at startup. It must remain the first job step so the duration covers the
    whole job.
  • submit-build-status reads that timestamp when it stops the monitor, computes the elapsed duration, validates it (non-negative integer, capped at 72h / 259200000 ms), and submits it automatically. Invalid/missing/out-of-range timestamps omit the
    field with a warning instead of failing submission.
  • Duration and resource/network metrics are now collected before Google auth and the BigQuery submission, so they exclude telemetry-submission overhead.
  • Resolution precedence: explicit build_duration_millis input → monitor-derived duration → field omitted.
  • Resource-metric computation (CPU/mem percentiles, network bytes) is unchanged.

Backward compatibility: Fully backward compatible.

  • The optional build_duration_millis input is retained. Repositories that pass their own value override the automatic duration — an explicit non-empty input always takes precedence, so unmigrated wrappers keep working unchanged.
  • Repositories that do not run start-build-monitor (or haven't migrated) simply get no automatic duration; the field is omitted (NULL in BigQuery), exactly as before.
  • No consumer changes are required to adopt this; wrappers can drop their local duration calculation later, after this action ref is available.

Copilot AI review requested due to automatic review settings July 17, 2026 09:41
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Kerruba
Kerruba requested review from clementnero and cmur2 July 17, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes build-duration collection in the shared start-build-monitor + submit-build-status actions, removing the need for per-repo duration calculation and ensuring duration/resource metrics are captured before auth/BigQuery submission.

Changes:

  • Record job start time (epoch millis) in start-build-monitor and compute/validate elapsed duration in submit-build-status.
  • Add explicit-duration validation and precedence resolution (explicit input overrides monitor-derived duration).
  • Update submit-build-status workflow step ordering and documentation; add a shell test script for duration behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
submit-build-status/validate-build-duration.sh Adds validation/normalization for explicit build_duration_millis input with max 72h cap.
submit-build-status/test_build_duration.sh Adds a shell-based test harness covering duration validation and monitor-derived duration behavior.
submit-build-status/stop-and-collect-build-monitor.sh Computes duration from start timestamp, makes monitor paths overridable, and emits build_duration_millis as a step output.
submit-build-status/resolve-build-duration.sh Implements precedence selection between explicit and monitor-derived duration.
submit-build-status/README.md Documents automatic duration behavior, precedence, and updated integration example.
submit-build-status/action.yml Validates duration input, collects metrics earlier, resolves duration, and submits the resolved duration field.
start-build-monitor/start-build-monitor.sh Writes start timestamp (epoch millis) and clears stale monitor state at startup; improves quoting.
start-build-monitor/README.md Updates docs to include duration collection and guidance to keep the step first in the job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 10 to +14
# NOTE: these paths are shared with start-build-monitor.sh -- if changed, update both
PID_FILE=/tmp/_monitor-start.pid
LOG_FILE=/tmp/_monitor-start.log
PID_FILE="${BUILD_MONITOR_PID_FILE:-/tmp/_monitor-start.pid}"
LOG_FILE="${BUILD_MONITOR_LOG_FILE:-/tmp/_monitor-start.log}"
START_TIME_FILE="${BUILD_MONITOR_START_TIME_FILE:-/tmp/_monitor-start.epoch-millis}"
NET_DEV_FILE="${BUILD_MONITOR_NET_DEV_FILE:-/proc/net/dev}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants