Page MenuHomePhabricator

D7501.id16909.diff

D7501.id16909.diff

diff --git a/src/applications/differential/editor/DifferentialRevisionEditor.php b/src/applications/differential/editor/DifferentialRevisionEditor.php
--- a/src/applications/differential/editor/DifferentialRevisionEditor.php
+++ b/src/applications/differential/editor/DifferentialRevisionEditor.php
@@ -273,6 +273,8 @@
$rem_ccs = $adapter->getCCsRemovedByHerald();
$blocking_reviewers = array_keys(
$adapter->getBlockingReviewersAddedByHerald());
+
+ $this->applyBuildPlans($revision, $adapter->getBuildPlans());
} else {
$sub = array(
'rev' => array(),
@@ -1104,5 +1106,31 @@
return $revision;
}
+ private function applyBuildPlans(
+ DifferentialRevision $revision,
+ array $plan_phids) {
+
+ if (count($plan_phids) === 0) {
+ return;
+ }
+
+ $buildable = HarbormasterBuildable::createOrLoadExisting(
+ PhabricatorUser::getOmnipotentUser(),
+ $revision->getPHID());
+
+ $plans = id(new HarbormasterBuildPlanQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($plan_phids)
+ ->execute();
+ foreach ($plans as $plan) {
+ $build = HarbormasterBuild::initializeNewBuild(
+ PhabricatorUser::getOmnipotentUser());
+ $build->setBuildablePHID($buildable->getPHID());
+ $build->setBuildPlanPHID($plan->getPHID());
+ $build->setBuildStatus(HarbormasterBuild::STATUS_PENDING);
+ $build->save();
+ }
+ }
+
}
diff --git a/src/applications/harbormaster/daemon/PhabricatorHarbormasterBuildDaemon.php b/src/applications/harbormaster/daemon/PhabricatorHarbormasterBuildDaemon.php
--- a/src/applications/harbormaster/daemon/PhabricatorHarbormasterBuildDaemon.php
+++ b/src/applications/harbormaster/daemon/PhabricatorHarbormasterBuildDaemon.php
@@ -14,6 +14,7 @@
->setViewer(PhabricatorUser::getOmnipotentUser())
->withBuildStatuses(array(HarbormasterBuild::STATUS_PENDING))
->needBuildPlans(true)
+ ->setLimit(1)
->executeOne();
if ($build === null) {
$this->sleep(15);
@@ -61,8 +62,6 @@
$build->save();
throw $e;
}
-
- $this->sleep(15);
}
}
diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php
--- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php
+++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php
@@ -31,6 +31,8 @@
foreach ($handles as $phid => $handle) {
$build_plan = $objects[$phid];
+ $handles[$phid]->setName($build_plan->getName());
+ $handles[$phid]->setURI('/harbormaster/plan/'.$build_plan->getID());
}
}
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php
--- a/src/applications/harbormaster/storage/HarbormasterBuildable.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php
@@ -20,6 +20,29 @@
->setBuildableStatus(self::STATUS_WHATEVER);
}
+ /**
+ * Returns an existing buildable for the object's PHID or creates a
+ * new buildable implicitly if needed.
+ */
+ public static function createOrLoadExisting(
+ PhabricatorUser $actor,
+ $buildable_object_phid) {
+
+ $buildable = id(new HarbormasterBuildableQuery())
+ ->setViewer($actor)
+ ->withBuildablePHIDs(array($buildable_object_phid))
+ ->executeOne();
+ if ($buildable) {
+ return $buildable;
+ }
+ $buildable = id(new HarbormasterBuildable())
+ ->setBuildStatus(self::STATUS_WHATEVER)
+ ->setBuildableStatus(self::STATUS_WHATEVER)
+ ->setBuildablePHID($buildable_object_phid);
+ $buildable->save();
+ return $buildable;
+ }
+
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -54,6 +54,7 @@
const ACTION_ADD_PROJECTS = 'addprojects';
const ACTION_ADD_REVIEWERS = 'addreviewers';
const ACTION_ADD_BLOCKING_REVIEWERS = 'addblockingreviewers';
+ const ACTION_APPLY_BUILD_PLANS = 'applybuildplans';
const VALUE_TEXT = 'text';
const VALUE_NONE = 'none';
@@ -67,6 +68,7 @@
const VALUE_FLAG_COLOR = 'flagcolor';
const VALUE_CONTENT_SOURCE = 'contentsource';
const VALUE_USER_OR_PROJECT = 'userorproject';
+ const VALUE_BUILD_PLAN = 'buildplan';
private $contentSource;
@@ -490,6 +492,7 @@
self::ACTION_ADD_PROJECTS => pht('Add projects'),
self::ACTION_ADD_REVIEWERS => pht('Add reviewers'),
self::ACTION_ADD_BLOCKING_REVIEWERS => pht('Add blocking reviewers'),
+ self::ACTION_APPLY_BUILD_PLANS => pht('Apply build plans'),
);
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
return array(
@@ -655,6 +658,8 @@
case self::ACTION_ADD_REVIEWERS:
case self::ACTION_ADD_BLOCKING_REVIEWERS:
return self::VALUE_USER_OR_PROJECT;
+ case self::ACTION_APPLY_BUILD_PLANS:
+ return self::VALUE_BUILD_PLAN;
default:
throw new Exception("Unknown or invalid action '{$action}'.");
}
diff --git a/src/applications/herald/adapter/HeraldCommitAdapter.php b/src/applications/herald/adapter/HeraldCommitAdapter.php
--- a/src/applications/herald/adapter/HeraldCommitAdapter.php
+++ b/src/applications/herald/adapter/HeraldCommitAdapter.php
@@ -22,6 +22,7 @@
protected $emailPHIDs = array();
protected $addCCPHIDs = array();
protected $auditMap = array();
+ protected $buildPlans = array();
protected $affectedPaths;
protected $affectedRevision;
@@ -120,7 +121,8 @@
self::ACTION_ADD_CC,
self::ACTION_EMAIL,
self::ACTION_AUDIT,
- self::ACTION_NOTHING,
+ self::ACTION_APPLY_BUILD_PLANS,
+ self::ACTION_NOTHING
);
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
return array(
@@ -176,6 +178,10 @@
return $this->auditMap;
}
+ public function getBuildPlans() {
+ return $this->buildPlans;
+ }
+
public function getHeraldName() {
return
'r'.
@@ -422,6 +428,15 @@
true,
pht('Triggered an audit.'));
break;
+ case self::ACTION_APPLY_BUILD_PLANS:
+ foreach ($effect->getTarget() as $phid) {
+ $this->buildPlans[] = $phid;
+ }
+ $result[] = new HeraldApplyTranscript(
+ $effect,
+ true,
+ pht('Applied build plans.'));
+ break;
case self::ACTION_FLAG:
$result[] = parent::applyFlagEffect(
$effect,
diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
--- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
+++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
@@ -14,6 +14,7 @@
protected $emailPHIDs = array();
protected $addReviewerPHIDs = array();
protected $blockingReviewerPHIDs = array();
+ protected $buildPlans = array();
protected $repository;
protected $affectedPackages;
@@ -117,6 +118,10 @@
return $this->blockingReviewerPHIDs;
}
+ public function getBuildPlans() {
+ return $this->buildPlans;
+ }
+
public function getPHID() {
return $this->revision->getPHID();
}
@@ -349,6 +354,7 @@
self::ACTION_EMAIL,
self::ACTION_ADD_REVIEWERS,
self::ACTION_ADD_BLOCKING_REVIEWERS,
+ self::ACTION_APPLY_BUILD_PLANS,
self::ACTION_NOTHING,
);
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
@@ -468,6 +474,15 @@
true,
pht('Added blocking reviewers.'));
break;
+ case self::ACTION_APPLY_BUILD_PLANS:
+ foreach ($effect->getTarget() as $phid) {
+ $this->buildPlans[] = $phid;
+ }
+ $result[] = new HeraldApplyTranscript(
+ $effect,
+ true,
+ pht('Applied build plans.'));
+ break;
default:
throw new Exception("No rules to handle action '{$action}'.");
}
diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php
--- a/src/applications/herald/controller/HeraldRuleController.php
+++ b/src/applications/herald/controller/HeraldRuleController.php
@@ -511,6 +511,7 @@
'package' => '/typeahead/common/packages/',
'project' => '/typeahead/common/projects/',
'userorproject' => '/typeahead/common/accountsorprojects/',
+ 'buildplan' => '/typeahead/common/buildplans/',
),
'markup' => $template,
);
diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php
--- a/src/applications/phid/PhabricatorPHIDConstants.php
+++ b/src/applications/phid/PhabricatorPHIDConstants.php
@@ -19,6 +19,7 @@
const PHID_TYPE_CHRG = 'CHRG';
const PHID_TYPE_CART = 'CART';
const PHID_TYPE_LEGB = 'LEGB';
+ const PHID_TYPE_HMCP = 'HMCP';
const PHID_TYPE_XCMT = 'XCMT';
diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
--- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
+++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
@@ -66,6 +66,8 @@
$this->createAudits($commit, $audit_phids, $cc_phids, $rules);
}
+ $this->applyBuildPlans($commit, $adapter->getBuildPlans());
+
$explicit_auditors = $this->createAuditsFromCommitMessage($commit, $data);
if ($repository->getDetail('herald-disabled')) {
@@ -194,6 +196,32 @@
}
}
+ private function applyBuildPlans(
+ PhabricatorRepositoryCommit $commit,
+ array $plan_phids) {
+
+ if (count($plan_phids) === 0) {
+ return;
+ }
+
+ $buildable = HarbormasterBuildable::createOrLoadExisting(
+ PhabricatorUser::getOmnipotentUser(),
+ $commit->getPHID());
+
+ $plans = id(new HarbormasterBuildPlanQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($plan_phids)
+ ->execute();
+ foreach ($plans as $plan) {
+ $build = HarbormasterBuild::initializeNewBuild(
+ PhabricatorUser::getOmnipotentUser());
+ $build->setBuildablePHID($buildable->getPHID());
+ $build->setBuildPlanPHID($plan->getPHID());
+ $build->setBuildStatus(HarbormasterBuild::STATUS_PENDING);
+ $build->save();
+ }
+ }
+
private function createAudits(
PhabricatorRepositoryCommit $commit,
array $map,
diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
--- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
+++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
@@ -35,6 +35,7 @@
$need_noproject = false;
$need_symbols = false;
$need_jump_objects = false;
+ $need_build_plans = false;
switch ($this->type) {
case 'mainsearch':
$need_users = true;
@@ -93,6 +94,9 @@
case 'arcanistprojects':
$need_arcanist_projects = true;
break;
+ case 'buildplans':
+ $need_build_plans = true;
+ break;
}
$results = array();
@@ -219,6 +223,17 @@
}
}
+ if ($need_build_plans) {
+ $plans = id(new HarbormasterBuildPlanQuery())
+ ->setViewer($viewer)
+ ->execute();
+ foreach ($plans as $plan) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($plan->getName())
+ ->setPHID($plan->getPHID());
+ }
+ }
+
if ($need_projs) {
$projs = id(new PhabricatorProjectQuery())
->setViewer($viewer)
diff --git a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
--- a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
+++ b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
@@ -221,6 +221,7 @@
case 'package':
case 'project':
case 'userorproject':
+ case 'buildplan':
var tokenizer = this._newTokenizer(type);
input = tokenizer[0];
get_fn = tokenizer[1];

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/ny/yf/cp263t66gsh6qaos
Default Alt Text
D7501.id16909.diff (12 KB)

Event Timeline