mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 11:12:42 +01:00
ac19c55822
Summary: Ref T1049. Generally, it's useful to separate test/trial/manual runs from production/automatic runs. For example, you don't want to email a bunch of people that the build is broken just because you messed something up when writing a new build plan. You'd rather try it first, then promote it into production once you have some good runs. Similarly, test runs generally should not affect the outside world, etc. Finally, some build steps (like "wait for other buildables") may want to behave differently when run in production/automation than when run in a testing environment (where they should probably continue immediately). So, formalize the distinction between automatic buildables (those created passively by the system in response to events) and manual buildables (those created explicitly by users). Add filtering, and stop the automated parts of the system from interacting with the manual parts (for example, we won't show manual results on revisions). This also moves the "Apply Build Plan" to a third, new home: instead of the sidebar or Buildables, it's now on plans. I think this generally makes more sense given how things have developed. Broadly, this improves isolation of test environments. Test Plan: Created some builds, browsed around, used filters, etc. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1049 Differential Revision: https://secure.phabricator.com/D7824
176 lines
4.9 KiB
PHP
176 lines
4.9 KiB
PHP
<?php
|
|
|
|
final class HarbormasterBuildableSearchEngine
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
$revisions = $this->readPHIDsFromRequest(
|
|
$request,
|
|
'revisions',
|
|
array(
|
|
DifferentialPHIDTypeRevision::TYPECONST,
|
|
));
|
|
|
|
$repositories = $this->readPHIDsFromRequest(
|
|
$request,
|
|
'repositories',
|
|
array(
|
|
PhabricatorRepositoryPHIDTypeRepository::TYPECONST,
|
|
));
|
|
|
|
$container_phids = array_merge($revisions, $repositories);
|
|
$saved->setParameter('containerPHIDs', $container_phids);
|
|
|
|
$commits = $this->readPHIDsFromRequest(
|
|
$request,
|
|
'commits',
|
|
array(
|
|
PhabricatorRepositoryPHIDTypeCommit::TYPECONST,
|
|
));
|
|
|
|
$diffs = $this->readListFromRequest($request, 'diffs');
|
|
if ($diffs) {
|
|
$diffs = id(new DifferentialDiffQuery())
|
|
->setViewer($this->requireViewer())
|
|
->withIDs($diffs)
|
|
->execute();
|
|
$diffs = mpull($diffs, 'getPHID', 'getPHID');
|
|
}
|
|
|
|
$buildable_phids = array_merge($commits, $diffs);
|
|
$saved->setParameter('buildablePHIDs', $buildable_phids);
|
|
|
|
$saved->setParameter(
|
|
'manual',
|
|
$this->readBoolFromRequest($request, 'manual'));
|
|
|
|
return $saved;
|
|
}
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
$query = id(new HarbormasterBuildableQuery())
|
|
->needContainerHandles(true)
|
|
->needBuildableHandles(true)
|
|
->needBuilds(true);
|
|
|
|
$container_phids = $saved->getParameter('containerPHIDs', array());
|
|
if ($container_phids) {
|
|
$query->withContainerPHIDs($container_phids);
|
|
}
|
|
|
|
$buildable_phids = $saved->getParameter('buildablePHIDs', array());
|
|
|
|
if ($buildable_phids) {
|
|
$query->withBuildablePHIDs($buildable_phids);
|
|
}
|
|
|
|
$manual = $saved->getParameter('manual');
|
|
if ($manual !== null) {
|
|
$query->withManualBuildables($manual);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function buildSearchForm(
|
|
AphrontFormView $form,
|
|
PhabricatorSavedQuery $saved_query) {
|
|
|
|
$container_phids = $saved_query->getParameter('containerPHIDs', array());
|
|
$buildable_phids = $saved_query->getParameter('buildablePHIDs', array());
|
|
|
|
$all_phids = array_merge($container_phids, $buildable_phids);
|
|
|
|
$revision_names = array();
|
|
$diff_names = array();
|
|
$repository_names = array();
|
|
$commit_names = array();
|
|
|
|
if ($all_phids) {
|
|
$objects = id(new PhabricatorObjectQuery())
|
|
->setViewer($this->requireViewer())
|
|
->withPHIDs($all_phids)
|
|
->execute();
|
|
|
|
foreach ($all_phids as $phid) {
|
|
$object = idx($objects, $phid);
|
|
if (!$object) {
|
|
continue;
|
|
}
|
|
|
|
if ($object instanceof DifferentialRevision) {
|
|
$revision_names[] = 'D'.$object->getID();
|
|
} else if ($object instanceof DifferentialDiff) {
|
|
$diff_names[] = $object->getID();
|
|
} else if ($object instanceof PhabricatorRepository) {
|
|
$repository_names[] = 'r'.$object->getCallsign();
|
|
} else if ($object instanceof PhabricatorRepositoryCommit) {
|
|
$repository = $object->getRepository();
|
|
$commit_names[] = $repository->formatCommitName(
|
|
$object->getCommitIdentifier());
|
|
}
|
|
}
|
|
}
|
|
|
|
$form
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel(pht('Differential Revisions'))
|
|
->setName('revisions')
|
|
->setValue(implode(', ', $revision_names)))
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel(pht('Differential Diffs'))
|
|
->setName('diffs')
|
|
->setValue(implode(', ', $diff_names)))
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel(pht('Repositories'))
|
|
->setName('repositories')
|
|
->setValue(implode(', ', $repository_names)))
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel(pht('Commits'))
|
|
->setName('commits')
|
|
->setValue(implode(', ', $commit_names)))
|
|
->appendChild(
|
|
id(new AphrontFormSelectControl())
|
|
->setLabel(pht('Origin'))
|
|
->setName('manual')
|
|
->setValue($this->getBoolFromQuery($saved_query, 'manual'))
|
|
->setOptions(
|
|
array(
|
|
'' => pht('(All Origins)'),
|
|
'true' => pht('Manual Buildables'),
|
|
'false' => pht('Automatic Buildables'),
|
|
)));
|
|
}
|
|
|
|
protected function getURI($path) {
|
|
return '/harbormaster/'.$path;
|
|
}
|
|
|
|
public function getBuiltinQueryNames() {
|
|
$names = array(
|
|
'all' => pht('All Buildables'),
|
|
);
|
|
|
|
return $names;
|
|
}
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
$query->setQueryKey($query_key);
|
|
|
|
switch ($query_key) {
|
|
case 'all':
|
|
return $query;
|
|
}
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
}
|
|
|
|
}
|