Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14726569
D9806.id23537.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D9806.id23537.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2315,6 +2315,7 @@
'PhabricatorTypeaheadMonogramDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadMonogramDatasource.php',
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadRuntimeCompositeDatasource.php',
+ 'PhabricatorTypeaheadStepDependenciesDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadStepDependenciesDatasourceController.php',
'PhabricatorUIConfigOptions' => 'applications/config/option/PhabricatorUIConfigOptions.php',
'PhabricatorUIExample' => 'applications/uiexample/examples/PhabricatorUIExample.php',
'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php',
@@ -5211,6 +5212,7 @@
'PhabricatorTypeaheadModularDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorTypeaheadMonogramDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
+ 'PhabricatorTypeaheadStepDependenciesDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorUIConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorUIExampleRenderController' => 'PhabricatorController',
'PhabricatorUIListFilterExample' => 'PhabricatorUIExample',
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
@@ -284,7 +284,7 @@
try {
$impl = $target->getImplementation();
- $name = $impl->getName();
+ $name = $impl->getDescription();
} catch (Exception $ex) {
$name = $target->getClassName();
}
diff --git a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php
@@ -158,8 +158,8 @@
->setHref(
$this->getApplicationURI('step/delete/'.$step->getID().'/')));
- $inputs = $step->getStepImplementation()->getArtifactInputs();
- $outputs = $step->getStepImplementation()->getArtifactOutputs();
+ $inputs = $step->getStepImplementation()->getFullArtifactInputs($step);
+ $outputs = $step->getStepImplementation()->getFullArtifactOutputs($step);
$has_conflicts = false;
if ($inputs || $outputs) {
diff --git a/src/applications/harbormaster/controller/HarbormasterStepEditController.php b/src/applications/harbormaster/controller/HarbormasterStepEditController.php
--- a/src/applications/harbormaster/controller/HarbormasterStepEditController.php
+++ b/src/applications/harbormaster/controller/HarbormasterStepEditController.php
@@ -64,9 +64,24 @@
->setViewer($viewer)
->readFieldsFromStorage($step);
+ $e_depends_on = true;
+ $raw_depends_on = $step->getDetail('depends_on', array());
+
+ // TODO: This is pretty horrible!
+ $v_depends_on = array();
+ foreach ($raw_depends_on as $phid) {
+ $v_depends_on[] = id(new PhabricatorObjectHandle())
+ ->setName('Build State '.$phid)
+ ->setURI('/')
+ ->setPHID($phid);
+ }
+
$errors = array();
$validation_exception = null;
if ($request->isFormPost()) {
+ $e_depends_on = null;
+ $v_depends_on = $request->getArr('dependsOn');
+
$xactions = $field_list->buildFieldTransactionsFromRequest(
new HarbormasterBuildStepTransaction(),
$request);
@@ -76,6 +91,12 @@
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request);
+ $depends_on_xaction = id(new HarbormasterBuildStepTransaction())
+ ->setTransactionType(
+ HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON)
+ ->setNewValue($v_depends_on);
+ array_unshift($xactions, $depends_on_xaction);
+
if ($is_new) {
// This is okay, but a little iffy. We should move it inside the editor
// if we create plans elsewhere.
@@ -98,9 +119,37 @@
}
}
+ $datasource_uri = new PhutilURI('/typeahead/stepdependencies/');
+ $datasource_uri->setQueryParam('planPHID', $plan->getPHID());
+ if (!$is_new) {
+ $datasource_uri->setQueryParam('stepPHID', $step->getPHID());
+ }
+
$form = id(new AphrontFormView())
->setUser($viewer);
+ // Check if there are any build steps that we can use.
+ $step_ref = null;
+ if (!$is_new) {
+ $step_ref = $step;
+ }
+ $previous_artifacts =
+ HarbormasterBuildStepImplementation::loadAvailableArtifacts(
+ $plan,
+ $step_ref,
+ HarbormasterBuildArtifact::TYPE_BUILD_STATE);
+
+ if (count($previous_artifacts) > 0) {
+ $form
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource((string)$datasource_uri)
+ ->setName('dependsOn')
+ ->setLabel(pht('Depends On'))
+ ->setError($e_depends_on)
+ ->setValue($v_depends_on));
+ }
+
$field_list->appendFieldsToForm($form);
if ($is_new) {
diff --git a/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php b/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php
--- a/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php
+++ b/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php
@@ -7,6 +7,7 @@
$types = parent::getTransactionTypes();
$types[] = HarbormasterBuildStepTransaction::TYPE_CREATE;
+ $types[] = HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON;
return $types;
}
@@ -18,6 +19,11 @@
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return null;
+ case HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON:
+ if ($this->getIsNewObject()) {
+ return null;
+ }
+ return $object->getDetail('depends_on', array());
}
return parent::getCustomTransactionOldValue($object, $xaction);
@@ -30,6 +36,8 @@
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return true;
+ case HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON:
+ return $xaction->getNewValue();
}
return parent::getCustomTransactionNewValue($object, $xaction);
@@ -42,6 +50,8 @@
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return;
+ case HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON:
+ return $object->setDetail('depends_on', $xaction->getNewValue());
}
return parent::applyCustomInternalTransaction($object, $xaction);
@@ -53,6 +63,7 @@
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
+ case HarbormasterBuildStepTransaction::TYPE_DEPENDS_ON:
return;
}
diff --git a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
--- a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
+++ b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
@@ -246,22 +246,14 @@
// Identify all the steps which are ready to run (because all their
// depdendencies are complete).
- $previous_step = null;
$runnable = array();
foreach ($steps as $step) {
- // TODO: For now, we're hard coding sequential dependencies into build
- // steps. In the future, we can be smart about this instead.
-
- if ($previous_step) {
- $dependencies = array($previous_step);
- } else {
- $dependencies = array();
- }
+ $dependencies = $step->getDetail('depends_on');
if (isset($queued[$step->getPHID()])) {
$can_run = true;
foreach ($dependencies as $dependency) {
- if (empty($complete[$dependency->getPHID()])) {
+ if (empty($complete[$dependency])) {
$can_run = false;
break;
}
@@ -271,13 +263,12 @@
$runnable[] = $step;
}
}
-
- $previous_step = $step;
}
if (!$runnable && !$waiting && !$underway) {
- // TODO: This means the build is deadlocked, probably? It should not
- // normally be possible yet, but we should communicate it more clearly.
+ // This means the build is deadlocked, and the user has configured
+ // circular dependencies. It should not normally be possible yet,
+ // but we should communicate it more clearly.
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
$build->save();
return;
diff --git a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
--- a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
+++ b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
@@ -98,6 +98,32 @@
return array();
}
+ public function getFullArtifactInputs(HarbormasterBuildStep $build_step) {
+ $artifacts = $this->getArtifactInputs();
+
+ $depends_on = $build_step->getDetail('depends_on', array());
+ foreach ($depends_on as $dependency) {
+ $artifacts[] = array(
+ 'name' => pht('Build State'),
+ 'key' => $dependency,
+ 'type' => HarbormasterBuildArtifact::TYPE_BUILD_STATE,
+ );
+ }
+
+ return $artifacts;
+ }
+
+ public function getFullArtifactOutputs(HarbormasterBuildStep $build_step) {
+ $artifacts = $this->getArtifactOutputs();
+ $artifacts[] = array(
+ 'name' => pht('Build State'),
+ 'key' => $build_step->getPHID(),
+ 'type' => HarbormasterBuildArtifact::TYPE_BUILD_STATE,
+ );
+
+ return $artifacts;
+ }
+
/**
* Returns a list of all artifacts made available by previous build steps.
*/
@@ -121,18 +147,20 @@
public static function getAvailableArtifacts(
HarbormasterBuildPlan $build_plan,
array $build_steps,
- HarbormasterBuildStep $current_build_step,
+ $current_build_step,
$artifact_type) {
- $previous_implementations = array();
+ $artifact_arrays = array();
foreach ($build_steps as $build_step) {
- if ($build_step->getPHID() === $current_build_step->getPHID()) {
+ if ($current_build_step !== null &&
+ $build_step->getPHID() === $current_build_step->getPHID()) {
break;
}
- $previous_implementations[] = $build_step->getStepImplementation();
+
+ $implementation = $build_step->getStepImplementation();
+ $artifact_arrays[] = $implementation->getFullArtifactOutputs($build_step);
}
- $artifact_arrays = mpull($previous_implementations, 'getArtifactOutputs');
$artifacts = array();
foreach ($artifact_arrays as $array) {
$array = ipull($array, 'type', 'key');
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
@@ -13,6 +13,7 @@
const TYPE_FILE = 'file';
const TYPE_HOST = 'host';
+ const TYPE_BUILD_STATE = 'buildstate';
public static function initializeNewBuildArtifact(
HarbormasterBuildTarget $build_target) {
diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php
--- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php
+++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php
@@ -4,6 +4,7 @@
extends PhabricatorApplicationTransaction {
const TYPE_CREATE = 'harbormaster:step:create';
+ const TYPE_DEPENDS_ON = 'harbormaster:step:depends';
public function getApplicationName() {
return 'harbormaster';
diff --git a/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php b/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php
--- a/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php
+++ b/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php
@@ -7,6 +7,8 @@
'/typeahead/' => array(
'common/(?P<type>\w+)/'
=> 'PhabricatorTypeaheadCommonDatasourceController',
+ 'stepdependencies/'
+ => 'PhabricatorTypeaheadStepDependenciesDatasourceController',
'class/(?:(?P<class>\w+)/)?'
=> 'PhabricatorTypeaheadModularDatasourceController',
),
diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadStepDependenciesDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadStepDependenciesDatasourceController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/typeahead/controller/PhabricatorTypeaheadStepDependenciesDatasourceController.php
@@ -0,0 +1,84 @@
+<?php
+
+final class PhabricatorTypeaheadStepDependenciesDatasourceController
+ extends PhabricatorTypeaheadDatasourceController {
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $plan_phid = $request->getStr('planPHID');
+ $step_phid = $request->getStr('stepPHID');
+
+ $plan = id(new HarbormasterBuildPlanQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($plan_phid))
+ ->executeOne();
+
+ $steps = id(new HarbormasterBuildStepQuery())
+ ->setViewer($viewer)
+ ->withBuildPlanPHIDs(array($plan_phid))
+ ->execute();
+ $steps = mpull($steps, null, 'getPHID');
+
+ $current_step = idx($steps, $step_phid);
+
+ $artifacts = HarbormasterBuildStepImplementation::loadAvailableArtifacts(
+ $plan,
+ $current_step,
+ HarbormasterBuildArtifact::TYPE_BUILD_STATE);
+
+ $results = array();
+ foreach ($artifacts as $key => $name) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName('Build State '.$key)
+ ->setURI('/')
+ ->setPHID($key);
+ }
+
+ $content = mpull($results, 'getWireFormat');
+
+ if ($request->isAjax()) {
+ return id(new AphrontAjaxResponse())->setContent($content);
+ }
+
+ // If there's a non-Ajax request to this endpoint, show results in a tabular
+ // format to make it easier to debug typeahead output.
+
+ $rows = array();
+ foreach ($results as $result) {
+ $wire = $result->getWireFormat();
+ $rows[] = $wire;
+ }
+
+ $table = new AphrontTableView($rows);
+ $table->setHeaders(
+ array(
+ 'Name',
+ 'URI',
+ 'PHID',
+ 'Priority',
+ 'Display Name',
+ 'Display Type',
+ 'Image URI',
+ 'Priority Type',
+ 'Sprite Class',
+ ));
+
+ $panel = new AphrontPanelView();
+ $panel->setHeader('Typeahead Results');
+ $panel->appendChild($table);
+
+ return $this->buildStandardPageResponse(
+ $panel,
+ array(
+ 'title' => pht('Typeahead Results'),
+ 'device' => true
+ ));
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 19, 3:33 AM (9 h, 31 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7016577
Default Alt Text
D9806.id23537.diff (15 KB)
Attached To
Mode
D9806: Implement artifact dependencies and parallisation in Harbormaster
Attached
Detach File
Event Timeline
Log In to Comment