mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 18:51:12 +01:00
Move build statuses to a constants class
Summary: No functional changes here, just lifting this out to make room for activities, heeding lint warnings along the way. Test Plan: before: ```lang=bash $ grep -Rn "HarbormasterBuild::" * src/applications/harbormaster/storage/HarbormasterBuildable.php:169: $build = HarbormasterBuild::initializeNewBuild($viewer) src/applications/harbormaster/storage/HarbormasterBuildable.php:173: ->setBuildStatus(HarbormasterBuild::STATUS_PENDING); src/applications/harbormaster/controller/HarbormasterStepEditController.php:242: $variables = HarbormasterBuild::getAvailableBuildVariables(); src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:200: 'fa-dot-circle-o '.HarbormasterBuild::getBuildStatusColor($status), src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:201: HarbormasterBuild::getBuildStatusName($status)); src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:203: $item->addAttribute(HarbormasterBuild::getBuildStatusName($status)); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:584: HarbormasterBuild::getBuildStatusName($status); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:585: $icon = HarbormasterBuild::getBuildStatusIcon($status); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:586: $color = HarbormasterBuild::getBuildStatusColor($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:135: $status_name = HarbormasterBuild::getBuildStatusName($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:136: $icon = HarbormasterBuild::getBuildStatusIcon($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:137: $color = HarbormasterBuild::getBuildStatusColor($status); src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php:78: 'buildStatusName' => HarbormasterBuild::getBuildStatusName($status), src/applications/harbormaster/engine/HarbormasterBuildEngine.php:66: $build->setBuildStatus(HarbormasterBuild::STATUS_ERROR); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:109: $build->setBuildStatus(HarbormasterBuild::STATUS_ABORTED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:113: if (($build->getBuildStatus() == HarbormasterBuild::STATUS_PENDING) || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:116: $build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:121: $build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:126: $build->setBuildStatus(HarbormasterBuild::STATUS_PAUSED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:132: if ($build->getBuildStatus() == HarbormasterBuild::STATUS_BUILDING) { src/applications/harbormaster/engine/HarbormasterBuildEngine.php:246: $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:254: $build->setBuildStatus(HarbormasterBuild::STATUS_PASSED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:290: $build->setBuildStatus(HarbormasterBuild::STATUS_DEADLOCKED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:446: if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) { src/applications/harbormaster/engine/HarbormasterBuildEngine.php:449: if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:450: $build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:451: $build->getBuildStatus() == HarbormasterBuild::STATUS_DEADLOCKED) { ``` after: ```lang=bash $ grep -Rn "HarbormasterBuild::" * src/applications/harbormaster/storage/HarbormasterBuildable.php:169: $build = HarbormasterBuild::initializeNewBuild($viewer) src/applications/harbormaster/controller/HarbormasterStepEditController.php:242: $variables = HarbormasterBuild::getAvailableBuildVariables(); ``` ran a manual build as a sanity check Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D16348
This commit is contained in:
parent
2c55a4ad72
commit
42b81a8090
11 changed files with 168 additions and 160 deletions
|
@ -1131,6 +1131,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php',
|
'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php',
|
||||||
'HarbormasterBuildRequest' => 'applications/harbormaster/engine/HarbormasterBuildRequest.php',
|
'HarbormasterBuildRequest' => 'applications/harbormaster/engine/HarbormasterBuildRequest.php',
|
||||||
'HarbormasterBuildSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildSearchEngine.php',
|
'HarbormasterBuildSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildSearchEngine.php',
|
||||||
|
'HarbormasterBuildStatus' => 'applications/harbormaster/constants/HarbormasterBuildStatus.php',
|
||||||
'HarbormasterBuildStatusDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildStatusDatasource.php',
|
'HarbormasterBuildStatusDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildStatusDatasource.php',
|
||||||
'HarbormasterBuildStep' => 'applications/harbormaster/storage/configuration/HarbormasterBuildStep.php',
|
'HarbormasterBuildStep' => 'applications/harbormaster/storage/configuration/HarbormasterBuildStep.php',
|
||||||
'HarbormasterBuildStepCoreCustomField' => 'applications/harbormaster/customfield/HarbormasterBuildStepCoreCustomField.php',
|
'HarbormasterBuildStepCoreCustomField' => 'applications/harbormaster/customfield/HarbormasterBuildStepCoreCustomField.php',
|
||||||
|
@ -5687,6 +5688,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'HarbormasterBuildRequest' => 'Phobject',
|
'HarbormasterBuildRequest' => 'Phobject',
|
||||||
'HarbormasterBuildSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'HarbormasterBuildSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
'HarbormasterBuildStatus' => 'Phobject',
|
||||||
'HarbormasterBuildStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
'HarbormasterBuildStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'HarbormasterBuildStep' => array(
|
'HarbormasterBuildStep' => array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
|
|
|
@ -66,6 +66,7 @@ final class HarbormasterQueryBuildsConduitAPIMethod
|
||||||
$id = $build->getID();
|
$id = $build->getID();
|
||||||
$uri = '/harbormaster/build/'.$id.'/';
|
$uri = '/harbormaster/build/'.$id.'/';
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
|
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||||
|
|
||||||
$data[] = array(
|
$data[] = array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
|
@ -75,7 +76,7 @@ final class HarbormasterQueryBuildsConduitAPIMethod
|
||||||
'buildablePHID' => $build->getBuildablePHID(),
|
'buildablePHID' => $build->getBuildablePHID(),
|
||||||
'buildPlanPHID' => $build->getBuildPlanPHID(),
|
'buildPlanPHID' => $build->getBuildPlanPHID(),
|
||||||
'buildStatus' => $status,
|
'buildStatus' => $status,
|
||||||
'buildStatusName' => HarbormasterBuild::getBuildStatusName($status),
|
'buildStatusName' => $status_name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterBuildStatus extends Phobject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not currently being built.
|
||||||
|
*/
|
||||||
|
const STATUS_INACTIVE = 'inactive';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pending pick up by the Harbormaster daemon.
|
||||||
|
*/
|
||||||
|
const STATUS_PENDING = 'pending';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current building the buildable.
|
||||||
|
*/
|
||||||
|
const STATUS_BUILDING = 'building';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build has passed.
|
||||||
|
*/
|
||||||
|
const STATUS_PASSED = 'passed';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build has failed.
|
||||||
|
*/
|
||||||
|
const STATUS_FAILED = 'failed';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build has aborted.
|
||||||
|
*/
|
||||||
|
const STATUS_ABORTED = 'aborted';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build encountered an unexpected error.
|
||||||
|
*/
|
||||||
|
const STATUS_ERROR = 'error';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build has been paused.
|
||||||
|
*/
|
||||||
|
const STATUS_PAUSED = 'paused';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The build has been deadlocked.
|
||||||
|
*/
|
||||||
|
const STATUS_DEADLOCKED = 'deadlocked';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a human readable name for a build status constant.
|
||||||
|
*
|
||||||
|
* @param const Build status constant.
|
||||||
|
* @return string Human-readable name.
|
||||||
|
*/
|
||||||
|
public static function getBuildStatusName($status) {
|
||||||
|
$map = self::getBuildStatusMap();
|
||||||
|
return idx($map, $status, pht('Unknown ("%s")', $status));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBuildStatusMap() {
|
||||||
|
return array(
|
||||||
|
self::STATUS_INACTIVE => pht('Inactive'),
|
||||||
|
self::STATUS_PENDING => pht('Pending'),
|
||||||
|
self::STATUS_BUILDING => pht('Building'),
|
||||||
|
self::STATUS_PASSED => pht('Passed'),
|
||||||
|
self::STATUS_FAILED => pht('Failed'),
|
||||||
|
self::STATUS_ABORTED => pht('Aborted'),
|
||||||
|
self::STATUS_ERROR => pht('Unexpected Error'),
|
||||||
|
self::STATUS_PAUSED => pht('Paused'),
|
||||||
|
self::STATUS_DEADLOCKED => pht('Deadlocked'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBuildStatusIcon($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::STATUS_INACTIVE:
|
||||||
|
case self::STATUS_PENDING:
|
||||||
|
return PHUIStatusItemView::ICON_OPEN;
|
||||||
|
case self::STATUS_BUILDING:
|
||||||
|
return PHUIStatusItemView::ICON_RIGHT;
|
||||||
|
case self::STATUS_PASSED:
|
||||||
|
return PHUIStatusItemView::ICON_ACCEPT;
|
||||||
|
case self::STATUS_FAILED:
|
||||||
|
return PHUIStatusItemView::ICON_REJECT;
|
||||||
|
case self::STATUS_ABORTED:
|
||||||
|
return PHUIStatusItemView::ICON_MINUS;
|
||||||
|
case self::STATUS_ERROR:
|
||||||
|
return PHUIStatusItemView::ICON_MINUS;
|
||||||
|
case self::STATUS_PAUSED:
|
||||||
|
return PHUIStatusItemView::ICON_MINUS;
|
||||||
|
case self::STATUS_DEADLOCKED:
|
||||||
|
return PHUIStatusItemView::ICON_WARNING;
|
||||||
|
default:
|
||||||
|
return PHUIStatusItemView::ICON_QUESTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBuildStatusColor($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::STATUS_INACTIVE:
|
||||||
|
return 'dark';
|
||||||
|
case self::STATUS_PENDING:
|
||||||
|
case self::STATUS_BUILDING:
|
||||||
|
return 'blue';
|
||||||
|
case self::STATUS_PASSED:
|
||||||
|
return 'green';
|
||||||
|
case self::STATUS_FAILED:
|
||||||
|
case self::STATUS_ABORTED:
|
||||||
|
case self::STATUS_ERROR:
|
||||||
|
case self::STATUS_DEADLOCKED:
|
||||||
|
return 'red';
|
||||||
|
case self::STATUS_PAUSED:
|
||||||
|
return 'dark';
|
||||||
|
default:
|
||||||
|
return 'bluegrey';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -581,9 +581,9 @@ final class HarbormasterBuildViewController
|
||||||
} else {
|
} else {
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
$status_name =
|
$status_name =
|
||||||
HarbormasterBuild::getBuildStatusName($status);
|
HarbormasterBuildStatus::getBuildStatusName($status);
|
||||||
$icon = HarbormasterBuild::getBuildStatusIcon($status);
|
$icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||||
$color = HarbormasterBuild::getBuildStatusColor($status);
|
$color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->setTarget($status_name);
|
$item->setTarget($status_name);
|
||||||
|
|
|
@ -196,11 +196,10 @@ final class HarbormasterBuildableViewController
|
||||||
->setHref($view_uri);
|
->setHref($view_uri);
|
||||||
|
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
$item->setStatusIcon(
|
$status_color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||||
'fa-dot-circle-o '.HarbormasterBuild::getBuildStatusColor($status),
|
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||||
HarbormasterBuild::getBuildStatusName($status));
|
$item->setStatusIcon('fa-dot-circle-o '.$status_color, $status_name);
|
||||||
|
$item->addAttribute($status_name);
|
||||||
$item->addAttribute(HarbormasterBuild::getBuildStatusName($status));
|
|
||||||
|
|
||||||
if ($build->isRestarting()) {
|
if ($build->isRestarting()) {
|
||||||
$item->addIcon('fa-repeat', pht('Restarting'));
|
$item->addIcon('fa-repeat', pht('Restarting'));
|
||||||
|
|
|
@ -63,7 +63,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
// If any exception is raised, the build is marked as a failure and the
|
// If any exception is raised, the build is marked as a failure and the
|
||||||
// exception is re-thrown (this ensures we don't leave builds in an
|
// exception is re-thrown (this ensures we don't leave builds in an
|
||||||
// inconsistent state).
|
// inconsistent state).
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_ERROR);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_ERROR);
|
||||||
$build->save();
|
$build->save();
|
||||||
|
|
||||||
$lock->unlock();
|
$lock->unlock();
|
||||||
|
@ -106,30 +106,30 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
private function updateBuild(HarbormasterBuild $build) {
|
private function updateBuild(HarbormasterBuild $build) {
|
||||||
if ($build->isAborting()) {
|
if ($build->isAborting()) {
|
||||||
$this->releaseAllArtifacts($build);
|
$this->releaseAllArtifacts($build);
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_ABORTED);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_ABORTED);
|
||||||
$build->save();
|
$build->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($build->getBuildStatus() == HarbormasterBuild::STATUS_PENDING) ||
|
if (($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_PENDING) ||
|
||||||
($build->isRestarting())) {
|
($build->isRestarting())) {
|
||||||
$this->restartBuild($build);
|
$this->restartBuild($build);
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_BUILDING);
|
||||||
$build->save();
|
$build->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($build->isResuming()) {
|
if ($build->isResuming()) {
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_BUILDING);
|
||||||
$build->save();
|
$build->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($build->isPausing() && !$build->isComplete()) {
|
if ($build->isPausing() && !$build->isComplete()) {
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_PAUSED);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PAUSED);
|
||||||
$build->save();
|
$build->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$build->deleteUnprocessedCommands();
|
$build->deleteUnprocessedCommands();
|
||||||
|
|
||||||
if ($build->getBuildStatus() == HarbormasterBuild::STATUS_BUILDING) {
|
if ($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_BUILDING) {
|
||||||
$this->updateBuildSteps($build);
|
$this->updateBuildSteps($build);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
|
|
||||||
// If any step failed, fail the whole build, then bail.
|
// If any step failed, fail the whole build, then bail.
|
||||||
if (count($failed)) {
|
if (count($failed)) {
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_FAILED);
|
||||||
$build->save();
|
$build->save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
// If every step is complete, we're done with this build. Mark it passed
|
// If every step is complete, we're done with this build. Mark it passed
|
||||||
// and bail.
|
// and bail.
|
||||||
if (count($complete) == count($steps)) {
|
if (count($complete) == count($steps)) {
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_PASSED);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PASSED);
|
||||||
$build->save();
|
$build->save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
if (!$runnable && !$waiting && !$underway) {
|
if (!$runnable && !$waiting && !$underway) {
|
||||||
// This means the build is deadlocked, and the user has configured
|
// This means the build is deadlocked, and the user has configured
|
||||||
// circular dependencies.
|
// circular dependencies.
|
||||||
$build->setBuildStatus(HarbormasterBuild::STATUS_DEADLOCKED);
|
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_DEADLOCKED);
|
||||||
$build->save();
|
$build->save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -443,14 +443,14 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
$all_pass = true;
|
$all_pass = true;
|
||||||
$any_fail = false;
|
$any_fail = false;
|
||||||
foreach ($buildable->getBuilds() as $build) {
|
foreach ($buildable->getBuilds() as $build) {
|
||||||
if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) {
|
if ($build->getBuildStatus() != HarbormasterBuildStatus::STATUS_PASSED) {
|
||||||
$all_pass = false;
|
$all_pass = false;
|
||||||
}
|
}
|
||||||
if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED ||
|
$any_fail = in_array($build->getBuildStatus(), array(
|
||||||
$build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR ||
|
HarbormasterBuildStatus::STATUS_FAILED,
|
||||||
$build->getBuildStatus() == HarbormasterBuild::STATUS_DEADLOCKED) {
|
HarbormasterBuildStatus::STATUS_ERROR,
|
||||||
$any_fail = true;
|
HarbormasterBuildStatus::STATUS_DEADLOCKED,
|
||||||
}
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($any_fail) {
|
if ($any_fail) {
|
||||||
|
|
|
@ -132,9 +132,9 @@ final class HarbormasterUIEventListener
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
$status_name = HarbormasterBuild::getBuildStatusName($status);
|
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||||
$icon = HarbormasterBuild::getBuildStatusIcon($status);
|
$icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||||
$color = HarbormasterBuild::getBuildStatusColor($status);
|
$color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||||
|
|
||||||
$item->setIcon($icon, $color, $status_name);
|
$item->setIcon($icon, $color, $status_name);
|
||||||
|
|
||||||
|
|
|
@ -107,9 +107,9 @@ final class HarbormasterBuildSearchEngine
|
||||||
|
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
|
|
||||||
$status_icon = HarbormasterBuild::getBuildStatusIcon($status);
|
$status_icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||||
$status_color = HarbormasterBuild::getBuildStatusColor($status);
|
$status_color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||||
$status_label = HarbormasterBuild::getBuildStatusName($status);
|
$status_label = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||||
|
|
||||||
$item->setStatusIcon("{$status_icon} {$status_color}", $status_label);
|
$item->setStatusIcon("{$status_icon} {$status_color}", $status_label);
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
||||||
->setBuildablePHID($this->getPHID())
|
->setBuildablePHID($this->getPHID())
|
||||||
->setBuildPlanPHID($plan->getPHID())
|
->setBuildPlanPHID($plan->getPHID())
|
||||||
->setBuildParameters($parameters)
|
->setBuildParameters($parameters)
|
||||||
->setBuildStatus(HarbormasterBuild::STATUS_PENDING);
|
->setBuildStatus(HarbormasterBuildStatus::STATUS_PENDING);
|
||||||
if ($initiator_phid) {
|
if ($initiator_phid) {
|
||||||
$build->setInitiatorPHID($initiator_phid);
|
$build->setInitiatorPHID($initiator_phid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,125 +18,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
private $buildTargets = self::ATTACHABLE;
|
private $buildTargets = self::ATTACHABLE;
|
||||||
private $unprocessedCommands = self::ATTACHABLE;
|
private $unprocessedCommands = self::ATTACHABLE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Not currently being built.
|
|
||||||
*/
|
|
||||||
const STATUS_INACTIVE = 'inactive';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pending pick up by the Harbormaster daemon.
|
|
||||||
*/
|
|
||||||
const STATUS_PENDING = 'pending';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current building the buildable.
|
|
||||||
*/
|
|
||||||
const STATUS_BUILDING = 'building';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build has passed.
|
|
||||||
*/
|
|
||||||
const STATUS_PASSED = 'passed';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build has failed.
|
|
||||||
*/
|
|
||||||
const STATUS_FAILED = 'failed';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build has aborted.
|
|
||||||
*/
|
|
||||||
const STATUS_ABORTED = 'aborted';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build encountered an unexpected error.
|
|
||||||
*/
|
|
||||||
const STATUS_ERROR = 'error';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build has been paused.
|
|
||||||
*/
|
|
||||||
const STATUS_PAUSED = 'paused';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build has been deadlocked.
|
|
||||||
*/
|
|
||||||
const STATUS_DEADLOCKED = 'deadlocked';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a human readable name for a build status constant.
|
|
||||||
*
|
|
||||||
* @param const Build status constant.
|
|
||||||
* @return string Human-readable name.
|
|
||||||
*/
|
|
||||||
public static function getBuildStatusName($status) {
|
|
||||||
$map = self::getBuildStatusMap();
|
|
||||||
return idx($map, $status, pht('Unknown ("%s")', $status));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getBuildStatusMap() {
|
|
||||||
return array(
|
|
||||||
self::STATUS_INACTIVE => pht('Inactive'),
|
|
||||||
self::STATUS_PENDING => pht('Pending'),
|
|
||||||
self::STATUS_BUILDING => pht('Building'),
|
|
||||||
self::STATUS_PASSED => pht('Passed'),
|
|
||||||
self::STATUS_FAILED => pht('Failed'),
|
|
||||||
self::STATUS_ABORTED => pht('Aborted'),
|
|
||||||
self::STATUS_ERROR => pht('Unexpected Error'),
|
|
||||||
self::STATUS_PAUSED => pht('Paused'),
|
|
||||||
self::STATUS_DEADLOCKED => pht('Deadlocked'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getBuildStatusIcon($status) {
|
|
||||||
switch ($status) {
|
|
||||||
case self::STATUS_INACTIVE:
|
|
||||||
case self::STATUS_PENDING:
|
|
||||||
return PHUIStatusItemView::ICON_OPEN;
|
|
||||||
case self::STATUS_BUILDING:
|
|
||||||
return PHUIStatusItemView::ICON_RIGHT;
|
|
||||||
case self::STATUS_PASSED:
|
|
||||||
return PHUIStatusItemView::ICON_ACCEPT;
|
|
||||||
case self::STATUS_FAILED:
|
|
||||||
return PHUIStatusItemView::ICON_REJECT;
|
|
||||||
case self::STATUS_ABORTED:
|
|
||||||
return PHUIStatusItemView::ICON_MINUS;
|
|
||||||
case self::STATUS_ERROR:
|
|
||||||
return PHUIStatusItemView::ICON_MINUS;
|
|
||||||
case self::STATUS_PAUSED:
|
|
||||||
return PHUIStatusItemView::ICON_MINUS;
|
|
||||||
case self::STATUS_DEADLOCKED:
|
|
||||||
return PHUIStatusItemView::ICON_WARNING;
|
|
||||||
default:
|
|
||||||
return PHUIStatusItemView::ICON_QUESTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getBuildStatusColor($status) {
|
|
||||||
switch ($status) {
|
|
||||||
case self::STATUS_INACTIVE:
|
|
||||||
return 'dark';
|
|
||||||
case self::STATUS_PENDING:
|
|
||||||
case self::STATUS_BUILDING:
|
|
||||||
return 'blue';
|
|
||||||
case self::STATUS_PASSED:
|
|
||||||
return 'green';
|
|
||||||
case self::STATUS_FAILED:
|
|
||||||
case self::STATUS_ABORTED:
|
|
||||||
case self::STATUS_ERROR:
|
|
||||||
case self::STATUS_DEADLOCKED:
|
|
||||||
return 'red';
|
|
||||||
case self::STATUS_PAUSED:
|
|
||||||
return 'dark';
|
|
||||||
default:
|
|
||||||
return 'bluegrey';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function initializeNewBuild(PhabricatorUser $actor) {
|
public static function initializeNewBuild(PhabricatorUser $actor) {
|
||||||
return id(new HarbormasterBuild())
|
return id(new HarbormasterBuild())
|
||||||
->setBuildStatus(self::STATUS_INACTIVE)
|
->setBuildStatus(HarbormasterBuildStatus::STATUS_INACTIVE)
|
||||||
->setBuildGeneration(0);
|
->setBuildGeneration(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +104,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBuilding() {
|
public function isBuilding() {
|
||||||
return $this->getBuildStatus() === self::STATUS_PENDING ||
|
return
|
||||||
$this->getBuildStatus() === self::STATUS_BUILDING;
|
$this->getBuildStatus() === HarbormasterBuildStatus::STATUS_PENDING ||
|
||||||
|
$this->getBuildStatus() === HarbormasterBuildStatus::STATUS_BUILDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAutobuild() {
|
public function isAutobuild() {
|
||||||
|
@ -285,11 +170,11 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function isComplete() {
|
public function isComplete() {
|
||||||
switch ($this->getBuildStatus()) {
|
switch ($this->getBuildStatus()) {
|
||||||
case self::STATUS_PASSED:
|
case HarbormasterBuildStatus::STATUS_PASSED:
|
||||||
case self::STATUS_FAILED:
|
case HarbormasterBuildStatus::STATUS_FAILED:
|
||||||
case self::STATUS_ABORTED:
|
case HarbormasterBuildStatus::STATUS_ABORTED:
|
||||||
case self::STATUS_ERROR:
|
case HarbormasterBuildStatus::STATUS_ERROR:
|
||||||
case self::STATUS_PAUSED:
|
case HarbormasterBuildStatus::STATUS_PAUSED:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +182,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPaused() {
|
public function isPaused() {
|
||||||
return ($this->getBuildStatus() == self::STATUS_PAUSED);
|
return ($this->getBuildStatus() == HarbormasterBuildStatus::STATUS_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
|
|
|
@ -27,11 +27,11 @@ final class HarbormasterBuildStatusDatasource
|
||||||
private function buildResults() {
|
private function buildResults() {
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$status_map = HarbormasterBuild::getBuildStatusMap();
|
$status_map = HarbormasterBuildStatus::getBuildStatusMap();
|
||||||
foreach ($status_map as $value => $name) {
|
foreach ($status_map as $value => $name) {
|
||||||
$result = id(new PhabricatorTypeaheadResult())
|
$result = id(new PhabricatorTypeaheadResult())
|
||||||
->setIcon(HarbormasterBuild::getBuildStatusIcon($value))
|
->setIcon(HarbormasterBuildStatus::getBuildStatusIcon($value))
|
||||||
->setColor(HarbormasterBuild::getBuildStatusColor($value))
|
->setColor(HarbormasterBuildStatus::getBuildStatusColor($value))
|
||||||
->setPHID($value)
|
->setPHID($value)
|
||||||
->setName($name)
|
->setName($name)
|
||||||
->addAttribute(pht('Status'));
|
->addAttribute(pht('Status'));
|
||||||
|
|
Loading…
Reference in a new issue