@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Measure how long build targets take in Harbormaster

Summary:
Ref T1049. This keeps track of how long a build target takes to execute in Harbormaster and displays it in the build view page. I'm not sure whether "Started" is really that useful once the target has completed?

Also, I change the name of the time taken depending on whether or not the target has completed; if it's still in progress it's called "Elapsed" and if it's completed then it's "Duration". The primary reason for this is that "Duration" sounds like post tense, whereas "Elapsed" is current tense. I'm not sure whether this is okay or not?

Test Plan: Ran a Sleep build step and saw the target dates / times appear correctly.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: talshiri, epriestley, Korvin

Maniphest Tasks: T5824, T1049

Differential Revision: https://secure.phabricator.com/D10174

+42 -1
+5
resources/sql/autopatches/20140807.harbormastertargettime.sql
··· 1 + ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget 2 + ADD dateStarted INT UNSIGNED NULL; 3 + 4 + ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget 5 + ADD dateCompleted INT UNSIGNED NULL;
+26 -1
src/applications/harbormaster/controller/HarbormasterBuildViewController.php
··· 94 94 $status_view->addItem($item); 95 95 96 96 $properties->addProperty(pht('Name'), $build_target->getName()); 97 + 98 + if ($build_target->getDateStarted() !== null) { 99 + $properties->addProperty( 100 + pht('Started'), 101 + phabricator_datetime($build_target->getDateStarted(), $viewer)); 102 + if ($build_target->isComplete()) { 103 + $properties->addProperty( 104 + pht('Completed'), 105 + phabricator_datetime($build_target->getDateCompleted(), $viewer)); 106 + $properties->addProperty( 107 + pht('Duration'), 108 + phutil_format_relative_time_detailed( 109 + $build_target->getDateCompleted() - 110 + $build_target->getDateStarted())); 111 + } else { 112 + $properties->addProperty( 113 + pht('Elapsed'), 114 + phutil_format_relative_time_detailed( 115 + time() - $build_target->getDateStarted())); 116 + } 117 + } 118 + 97 119 $properties->addProperty(pht('Status'), $status_view); 98 120 99 121 $target_box->addPropertyList($properties, pht('Overview')); ··· 192 214 ->setFlush(true); 193 215 194 216 foreach ($artifacts as $artifact) { 195 - $list->addItem($artifact->getObjectItemView($viewer)); 217 + $item = $artifact->getObjectItemView($viewer); 218 + if ($item !== null) { 219 + $list->addItem($item); 220 + } 196 221 } 197 222 198 223 return $list;
+2
src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
··· 10 10 protected $details; 11 11 protected $variables; 12 12 protected $targetStatus; 13 + protected $dateStarted; 14 + protected $dateCompleted; 13 15 14 16 const STATUS_PENDING = 'target/pending'; 15 17 const STATUS_BUILDING = 'target/building';
+9
src/applications/harbormaster/worker/HarbormasterTargetWorker.php
··· 35 35 $build = $target->getBuild(); 36 36 $viewer = $this->getViewer(); 37 37 38 + $target->setDateStarted(time()); 39 + 38 40 try { 39 41 $status_pending = HarbormasterBuildTarget::STATUS_PENDING; 40 42 if ($target->getTargetStatus() == $status_pending) { ··· 51 53 } 52 54 53 55 $target->setTargetStatus($next_status); 56 + 57 + if ($target->isComplete()) { 58 + $target->setDateCompleted(time()); 59 + } 60 + 54 61 $target->save(); 55 62 } catch (PhabricatorWorkerYieldException $ex) { 56 63 // If the target wants to yield, let that escape without further ··· 59 66 } catch (HarbormasterBuildFailureException $ex) { 60 67 // A build step wants to fail explicitly. 61 68 $target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED); 69 + $target->setDateCompleted(time()); 62 70 $target->save(); 63 71 } catch (Exception $ex) { 64 72 phlog($ex); ··· 73 81 } 74 82 75 83 $target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED); 84 + $target->setDateCompleted(time()); 76 85 $target->save(); 77 86 } 78 87