mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
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:
parent
718cdc2447
commit
f97df9ebea
2 changed files with 33 additions and 4 deletions
|
@ -497,9 +497,33 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
// passed everything it needs to.
|
// passed everything it needs to.
|
||||||
|
|
||||||
if (!$buildable->isPreparing()) {
|
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;
|
$all_pass = true;
|
||||||
$any_fail = false;
|
$any_fail = false;
|
||||||
foreach ($buildable->getBuilds() as $build) {
|
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()) {
|
if (!$build->isPassed()) {
|
||||||
$all_pass = false;
|
$all_pass = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ final class HarbormasterBuildPlanBehavior
|
||||||
const DRAFTS_IF_BUILDING = 'building';
|
const DRAFTS_IF_BUILDING = 'building';
|
||||||
const DRAFTS_NEVER = 'never';
|
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) {
|
public function setKey($key) {
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -207,7 +212,7 @@ final class HarbormasterBuildPlanBehavior
|
||||||
|
|
||||||
$aggregate_options = array(
|
$aggregate_options = array(
|
||||||
id(new HarbormasterBuildPlanBehaviorOption())
|
id(new HarbormasterBuildPlanBehaviorOption())
|
||||||
->setKey('always')
|
->setKey(self::BUILDABLE_ALWAYS)
|
||||||
->setIcon('fa-check-circle-o green')
|
->setIcon('fa-check-circle-o green')
|
||||||
->setName(pht('Always'))
|
->setName(pht('Always'))
|
||||||
->setIsDefault(true)
|
->setIsDefault(true)
|
||||||
|
@ -216,7 +221,7 @@ final class HarbormasterBuildPlanBehavior
|
||||||
'The buildable waits for the build, and fails if the '.
|
'The buildable waits for the build, and fails if the '.
|
||||||
'build fails.')),
|
'build fails.')),
|
||||||
id(new HarbormasterBuildPlanBehaviorOption())
|
id(new HarbormasterBuildPlanBehaviorOption())
|
||||||
->setKey('building')
|
->setKey(self::BUILDABLE_IF_BUILDING)
|
||||||
->setIcon('fa-pause-circle-o yellow')
|
->setIcon('fa-pause-circle-o yellow')
|
||||||
->setName(pht('If Building'))
|
->setName(pht('If Building'))
|
||||||
->setDescription(
|
->setDescription(
|
||||||
|
@ -224,7 +229,7 @@ final class HarbormasterBuildPlanBehavior
|
||||||
'The buildable waits for the build, but does not fail '.
|
'The buildable waits for the build, but does not fail '.
|
||||||
'if the build fails.')),
|
'if the build fails.')),
|
||||||
id(new HarbormasterBuildPlanBehaviorOption())
|
id(new HarbormasterBuildPlanBehaviorOption())
|
||||||
->setKey('never')
|
->setKey(self::BUILDABLE_NEVER)
|
||||||
->setIcon('fa-circle-o red')
|
->setIcon('fa-circle-o red')
|
||||||
->setName(pht('Never'))
|
->setName(pht('Never'))
|
||||||
->setDescription(
|
->setDescription(
|
||||||
|
@ -310,7 +315,7 @@ final class HarbormasterBuildPlanBehavior
|
||||||
'this warning and continue, even if builds have failed.'))
|
'this warning and continue, even if builds have failed.'))
|
||||||
->setOptions($land_options),
|
->setOptions($land_options),
|
||||||
id(new self())
|
id(new self())
|
||||||
->setKey('buildable')
|
->setKey(self::BEHAVIOR_BUILDABLE)
|
||||||
->setEditInstructions(
|
->setEditInstructions(
|
||||||
pht(
|
pht(
|
||||||
'The overall state of a buildable (like a commit or revision) is '.
|
'The overall state of a buildable (like a commit or revision) is '.
|
||||||
|
|
Loading…
Reference in a new issue