@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+49 -7
+4
src/applications/differential/storage/DifferentialDiff.php
··· 502 502 return null; 503 503 } 504 504 505 + public function getHarbormasterPublishablePHID() { 506 + return $this->getHarbormasterContainerPHID(); 507 + } 508 + 505 509 public function getBuildVariables() { 506 510 $results = array(); 507 511
+4
src/applications/differential/storage/DifferentialRevision.php
··· 513 513 return $this->getPHID(); 514 514 } 515 515 516 + public function getHarbormasterPublishablePHID() { 517 + return $this->getPHID(); 518 + } 519 + 516 520 public function getBuildVariables() { 517 521 return array(); 518 522 }
+18 -7
src/applications/harbormaster/engine/HarbormasterBuildEngine.php
··· 497 497 return; 498 498 } 499 499 500 - if (!($object instanceof PhabricatorApplicationTransactionInterface)) { 500 + $publish_phid = $object->getHarbormasterPublishablePHID(); 501 + if (!$publish_phid) { 501 502 return; 502 503 } 503 504 504 - // TODO: Publishing these transactions is causing a race. See T8650. 505 - // We shouldn't be publishing to diffs anyway. 506 - if ($object instanceof DifferentialDiff) { 505 + if ($publish_phid === $object->getPHID()) { 506 + $publish = $object; 507 + } else { 508 + $publish = id(new PhabricatorObjectQuery()) 509 + ->setViewer($viewer) 510 + ->withPHIDs(array($publish_phid)) 511 + ->executeOne(); 512 + if (!$publish) { 513 + return; 514 + } 515 + } 516 + 517 + if (!($publish instanceof PhabricatorApplicationTransactionInterface)) { 507 518 return; 508 519 } 509 520 510 - $template = $object->getApplicationTransactionTemplate(); 521 + $template = $publish->getApplicationTransactionTemplate(); 511 522 if (!$template) { 512 523 return; 513 524 } ··· 526 537 $daemon_source = PhabricatorContentSource::newForSource( 527 538 PhabricatorDaemonContentSource::SOURCECONST); 528 539 529 - $editor = $object->getApplicationTransactionEditor() 540 + $editor = $publish->getApplicationTransactionEditor() 530 541 ->setActor($viewer) 531 542 ->setActingAsPHID($harbormaster_phid) 532 543 ->setContentSource($daemon_source) ··· 534 545 ->setContinueOnMissingFields(true); 535 546 536 547 $editor->applyTransactions( 537 - $object->getApplicationTransactionObject(), 548 + $publish->getApplicationTransactionObject(), 538 549 array($template)); 539 550 } 540 551
+15
src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
··· 18 18 public function getHarbormasterBuildablePHID(); 19 19 public function getHarbormasterContainerPHID(); 20 20 21 + 22 + /** 23 + * Get the object PHID which build status should be published to. 24 + * 25 + * In some cases (like commits), this is the object itself. In other cases, 26 + * it is a different object: for example, diffs publish builds to revisions. 27 + * 28 + * This method can return `null` to disable publishing. 29 + * 30 + * @return phid|null Build status updates will be published to this object's 31 + * transaction timeline. 32 + */ 33 + public function getHarbormasterPublishablePHID(); 34 + 35 + 21 36 public function getBuildVariables(); 22 37 public function getAvailableBuildVariables(); 23 38
+4
src/applications/harbormaster/storage/HarbormasterBuildable.php
··· 317 317 return $this->getContainerPHID(); 318 318 } 319 319 320 + public function getHarbormasterPublishablePHID() { 321 + return $this->getBuildableObject()->getHarbormasterPublishablePHID(); 322 + } 323 + 320 324 public function getBuildVariables() { 321 325 return array(); 322 326 }
+4
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 413 413 return $this->getRepository()->getPHID(); 414 414 } 415 415 416 + public function getHarbormasterPublishablePHID() { 417 + return $this->getPHID(); 418 + } 419 + 416 420 public function getBuildVariables() { 417 421 $results = array(); 418 422