diff --git a/www/react-base/src/components/BuildSummary/BuildSummary.tsx b/www/react-base/src/components/BuildSummary/BuildSummary.tsx index 188edb8c7c6f..63a7933d1eb6 100644 --- a/www/react-base/src/components/BuildSummary/BuildSummary.tsx +++ b/www/react-base/src/components/BuildSummary/BuildSummary.tsx @@ -27,7 +27,7 @@ import { ConfigContext, analyzeStepUrls, buildDurationFormatWithLocks, - durationFormat, + stepDurationFormatWithLocks, useCurrentTime, useStateWithParentTrackingWithDefaultIfNotSet, useStepUrlAnalyzer @@ -104,32 +104,6 @@ type BuildSummaryStepLineProps = { parentFullDisplay: boolean } -function getTimeTextForStep(step: Step, now: number) { - const lockDuration = step.locks_acquired_at !== null - ? step.locks_acquired_at - step.started_at! - : 0; - - if (step.complete) { - const stepDurationText = durationFormat(step.complete_at! - step.started_at!); - - if (lockDuration > 1) { - // Since lock delay includes general step setup overhead, then sometimes the started_at and locks_acquired_at - // may fall into different seconds. However, it's unlikely that step setup would take more than one second. - return `${stepDurationText} (${durationFormat(lockDuration)} spent waiting for locks)` - } - return stepDurationText; - } - - const ongoingStepDurationText = durationFormat(now - step.started_at!); - if (lockDuration > 1) { - // Since lock delay includes general step setup overhead, then sometimes the started_at and locks_acquired_at - // may fall into different seconds. However, it's unlikely that step setup would take more than one second. - return `${ongoingStepDurationText} (${durationFormat(lockDuration)} spent waiting for locks)` - } - - return ongoingStepDurationText; -} - const BuildSummaryStepLine = observer(({build, step, logs, parentFullDisplay}: BuildSummaryStepLineProps) => { const config = useContext(ConfigContext); const now = useCurrentTime(); @@ -150,7 +124,7 @@ const BuildSummaryStepLine = observer(({build, step, logs, parentFullDisplay}: B return ( - {getTimeTextForStep(step, now)} + {stepDurationFormatWithLocks(step, now)}   {step.state_string} diff --git a/www/react-ui/src/components/BuildSummaryTooltip/BuildSummaryTooltip.tsx b/www/react-ui/src/components/BuildSummaryTooltip/BuildSummaryTooltip.tsx index e0b70ecf71d4..fbffa30f8d3c 100644 --- a/www/react-ui/src/components/BuildSummaryTooltip/BuildSummaryTooltip.tsx +++ b/www/react-ui/src/components/BuildSummaryTooltip/BuildSummaryTooltip.tsx @@ -29,8 +29,8 @@ import { results2text } from "buildbot-data-js"; import {ConfigContext} from "../../contexts/Config"; -import {buildDurationFormatWithLocks} from "../../util/DataUtils"; -import {durationFormat, useCurrentTime} from "../../util/Moment"; +import {buildDurationFormatWithLocks, stepDurationFormatWithLocks} from "../../util/DataUtils"; +import {useCurrentTime} from "../../util/Moment"; import {analyzeStepUrls, useStepUrlAnalyzer} from "../../util/StepUrls"; import {BadgeRound} from "../BadgeRound/BadgeRound"; import {BadgeStatus} from "../BadgeStatus/BadgeStatus"; @@ -125,11 +125,7 @@ export const BuildSummaryTooltip = observer(({build}: BuildSummaryTooltipProps) if (step.started_at !== null) { stepInfoWhenStarted = ( - { - step.complete - ? {durationFormat(step.complete_at! - step.started_at)} - : {durationFormat(now - step.started_at)} - } + { stepDurationFormatWithLocks(step, now) }   {limitStringLength(step.state_string, 40)} diff --git a/www/react-ui/src/util/DataUtils.ts b/www/react-ui/src/util/DataUtils.ts index 26cb3a2418d2..21ace19631ec 100644 --- a/www/react-ui/src/util/DataUtils.ts +++ b/www/react-ui/src/util/DataUtils.ts @@ -15,7 +15,7 @@ Copyright Buildbot Team Members */ -import {Build, Builder, DataCollection, Master} from "buildbot-data-js"; +import {Build, Builder, DataCollection, Master, Step} from "buildbot-data-js"; import {durationFormat} from "./Moment"; export function hasActiveMaster(builder: Builder, masters: DataCollection) { @@ -45,3 +45,31 @@ export function buildDurationFormatWithLocks(build: Build, now: number) { } return res; } + +export function stepDurationFormatWithLocks(step: Step, now: number) { + const lockDuration = step.locks_acquired_at !== null + ? step.locks_acquired_at - step.started_at! + : 0; + + if (step.complete) { + const stepDurationText = durationFormat(step.complete_at! - step.started_at!); + + if (lockDuration > 1) { + // Since lock delay includes general step setup overhead, then sometimes the started_at and + // locks_acquired_at may fall into different seconds. However, it's unlikely that step setup + // would take more than one second. + return `${stepDurationText} (locks: ${durationFormat(lockDuration)})` + } + return stepDurationText; + } + + const ongoingStepDurationText = durationFormat(now - step.started_at!); + if (lockDuration > 1) { + // Since lock delay includes general step setup overhead, then sometimes the started_at and + // locks_acquired_at may fall into different seconds. However, it's unlikely that step setup + // would take more than one second. + return `${ongoingStepDurationText} (locks: ${durationFormat(lockDuration)})` + } + + return ongoingStepDurationText; +}