Skip to content

Commit 776caa5

Browse files
author
epriestley
committed
Modularize the Harbormaster "Run build plan" Herald action
Ref T8726. Modularizes "Run build plan" in Differential and Diffusion.
1 parent fdd379a commit 776caa5

File tree

11 files changed

+225
-86
lines changed

11 files changed

+225
-86
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
UPDATE {$NAMESPACE}_herald.herald_action a
2+
JOIN {$NAMESPACE}_herald.herald_rule r
3+
ON a.ruleID = r.id
4+
SET a.action = 'harbormaster.build'
5+
WHERE r.ruleType != 'personal'
6+
AND a.action = 'applybuildplans';

src/__phutil_library_map__.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@
963963
'HarbormasterBuildWorker' => 'applications/harbormaster/worker/HarbormasterBuildWorker.php',
964964
'HarbormasterBuildable' => 'applications/harbormaster/storage/HarbormasterBuildable.php',
965965
'HarbormasterBuildableActionController' => 'applications/harbormaster/controller/HarbormasterBuildableActionController.php',
966+
'HarbormasterBuildableAdapterInterface' => 'applications/harbormaster/herald/HarbormasterBuildableAdapterInterface.php',
966967
'HarbormasterBuildableInterface' => 'applications/harbormaster/interface/HarbormasterBuildableInterface.php',
967968
'HarbormasterBuildableListController' => 'applications/harbormaster/controller/HarbormasterBuildableListController.php',
968969
'HarbormasterBuildablePHIDType' => 'applications/harbormaster/phid/HarbormasterBuildablePHIDType.php',
@@ -996,6 +997,7 @@
996997
'HarbormasterQueryBuildablesConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildablesConduitAPIMethod.php',
997998
'HarbormasterQueryBuildsConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php',
998999
'HarbormasterRemarkupRule' => 'applications/harbormaster/remarkup/HarbormasterRemarkupRule.php',
1000+
'HarbormasterRunBuildPlansHeraldAction' => 'applications/harbormaster/herald/HarbormasterRunBuildPlansHeraldAction.php',
9991001
'HarbormasterSchemaSpec' => 'applications/harbormaster/storage/HarbormasterSchemaSpec.php',
10001002
'HarbormasterScratchTable' => 'applications/harbormaster/storage/HarbormasterScratchTable.php',
10011003
'HarbormasterSendMessageConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterSendMessageConduitAPIMethod.php',
@@ -4703,6 +4705,7 @@
47034705
'HarbormasterQueryBuildablesConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
47044706
'HarbormasterQueryBuildsConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
47054707
'HarbormasterRemarkupRule' => 'PhabricatorObjectRemarkupRule',
4708+
'HarbormasterRunBuildPlansHeraldAction' => 'HeraldAction',
47064709
'HarbormasterSchemaSpec' => 'PhabricatorConfigSchemaSpec',
47074710
'HarbormasterScratchTable' => 'HarbormasterDAO',
47084711
'HarbormasterSendMessageConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
@@ -4728,7 +4731,10 @@
47284731
'HeraldApplicationActionGroup' => 'HeraldActionGroup',
47294732
'HeraldApplyTranscript' => 'Phobject',
47304733
'HeraldBasicFieldGroup' => 'HeraldFieldGroup',
4731-
'HeraldCommitAdapter' => 'HeraldAdapter',
4734+
'HeraldCommitAdapter' => array(
4735+
'HeraldAdapter',
4736+
'HarbormasterBuildableAdapterInterface',
4737+
),
47324738
'HeraldCondition' => 'HeraldDAO',
47334739
'HeraldConditionTranscript' => 'Phobject',
47344740
'HeraldContentSourceField' => 'HeraldField',
@@ -4737,7 +4743,10 @@
47374743
'HeraldDAO' => 'PhabricatorLiskDAO',
47384744
'HeraldDifferentialAdapter' => 'HeraldAdapter',
47394745
'HeraldDifferentialDiffAdapter' => 'HeraldDifferentialAdapter',
4740-
'HeraldDifferentialRevisionAdapter' => 'HeraldDifferentialAdapter',
4746+
'HeraldDifferentialRevisionAdapter' => array(
4747+
'HeraldDifferentialAdapter',
4748+
'HarbormasterBuildableAdapterInterface',
4749+
),
47414750
'HeraldDisableController' => 'HeraldController',
47424751
'HeraldDoNothingAction' => 'HeraldAction',
47434752
'HeraldEditFieldGroup' => 'HeraldFieldGroup',

