Implement Build Plan behavior "Affects Buildable"
Summary: Ref T13258. Make the "Affects Buildable" option actually work.
Test Plan:
- As in previous change, created a "wait for HTTP request" build plan and had it always run against every revision.
- Created revisions, waited a bit, then sent the build a "Fail" message, with different values of "Affects Buildable":
- "Always": Same behavior as today. Buildable waited for the build, then failed when it failed.
- "While Building": Buildable waited for the build, but passed even though it failed (buildable has green checkmark even though build is red):
{F6250359}
- "Never": Buildable passed immediately (buildable has green checkmark even though build is still running):
{F6250360}
Reviewers: amckinley
Reviewed By: amckinley
Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam
Maniphest Tasks: T13258
Differential Revision: https://secure.phabricator.com/D20233
This commit is contained in:
@@ -497,9 +497,33 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||
// passed everything it needs to.
|
||||
|
||||
if (!$buildable->isPreparing()) {
|
||||
$behavior_key = HarbormasterBuildPlanBehavior::BEHAVIOR_BUILDABLE;
|
||||
$behavior = HarbormasterBuildPlanBehavior::getBehavior($behavior_key);
|
||||
|
||||
$key_never = HarbormasterBuildPlanBehavior::BUILDABLE_NEVER;
|
||||
$key_building = HarbormasterBuildPlanBehavior::BUILDABLE_IF_BUILDING;
|
||||
|
||||
$all_pass = true;
|
||||
$any_fail = false;
|
||||
foreach ($buildable->getBuilds() as $build) {
|
||||
$plan = $build->getBuildPlan();
|
||||
$option = $behavior->getPlanOption($plan);
|
||||
$option_key = $option->getKey();
|
||||
|
||||
$is_never = ($option_key === $key_never);
|
||||
$is_building = ($option_key === $key_building);
|
||||
|
||||
// If this build "Never" affects the buildable, ignore it.
|
||||
if ($is_never) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this build affects the buildable "If Building", but is already
|
||||
// complete, ignore it.
|
||||
if ($is_building && $build->isComplete()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$build->isPassed()) {
|
||||
$all_pass = false;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ final class HarbormasterBuildPlanBehavior
|
||||
const DRAFTS_IF_BUILDING = 'building';
|
||||
const DRAFTS_NEVER = 'never';
|
||||
|
||||
const BEHAVIOR_BUILDABLE = 'buildable';
|
||||
const BUILDABLE_ALWAYS = 'always';
|
||||
const BUILDABLE_IF_BUILDING = 'building';
|
||||
const BUILDABLE_NEVER = 'never';
|
||||
|
||||
public function setKey($key) {
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
@@ -207,7 +212,7 @@ final class HarbormasterBuildPlanBehavior
|
||||
|
||||
$aggregate_options = array(
|
||||
id(new HarbormasterBuildPlanBehaviorOption())
|
||||
->setKey('always')
|
||||
->setKey(self::BUILDABLE_ALWAYS)
|
||||
->setIcon('fa-check-circle-o green')
|
||||
->setName(pht('Always'))
|
||||
->setIsDefault(true)
|
||||
@@ -216,7 +221,7 @@ final class HarbormasterBuildPlanBehavior
|
||||
'The buildable waits for the build, and fails if the '.
|
||||
'build fails.')),
|
||||
id(new HarbormasterBuildPlanBehaviorOption())
|
||||
->setKey('building')
|
||||
->setKey(self::BUILDABLE_IF_BUILDING)
|
||||
->setIcon('fa-pause-circle-o yellow')
|
||||
->setName(pht('If Building'))
|
||||
->setDescription(
|
||||
@@ -224,7 +229,7 @@ final class HarbormasterBuildPlanBehavior
|
||||
'The buildable waits for the build, but does not fail '.
|
||||
'if the build fails.')),
|
||||
id(new HarbormasterBuildPlanBehaviorOption())
|
||||
->setKey('never')
|
||||
->setKey(self::BUILDABLE_NEVER)
|
||||
->setIcon('fa-circle-o red')
|
||||
->setName(pht('Never'))
|
||||
->setDescription(
|
||||
@@ -310,7 +315,7 @@ final class HarbormasterBuildPlanBehavior
|
||||
'this warning and continue, even if builds have failed.'))
|
||||
->setOptions($land_options),
|
||||
id(new self())
|
||||
->setKey('buildable')
|
||||
->setKey(self::BEHAVIOR_BUILDABLE)
|
||||
->setEditInstructions(
|
||||
pht(
|
||||
'The overall state of a buildable (like a commit or revision) is '.
|
||||
|
||||
Reference in New Issue
Block a user