mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-16 16:58:38 +01:00
Show build results in arc land
Summary: Fixes T4809. When landing a revision, check for a (non-manual) buildable of the current diff. If we find one, check its status: - If it passed, print out a message to inform the user that we checked. - If it failed or is still building, print out details about the issue and require a confirmation to continue. - Just ignore other cases. Test Plan: - Ran `arc land` on a revision with no buildable, a passing buildable, a failed buildable, and a building buildable for the current diff. - Got sensible output / prompts. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4809 Differential Revision: https://secure.phabricator.com/D8801
This commit is contained in:
parent
23c9e87fdf
commit
6e597b292a
1 changed files with 96 additions and 0 deletions
|
@ -533,6 +533,11 @@ EOTEXT
|
||||||
|
|
||||||
echo pht("Landing revision '%s'...",
|
echo pht("Landing revision '%s'...",
|
||||||
"D{$rev_id}: {$rev_title}"), "\n";
|
"D{$rev_id}: {$rev_title}"), "\n";
|
||||||
|
|
||||||
|
$diff_phid = idx($this->revision, 'activeDiffPHID');
|
||||||
|
if ($diff_phid) {
|
||||||
|
$this->checkForBuildables($diff_phid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function pullFromRemote() {
|
private function pullFromRemote() {
|
||||||
|
@ -1162,4 +1167,95 @@ EOTEXT
|
||||||
$this->oldBranch);
|
$this->oldBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a diff has a running or failed buildable, and prompt the user
|
||||||
|
* before landing if it does.
|
||||||
|
*/
|
||||||
|
private function checkForBuildables($diff_phid) {
|
||||||
|
// NOTE: Since Harbormaster is still beta and this stuff all got added
|
||||||
|
// recently, just bail if we can't find a buildable. This is just an
|
||||||
|
// advisory check intended to prevent human error.
|
||||||
|
|
||||||
|
try {
|
||||||
|
$buildables = $this->getConduit()->callMethodSynchronous(
|
||||||
|
'harbormaster.querybuildables',
|
||||||
|
array(
|
||||||
|
'buildablePHIDs' => array($diff_phid),
|
||||||
|
'manualBuildables' => false,
|
||||||
|
));
|
||||||
|
} catch (ConduitClientException $ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$buildables['data']) {
|
||||||
|
// If there's no corresponding buildable, we're done.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$console = PhutilConsole::getConsole();
|
||||||
|
|
||||||
|
$buildable = head($buildables['data']);
|
||||||
|
|
||||||
|
if ($buildable['buildableStatus'] == 'passed') {
|
||||||
|
$console->writeOut(
|
||||||
|
"**<bg:green> %s </bg>** %s\n",
|
||||||
|
pht('BUILDS PASSED'),
|
||||||
|
pht(
|
||||||
|
'Harbormaster builds for the active diff completed successfully.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($buildable['buildableStatus']) {
|
||||||
|
case 'building':
|
||||||
|
$message = pht(
|
||||||
|
'Harbormaster is still building the active diff for this revision:');
|
||||||
|
$prompt = pht('Land revision anyway, despite ongoing build?');
|
||||||
|
break;
|
||||||
|
case 'failed':
|
||||||
|
$message = pht(
|
||||||
|
'Harbormaster failed to build the active diff for this revision. '.
|
||||||
|
'Build failures:');
|
||||||
|
$prompt = pht('Land revision anyway, despite build failures?');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// If we don't recognize the status, just bail.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$builds = $this->getConduit()->callMethodSynchronous(
|
||||||
|
'harbormaster.querybuilds',
|
||||||
|
array(
|
||||||
|
'buildablePHIDs' => array($buildable['phid']),
|
||||||
|
));
|
||||||
|
|
||||||
|
$console->writeOut($message."\n\n");
|
||||||
|
foreach ($builds['data'] as $build) {
|
||||||
|
switch ($build['buildStatus']) {
|
||||||
|
case 'failed':
|
||||||
|
$color = 'red';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$color = 'yellow';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$console->writeOut(
|
||||||
|
" **<bg:".$color."> %s </bg>** %s: %s\n",
|
||||||
|
phutil_utf8_strtoupper($build['buildStatusName']),
|
||||||
|
pht('Build %d', $build['id']),
|
||||||
|
$build['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$console->writeOut(
|
||||||
|
"\n%s\n\n **%s**: __%s__",
|
||||||
|
pht('You can review build details here:'),
|
||||||
|
pht('Harbormaster URI'),
|
||||||
|
$buildable['uri']);
|
||||||
|
|
||||||
|
if (!$console->confirm($prompt)) {
|
||||||
|
throw new ArcanistUserAbortException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue