From c4eef3dfcb5b5e4bede98a3831007453477e282d Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 21 Jun 2015 14:37:34 -0700 Subject: [PATCH] Sketch out unit/lint displaying on builds Summary: Ref T8096. Show basic lint/unit info on builds. This is still pretty rough. Test Plan: {F524839} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8096 Differential Revision: https://secure.phabricator.com/D13383 --- .../HarbormasterBuildableViewController.php | 57 +++++++++++++++++++ .../view/HarbormasterLintPropertyView.php | 2 +- .../view/HarbormasterUnitPropertyView.php | 2 +- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php index f080961efc..461425ba3d 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php @@ -25,6 +25,8 @@ final class HarbormasterBuildableViewController ->needBuildTargets(true) ->execute(); + list($lint, $unit) = $this->renderLintAndUnit($builds); + $buildable->attachBuilds($builds); $object = $buildable->getBuildableObject(); @@ -55,6 +57,8 @@ final class HarbormasterBuildableViewController array( $crumbs, $box, + $lint, + $unit, $build_list, $timeline, ), @@ -251,4 +255,57 @@ final class HarbormasterBuildableViewController return $box; } + private function renderLintAndUnit(array $builds) { + $viewer = $this->getViewer(); + + $targets = array(); + foreach ($builds as $build) { + foreach ($build->getBuildTargets() as $target) { + $targets[] = $target; + } + } + + if (!$targets) { + return; + } + + $target_phids = mpull($targets, 'getPHID'); + + $lint_data = id(new HarbormasterBuildLintMessage())->loadAllWhere( + 'buildTargetPHID IN (%Ls) LIMIT 25', + $target_phids); + + $unit_data = id(new HarbormasterBuildUnitMessage())->loadAllWhere( + 'buildTargetPHID IN (%Ls) LIMIT 25', + $target_phids); + + if ($lint_data) { + $lint_table = id(new HarbormasterLintPropertyView()) + ->setUser($viewer) + ->setLintMessages($lint_data); + + $lint = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Lint Messages')) + ->appendChild($lint_table); + } else { + $lint = null; + } + + if ($unit_data) { + $unit_table = id(new HarbormasterUnitPropertyView()) + ->setUser($viewer) + ->setUnitMessages($unit_data); + + $unit = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Unit Tests')) + ->appendChild($unit_table); + } else { + $unit = null; + } + + return array($lint, $unit); + } + + + } diff --git a/src/applications/harbormaster/view/HarbormasterLintPropertyView.php b/src/applications/harbormaster/view/HarbormasterLintPropertyView.php index 8cf86124fe..f2591daae5 100644 --- a/src/applications/harbormaster/view/HarbormasterLintPropertyView.php +++ b/src/applications/harbormaster/view/HarbormasterLintPropertyView.php @@ -2,7 +2,7 @@ final class HarbormasterLintPropertyView extends AphrontView { - private $pathURIMap; + private $pathURIMap = array(); private $lintMessages = array(); public function setPathURIMap(array $map) { diff --git a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php index e49749636c..8bff9744f7 100644 --- a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php +++ b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php @@ -2,7 +2,7 @@ final class HarbormasterUnitPropertyView extends AphrontView { - private $pathURIMap; + private $pathURIMap = array(); private $unitMessages = array(); public function setPathURIMap(array $map) {