src/applications/audit/editor/PhabricatorAuditEditor.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,6 @@ protected function didApplyHeraldRules(
901901
'auditReasonMap', $this->auditReasonMap);
902902
}
903903

904-
HarbormasterBuildable::applyBuildPlans(
905-
$object->getPHID(),
906-
$object->getRepository()->getPHID(),
907-
$adapter->getBuildPlans());
908-
909904
$limit = self::MAX_FILES_SHOWN_IN_EMAIL;
910905
$files = $adapter->loadAffectedPaths();
911906
sort($files);

src/applications/differential/editor/DifferentialTransactionEditor.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,20 +1591,6 @@ protected function buildHeraldAdapter(
15911591
return $adapter;
15921592
}
15931593

1594-
protected function didApplyHeraldRules(
1595-
PhabricatorLiskDAO $object,
1596-
HeraldAdapter $adapter,
1597-
HeraldTranscript $transcript) {
1598-
1599-
// Apply build plans.
1600-
HarbormasterBuildable::applyBuildPlans(
1601-
$adapter->getDiff()->getPHID(),
1602-
$adapter->getPHID(),
1603-
$adapter->getBuildPlans());
1604-
1605-
return array();
1606-
}
1607-
16081594
/**
16091595
* Update the table which links Differential revisions to paths they affect,
16101596
* so Diffusion can efficiently find pending revisions for a given file.

src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22

33
final class HeraldDifferentialRevisionAdapter
4-
extends HeraldDifferentialAdapter {
4+
extends HeraldDifferentialAdapter
5+
implements HarbormasterBuildableAdapterInterface {
56

67
protected $revision;
78

8-
protected $buildPlans = array();
9-
109
protected $affectedPackages;
1110
protected $changesets;
1211
private $haveHunks;
1312

13+
private $buildPlanPHIDs = array();
14+
1415
public function getAdapterApplicationClass() {
1516
return 'PhabricatorDifferentialApplication';
1617
}
@@ -79,10 +80,6 @@ public static function newLegacyAdapter(
7980
return $object;
8081
}
8182

82-
public function getBuildPlans() {
83-
return $this->buildPlans;
84-
}
85-
8683
public function getHeraldName() {
8784
return $this->revision->getTitle();
8885
}
@@ -130,44 +127,24 @@ public function loadReviewers() {
130127
return mpull($reviewers, 'getReviewerPHID');
131128
}
132129

133-
public function getActions($rule_type) {
134-
switch ($rule_type) {
135-
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
136-
return array_merge(
137-
array(
138-
self::ACTION_APPLY_BUILD_PLANS,
139-
),
140-
parent::getActions($rule_type));
141-
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
142-
return array_merge(
143-
array(),
144-
parent::getActions($rule_type));
145-
}
130+
131+
/* -( HarbormasterBuildableAdapterInterface )------------------------------ */
132+
133+
134+
public function getHarbormasterBuildablePHID() {
135+
return $this->getDiff()->getPHID();
146136
}
147137

148-
public function applyHeraldEffects(array $effects) {
149-
assert_instances_of($effects, 'HeraldEffect');
150-
151-
$result = array();
152-
153-
foreach ($effects as $effect) {
154-
$action = $effect->getAction();
155-
switch ($action) {
156-
case self::ACTION_APPLY_BUILD_PLANS:
157-
foreach ($effect->getTarget() as $phid) {
158-
$this->buildPlans[] = $phid;
159-
}
160-
$result[] = new HeraldApplyTranscript(
161-
$effect,
162-
true,
163-
pht('Applied build plans.'));
164-
break;
165-
default:
166-
$result[] = $this->applyStandardEffect($effect);
167-
break;
168-
}
169-
}
170-
return $result;
138+
public function getHarbormasterContainerPHID() {
139+
return $this->getObject()->getPHID();
140+
}
141+
142+
public function getQueuedHarbormasterBuildPlanPHIDs() {
143+
return $this->buildPlanPHIDs;
144+
}
145+
146+
public function queueHarbormasterBuildPlanPHID($phid) {
147+
$this->buildPlanPHIDs[] = $phid;
171148
}
172149

173150
}

