Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuild.php
Show All 36 Lines | final class HarbormasterBuild extends HarbormasterDAO | ||||
const STATUS_PASSED = 'passed'; | const STATUS_PASSED = 'passed'; | ||||
/** | /** | ||||
* The build has failed. | * The build has failed. | ||||
*/ | */ | ||||
const STATUS_FAILED = 'failed'; | const STATUS_FAILED = 'failed'; | ||||
/** | /** | ||||
* The build has aborted. | |||||
*/ | |||||
const STATUS_ABORTED = 'aborted'; | |||||
/** | |||||
* The build encountered an unexpected error. | * The build encountered an unexpected error. | ||||
*/ | */ | ||||
const STATUS_ERROR = 'error'; | const STATUS_ERROR = 'error'; | ||||
/** | /** | ||||
* The build has been stopped. | * The build has been stopped. | ||||
*/ | */ | ||||
const STATUS_STOPPED = 'stopped'; | const STATUS_STOPPED = 'stopped'; | ||||
Show All 17 Lines | switch ($status) { | ||||
case self::STATUS_PENDING: | case self::STATUS_PENDING: | ||||
return pht('Pending'); | return pht('Pending'); | ||||
case self::STATUS_BUILDING: | case self::STATUS_BUILDING: | ||||
return pht('Building'); | return pht('Building'); | ||||
case self::STATUS_PASSED: | case self::STATUS_PASSED: | ||||
return pht('Passed'); | return pht('Passed'); | ||||
case self::STATUS_FAILED: | case self::STATUS_FAILED: | ||||
return pht('Failed'); | return pht('Failed'); | ||||
case self::STATUS_ABORTED: | |||||
return pht('Aborted'); | |||||
case self::STATUS_ERROR: | case self::STATUS_ERROR: | ||||
return pht('Unexpected Error'); | return pht('Unexpected Error'); | ||||
case self::STATUS_STOPPED: | case self::STATUS_STOPPED: | ||||
return pht('Paused'); | return pht('Paused'); | ||||
case self::STATUS_DEADLOCKED: | case self::STATUS_DEADLOCKED: | ||||
return pht('Deadlocked'); | return pht('Deadlocked'); | ||||
default: | default: | ||||
return pht('Unknown'); | return pht('Unknown'); | ||||
} | } | ||||
} | } | ||||
public static function getBuildStatusIcon($status) { | public static function getBuildStatusIcon($status) { | ||||
switch ($status) { | switch ($status) { | ||||
case self::STATUS_INACTIVE: | case self::STATUS_INACTIVE: | ||||
case self::STATUS_PENDING: | case self::STATUS_PENDING: | ||||
return PHUIStatusItemView::ICON_OPEN; | return PHUIStatusItemView::ICON_OPEN; | ||||
case self::STATUS_BUILDING: | case self::STATUS_BUILDING: | ||||
return PHUIStatusItemView::ICON_RIGHT; | return PHUIStatusItemView::ICON_RIGHT; | ||||
case self::STATUS_PASSED: | case self::STATUS_PASSED: | ||||
return PHUIStatusItemView::ICON_ACCEPT; | return PHUIStatusItemView::ICON_ACCEPT; | ||||
case self::STATUS_FAILED: | case self::STATUS_FAILED: | ||||
return PHUIStatusItemView::ICON_REJECT; | return PHUIStatusItemView::ICON_REJECT; | ||||
case self::STATUS_ABORTED: | |||||
return PHUIStatusItemView::ICON_MINUS; | |||||
case self::STATUS_ERROR: | case self::STATUS_ERROR: | ||||
return PHUIStatusItemView::ICON_MINUS; | return PHUIStatusItemView::ICON_MINUS; | ||||
case self::STATUS_STOPPED: | case self::STATUS_STOPPED: | ||||
return PHUIStatusItemView::ICON_MINUS; | return PHUIStatusItemView::ICON_MINUS; | ||||
case self::STATUS_DEADLOCKED: | case self::STATUS_DEADLOCKED: | ||||
return PHUIStatusItemView::ICON_WARNING; | return PHUIStatusItemView::ICON_WARNING; | ||||
default: | default: | ||||
return PHUIStatusItemView::ICON_QUESTION; | return PHUIStatusItemView::ICON_QUESTION; | ||||
} | } | ||||
} | } | ||||
public static function getBuildStatusColor($status) { | public static function getBuildStatusColor($status) { | ||||
switch ($status) { | switch ($status) { | ||||
case self::STATUS_INACTIVE: | case self::STATUS_INACTIVE: | ||||
return 'dark'; | return 'dark'; | ||||
case self::STATUS_PENDING: | case self::STATUS_PENDING: | ||||
case self::STATUS_BUILDING: | case self::STATUS_BUILDING: | ||||
return 'blue'; | return 'blue'; | ||||
case self::STATUS_PASSED: | case self::STATUS_PASSED: | ||||
return 'green'; | return 'green'; | ||||
case self::STATUS_FAILED: | case self::STATUS_FAILED: | ||||
case self::STATUS_ABORTED: | |||||
case self::STATUS_ERROR: | case self::STATUS_ERROR: | ||||
case self::STATUS_DEADLOCKED: | case self::STATUS_DEADLOCKED: | ||||
return 'red'; | return 'red'; | ||||
case self::STATUS_STOPPED: | case self::STATUS_STOPPED: | ||||
return 'dark'; | return 'dark'; | ||||
default: | default: | ||||
return 'bluegrey'; | return 'bluegrey'; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | public static function getAvailableBuildVariables() { | ||||
$variables = array_mergev($variables); | $variables = array_mergev($variables); | ||||
return $variables; | return $variables; | ||||
} | } | ||||
public function isComplete() { | public function isComplete() { | ||||
switch ($this->getBuildStatus()) { | switch ($this->getBuildStatus()) { | ||||
case self::STATUS_PASSED: | case self::STATUS_PASSED: | ||||
case self::STATUS_FAILED: | case self::STATUS_FAILED: | ||||
case self::STATUS_ABORTED: | |||||
case self::STATUS_ERROR: | case self::STATUS_ERROR: | ||||
case self::STATUS_STOPPED: | case self::STATUS_STOPPED: | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
Show All 19 Lines | /* -( Build Commands )----------------------------------------------------- */ | ||||
} | } | ||||
public function canStopBuild() { | public function canStopBuild() { | ||||
return !$this->isComplete() && | return !$this->isComplete() && | ||||
!$this->isStopped() && | !$this->isStopped() && | ||||
!$this->isStopping(); | !$this->isStopping(); | ||||
} | } | ||||
public function canAbortBuild() { | |||||
epriestley: Prevent abort of automatic builds, as other methods now do. | |||||
return !$this->isComplete(); | |||||
} | |||||
public function canResumeBuild() { | public function canResumeBuild() { | ||||
return $this->isStopped() && | return $this->isStopped() && | ||||
!$this->isResuming(); | !$this->isResuming(); | ||||
} | } | ||||
public function isStopping() { | public function isStopping() { | ||||
$is_stopping = false; | $is_stopping = false; | ||||
foreach ($this->getUnprocessedCommands() as $command_object) { | foreach ($this->getUnprocessedCommands() as $command_object) { | ||||
$command = $command_object->getCommand(); | $command = $command_object->getCommand(); | ||||
switch ($command) { | switch ($command) { | ||||
case HarbormasterBuildCommand::COMMAND_STOP: | case HarbormasterBuildCommand::COMMAND_STOP: | ||||
$is_stopping = true; | $is_stopping = true; | ||||
break; | break; | ||||
case HarbormasterBuildCommand::COMMAND_RESUME: | case HarbormasterBuildCommand::COMMAND_RESUME: | ||||
case HarbormasterBuildCommand::COMMAND_RESTART: | case HarbormasterBuildCommand::COMMAND_RESTART: | ||||
$is_stopping = false; | $is_stopping = false; | ||||
break; | break; | ||||
case HarbormasterBuildCommand::COMMAND_ABORT: | |||||
$is_stopping = true; | |||||
break; | |||||
} | } | ||||
} | } | ||||
return $is_stopping; | return $is_stopping; | ||||
} | } | ||||
public function isResuming() { | public function isResuming() { | ||||
$is_resuming = false; | $is_resuming = false; | ||||
foreach ($this->getUnprocessedCommands() as $command_object) { | foreach ($this->getUnprocessedCommands() as $command_object) { | ||||
$command = $command_object->getCommand(); | $command = $command_object->getCommand(); | ||||
switch ($command) { | switch ($command) { | ||||
case HarbormasterBuildCommand::COMMAND_RESTART: | case HarbormasterBuildCommand::COMMAND_RESTART: | ||||
case HarbormasterBuildCommand::COMMAND_RESUME: | case HarbormasterBuildCommand::COMMAND_RESUME: | ||||
$is_resuming = true; | $is_resuming = true; | ||||
break; | break; | ||||
case HarbormasterBuildCommand::COMMAND_STOP: | case HarbormasterBuildCommand::COMMAND_STOP: | ||||
$is_resuming = false; | $is_resuming = false; | ||||
break; | break; | ||||
case HarbormasterBuildCommand::COMMAND_ABORT: | |||||
$is_resuming = false; | |||||
break; | |||||
} | } | ||||
} | } | ||||
return $is_resuming; | return $is_resuming; | ||||
} | } | ||||
public function isRestarting() { | public function isRestarting() { | ||||
$is_restarting = false; | $is_restarting = false; | ||||
foreach ($this->getUnprocessedCommands() as $command_object) { | foreach ($this->getUnprocessedCommands() as $command_object) { | ||||
$command = $command_object->getCommand(); | $command = $command_object->getCommand(); | ||||
switch ($command) { | switch ($command) { | ||||
case HarbormasterBuildCommand::COMMAND_RESTART: | case HarbormasterBuildCommand::COMMAND_RESTART: | ||||
$is_restarting = true; | $is_restarting = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return $is_restarting; | return $is_restarting; | ||||
} | } | ||||
public function isAborting() { | |||||
$is_aborting = false; | |||||
foreach ($this->getUnprocessedCommands() as $command_object) { | |||||
$command = $command_object->getCommand(); | |||||
switch ($command) { | |||||
case HarbormasterBuildCommand::COMMAND_ABORT: | |||||
$is_aborting = true; | |||||
break; | |||||
} | |||||
} | |||||
return $is_aborting; | |||||
} | |||||
public function deleteUnprocessedCommands() { | public function deleteUnprocessedCommands() { | ||||
foreach ($this->getUnprocessedCommands() as $key => $command_object) { | foreach ($this->getUnprocessedCommands() as $key => $command_object) { | ||||
$command_object->delete(); | $command_object->delete(); | ||||
unset($this->unprocessedCommands[$key]); | unset($this->unprocessedCommands[$key]); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
Prevent abort of automatic builds, as other methods now do.