1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Allow Harbormaster builds to publish to a different object

Summary:
Fixes T9276. Fixes T8650. The story so far:

  - We once published build updates to Revisions.
  - An unrelated fix (D10911) sent them to the Diffs instead of Revisions, which isn't useful, since you can't see a diff's timeline anywhere.
  - This also caused a race condition, where the RevisionEditor and DiffEditor would update the diff simultaneously (T8650).
  - The diff update was just disabled to avoid the race (part of D13441).
  - Instead, allow the updates to go somewhere else. In this case, we send commit updates to the commit but send diff updates to the revision so you can see 'em.
  - Since everything will be using the revision editor now, we should either get proper lock behavior for free or it should be easy to add if something whack is still happening.
  - Overall, this should pretty much put us back in working order like we were before D10911.

This behavior is undoubtedly refinable, but this should let us move forward.

Test Plan:
Saw a build failure in timeline:

{F2304575}

Reviewers: chad

Reviewed By: chad

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T9276, T8650

Differential Revision: https://secure.phabricator.com/D17139
This commit is contained in:
epriestley 2017-01-04 11:31:44 -08:00
parent e9243f22b9
commit ef05bf335d
6 changed files with 49 additions and 7 deletions

View file

@ -502,6 +502,10 @@ final class DifferentialDiff
return null;
}
public function getHarbormasterPublishablePHID() {
return $this->getHarbormasterContainerPHID();
}
public function getBuildVariables() {
$results = array();

View file

@ -513,6 +513,10 @@ final class DifferentialRevision extends DifferentialDAO
return $this->getPHID();
}
public function getHarbormasterPublishablePHID() {
return $this->getPHID();
}
public function getBuildVariables() {
return array();
}

View file

@ -497,17 +497,28 @@ final class HarbormasterBuildEngine extends Phobject {
return;
}
if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
$publish_phid = $object->getHarbormasterPublishablePHID();
if (!$publish_phid) {
return;
}
// TODO: Publishing these transactions is causing a race. See T8650.
// We shouldn't be publishing to diffs anyway.
if ($object instanceof DifferentialDiff) {
if ($publish_phid === $object->getPHID()) {
$publish = $object;
} else {
$publish = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->withPHIDs(array($publish_phid))
->executeOne();
if (!$publish) {
return;
}
}
if (!($publish instanceof PhabricatorApplicationTransactionInterface)) {
return;
}
$template = $object->getApplicationTransactionTemplate();
$template = $publish->getApplicationTransactionTemplate();
if (!$template) {
return;
}
@ -526,7 +537,7 @@ final class HarbormasterBuildEngine extends Phobject {
$daemon_source = PhabricatorContentSource::newForSource(
PhabricatorDaemonContentSource::SOURCECONST);
$editor = $object->getApplicationTransactionEditor()
$editor = $publish->getApplicationTransactionEditor()
->setActor($viewer)
->setActingAsPHID($harbormaster_phid)
->setContentSource($daemon_source)
@ -534,7 +545,7 @@ final class HarbormasterBuildEngine extends Phobject {
->setContinueOnMissingFields(true);
$editor->applyTransactions(
$object->getApplicationTransactionObject(),
$publish->getApplicationTransactionObject(),
array($template));
}

View file

@ -18,6 +18,21 @@ interface HarbormasterBuildableInterface {
public function getHarbormasterBuildablePHID();
public function getHarbormasterContainerPHID();
/**
* Get the object PHID which build status should be published to.
*
* In some cases (like commits), this is the object itself. In other cases,
* it is a different object: for example, diffs publish builds to revisions.
*
* This method can return `null` to disable publishing.
*
* @return phid|null Build status updates will be published to this object's
* transaction timeline.
*/
public function getHarbormasterPublishablePHID();
public function getBuildVariables();
public function getAvailableBuildVariables();

View file

@ -317,6 +317,10 @@ final class HarbormasterBuildable extends HarbormasterDAO
return $this->getContainerPHID();
}
public function getHarbormasterPublishablePHID() {
return $this->getBuildableObject()->getHarbormasterPublishablePHID();
}
public function getBuildVariables() {
return array();
}

View file

@ -413,6 +413,10 @@ final class PhabricatorRepositoryCommit
return $this->getRepository()->getPHID();
}
public function getHarbormasterPublishablePHID() {
return $this->getPHID();
}
public function getBuildVariables() {
$results = array();