4 * Directed graph representing a build plan
6 final class HarbormasterBuildGraph
extends AbstractDirectedGraph
{
10 public static function determineDependencyExecution(
11 HarbormasterBuildPlan
$plan) {
13 $steps = id(new HarbormasterBuildStepQuery())
14 ->setViewer(PhabricatorUser
::getOmnipotentUser())
15 ->withBuildPlanPHIDs(array($plan->getPHID()))
18 $steps_by_phid = mpull($steps, null, 'getPHID');
19 $step_phids = mpull($steps, 'getPHID');
21 if (count($steps) === 0) {
25 $graph = id(new HarbormasterBuildGraph($steps_by_phid))
26 ->addNodes($step_phids);
28 $raw_results = $graph->getNodesInRoughTopologicalOrder();
31 foreach ($raw_results as $node) {
33 'node' => $steps_by_phid[$node['node']],
34 'depth' => $node['depth'],
35 'cycle' => $node['cycle'],
42 public function __construct($step_map) {
43 $this->stepMap
= $step_map;
46 protected function loadEdges(array $nodes) {
48 foreach ($nodes as $node) {
49 $step = $this->stepMap
[$node];
52 $deps = $step->getStepImplementation()->getDependencies($step);
53 } catch (Exception
$ex) {
57 $map[$node] = array();
58 foreach ($deps as $dep) {