Differential D7935 Diff 17980 src/applications/harbormaster/step/WaitForPreviousBuildStepImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/step/WaitForPreviousBuildStepImplementation.php
Show All 24 Lines | public function execute( | ||||
// We can only wait when building against commits. | // We can only wait when building against commits. | ||||
$buildable = $build->getBuildable(); | $buildable = $build->getBuildable(); | ||||
$object = $buildable->getBuildableObject(); | $object = $buildable->getBuildableObject(); | ||||
if (!($object instanceof PhabricatorRepositoryCommit)) { | if (!($object instanceof PhabricatorRepositoryCommit)) { | ||||
return; | return; | ||||
} | } | ||||
// We are blocked until all previous builds finish. | |||||
$build->setBuildStatus(HarbormasterBuild::STATUS_WAITING); | |||||
$build->save(); | |||||
hach-que: Why is this removed? This will mean the build will not display waiting information to the user. | |||||
Not Done Inline ActionsTwo reasons:
epriestley: Two reasons:
- I've removed all updates of `$build` from the actual steps. This avoids a… | |||||
// Block until all previous builds of the same build plan have | // Block until all previous builds of the same build plan have | ||||
// finished. | // finished. | ||||
$plan = $build->getBuildPlan(); | $plan = $build->getBuildPlan(); | ||||
$log = null; | $log = null; | ||||
$log_start = null; | $log_start = null; | ||||
$blockers = $this->getBlockers($object, $plan, $build); | $blockers = $this->getBlockers($object, $plan, $build); | ||||
while (count($blockers) > 0) { | while (count($blockers) > 0) { | ||||
if ($build->checkForCancellation()) { | |||||
if ($log !== null) { | |||||
$log->finalize($log_start); | |||||
} | |||||
return; | |||||
} | |||||
if ($log === null) { | if ($log === null) { | ||||
$log = $build->createLog($build_target, "waiting", "blockers"); | $log = $build->createLog($build_target, "waiting", "blockers"); | ||||
$log_start = $log->start(); | $log_start = $log->start(); | ||||
} | } | ||||
$log->append("Blocked by: ".implode(",", $blockers)."\n"); | $log->append("Blocked by: ".implode(",", $blockers)."\n"); | ||||
// TODO: This should fail temporarily instead after setting the target to | |||||
// waiting, and thereby push the build into a waiting status. | |||||
sleep(1); | sleep(1); | ||||
$blockers = $this->getBlockers($object, $plan, $build); | $blockers = $this->getBlockers($object, $plan, $build); | ||||
} | } | ||||
if ($log !== null) { | if ($log !== null) { | ||||
$log->finalize($log_start); | $log->finalize($log_start); | ||||
} | } | ||||
// Move back into building status. | |||||
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING); | |||||
$build->save(); | |||||
} | } | ||||
private function getBlockers( | private function getBlockers( | ||||
PhabricatorRepositoryCommit $commit, | PhabricatorRepositoryCommit $commit, | ||||
HarbormasterBuildPlan $plan, | HarbormasterBuildPlan $plan, | ||||
HarbormasterBuild $source) { | HarbormasterBuild $source) { | ||||
$call = new ConduitCall( | $call = new ConduitCall( | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |
Why is this removed? This will mean the build will not display waiting information to the user.