src/applications/diffusion/herald/HeraldCommitAdapter.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
final class HeraldCommitAdapter extends HeraldAdapter {
3+
final class HeraldCommitAdapter
4+
extends HeraldAdapter
5+
implements HarbormasterBuildableAdapterInterface {
46

57
protected $diff;
68
protected $revision;
@@ -11,13 +13,14 @@ final class HeraldCommitAdapter extends HeraldAdapter {
1113
private $commitDiff;
1214

1315
protected $auditMap = array();
14-
protected $buildPlans = array();
1516

1617
protected $affectedPaths;
1718
protected $affectedRevision;
1819
protected $affectedPackages;
1920
protected $auditNeededPackages;
2021

22+
private $buildPlanPHIDs = array();
23+
2124
public function getAdapterApplicationClass() {
2225
return 'PhabricatorDiffusionApplication';
2326
}
@@ -90,7 +93,6 @@ public function getActions($rule_type) {
9093
return array_merge(
9194
array(
9295
self::ACTION_AUDIT,
93-
self::ACTION_APPLY_BUILD_PLANS,
9496
),
9597
parent::getActions($rule_type));
9698
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
@@ -151,10 +153,6 @@ public function getAuditMap() {
151153
return $this->auditMap;
152154
}
153155

154-
public function getBuildPlans() {
155-
return $this->buildPlans;
156-
}
157-
158156
public function getHeraldName() {
159157
return
160158
'r'.
@@ -343,15 +341,6 @@ public function applyHeraldEffects(array $effects) {
343341
true,
344342
pht('Triggered an audit.'));
345343
break;
346-
case self::ACTION_APPLY_BUILD_PLANS:
347-
foreach ($effect->getTarget() as $phid) {
348-
$this->buildPlans[] = $phid;
349-
}
350-
$result[] = new HeraldApplyTranscript(
351-
$effect,
352-
true,
353-
pht('Applied build plans.'));
354-
break;
355344
default:
356345
$result[] = $this->applyStandardEffect($effect);
357346
break;
@@ -360,4 +349,24 @@ public function applyHeraldEffects(array $effects) {
360349
return $result;
361350
}
362351

352+
353+
/* -( HarbormasterBuildableAdapterInterface )------------------------------ */
354+
355+
356+
public function getHarbormasterBuildablePHID() {
357+
return $this->getObject()->getPHID();
358+
}
359+
360+
public function getHarbormasterContainerPHID() {
361+
return $this->getObject()->getRepository()->getPHID();
362+
}
363+
364+
public function getQueuedHarbormasterBuildPlanPHIDs() {
365+
return $this->buildPlanPHIDs;
366+
}
367+
368+
public function queueHarbormasterBuildPlanPHID($phid) {
369+
$this->buildPlanPHIDs[] = $phid;
370+
}
371+
363372
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
interface HarbormasterBuildableAdapterInterface {
4+
5+
public function getHarbormasterBuildablePHID();
6+
public function getHarbormasterContainerPHID();
7+
public function getQueuedHarbormasterBuildPlanPHIDs();
8+
public function queueHarbormasterBuildPlanPHID($phid);
9+
10+
}
11+
12+
// TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
13+
14+
15+
/* -( HarbormasterBuildableAdapterInterface )------------------------------ */
16+
/*
17+
18+
public function getHarbormasterBuildablePHID() {
19+
return $this->getObject()->getPHID();
20+
}
21+
22+
public function getHarbormasterContainerPHID() {
23+
return null;
24+
}
25+
26+
public function getQueuedHarbormasterBuildPlanPHIDs() {
27+
return $this->buildPlanPHIDs;
28+
}
29+
30+
public function queueHarbormasterBuildPlanPHID($phid) {
31+
$this->buildPlanPHIDs[] = $phid;
32+
}
33+
34+
*/

0 commit comments

Comments
 (0)