mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
This commit is contained in:
parent
60fca1d7f4
commit
efc82c727b
4 changed files with 42 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget
|
||||
ADD dateStarted INT UNSIGNED NULL;
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget
|
||||
ADD dateCompleted INT UNSIGNED NULL;
|
|
@ -94,6 +94,28 @@ final class HarbormasterBuildViewController
|
|||
$status_view->addItem($item);
|
||||
|
||||
$properties->addProperty(pht('Name'), $build_target->getName());
|
||||
|
||||
if ($build_target->getDateStarted() !== null) {
|
||||
$properties->addProperty(
|
||||
pht('Started'),
|
||||
phabricator_datetime($build_target->getDateStarted(), $viewer));
|
||||
if ($build_target->isComplete()) {
|
||||
$properties->addProperty(
|
||||
pht('Completed'),
|
||||
phabricator_datetime($build_target->getDateCompleted(), $viewer));
|
||||
$properties->addProperty(
|
||||
pht('Duration'),
|
||||
phutil_format_relative_time_detailed(
|
||||
$build_target->getDateCompleted() -
|
||||
$build_target->getDateStarted()));
|
||||
} else {
|
||||
$properties->addProperty(
|
||||
pht('Elapsed'),
|
||||
phutil_format_relative_time_detailed(
|
||||
time() - $build_target->getDateStarted()));
|
||||
}
|
||||
}
|
||||
|
||||
$properties->addProperty(pht('Status'), $status_view);
|
||||
|
||||
$target_box->addPropertyList($properties, pht('Overview'));
|
||||
|
@ -192,7 +214,10 @@ final class HarbormasterBuildViewController
|
|||
->setFlush(true);
|
||||
|
||||
foreach ($artifacts as $artifact) {
|
||||
$list->addItem($artifact->getObjectItemView($viewer));
|
||||
$item = $artifact->getObjectItemView($viewer);
|
||||
if ($item !== null) {
|
||||
$list->addItem($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
|
@ -10,6 +10,8 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
|
|||
protected $details;
|
||||
protected $variables;
|
||||
protected $targetStatus;
|
||||
protected $dateStarted;
|
||||
protected $dateCompleted;
|
||||
|
||||
const STATUS_PENDING = 'target/pending';
|
||||
const STATUS_BUILDING = 'target/building';
|
||||
|
|
|
@ -35,6 +35,8 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
|
|||
$build = $target->getBuild();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$target->setDateStarted(time());
|
||||
|
||||
try {
|
||||
$status_pending = HarbormasterBuildTarget::STATUS_PENDING;
|
||||
if ($target->getTargetStatus() == $status_pending) {
|
||||
|
@ -51,6 +53,11 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
|
|||
}
|
||||
|
||||
$target->setTargetStatus($next_status);
|
||||
|
||||
if ($target->isComplete()) {
|
||||
$target->setDateCompleted(time());
|
||||
}
|
||||
|
||||
$target->save();
|
||||
} catch (PhabricatorWorkerYieldException $ex) {
|
||||
// If the target wants to yield, let that escape without further
|
||||
|
@ -59,6 +66,7 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
|
|||
} catch (HarbormasterBuildFailureException $ex) {
|
||||
// A build step wants to fail explicitly.
|
||||
$target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED);
|
||||
$target->setDateCompleted(time());
|
||||
$target->save();
|
||||
} catch (Exception $ex) {
|
||||
phlog($ex);
|
||||
|
@ -73,6 +81,7 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
|
|||
}
|
||||
|
||||
$target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED);
|
||||
$target->setDateCompleted(time());
|
||||
$target->save();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue