Page MenuHomePhabricator

D7511.id.diff
No OneTemporary

D7511.id.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -91,7 +91,6 @@
'AphrontView' => 'view/AphrontView.php',
'AphrontWebpageResponse' => 'aphront/response/AphrontWebpageResponse.php',
'AuditActionMenuEventListener' => 'applications/audit/events/AuditActionMenuEventListener.php',
- 'BuildStepImplementation' => 'applications/harbormaster/step/BuildStepImplementation.php',
'CelerityAPI' => 'infrastructure/celerity/CelerityAPI.php',
'CelerityPhabricatorResourceController' => 'infrastructure/celerity/CelerityPhabricatorResourceController.php',
'CelerityResourceController' => 'infrastructure/celerity/CelerityResourceController.php',
@@ -104,6 +103,8 @@
'ConduitAPIMethod' => 'applications/conduit/method/ConduitAPIMethod.php',
'ConduitAPIRequest' => 'applications/conduit/protocol/ConduitAPIRequest.php',
'ConduitAPIResponse' => 'applications/conduit/protocol/ConduitAPIResponse.php',
+ 'ConduitAPI_agent_Method' => 'applications/harbormaster/conduit/ConduitAPI_agent_Method.php',
+ 'ConduitAPI_agent_nextbuild_Method' => 'applications/harbormaster/conduit/ConduitAPI_agent_nextbuild_Method.php',
'ConduitAPI_arcanist_Method' => 'applications/arcanist/conduit/ConduitAPI_arcanist_Method.php',
'ConduitAPI_arcanist_projectinfo_Method' => 'applications/arcanist/conduit/ConduitAPI_arcanist_projectinfo_Method.php',
'ConduitAPI_audit_Method' => 'applications/audit/conduit/ConduitAPI_audit_Method.php',
@@ -2199,7 +2200,6 @@
'ReleephStatusFieldSpecification' => 'applications/releeph/field/specification/ReleephStatusFieldSpecification.php',
'ReleephSummaryFieldSpecification' => 'applications/releeph/field/specification/ReleephSummaryFieldSpecification.php',
'ReleephUserView' => 'applications/releeph/view/user/ReleephUserView.php',
- 'SleepBuildStepImplementation' => 'applications/harbormaster/step/SleepBuildStepImplementation.php',
'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php',
'SlowvoteRemarkupRule' => 'applications/slowvote/remarkup/SlowvoteRemarkupRule.php',
),
@@ -2320,6 +2320,8 @@
0 => 'Phobject',
1 => 'PhabricatorPolicyInterface',
),
+ 'ConduitAPI_agent_Method' => 'ConduitAPIMethod',
+ 'ConduitAPI_agent_nextbuild_Method' => 'ConduitAPI_agent_Method',
'ConduitAPI_arcanist_Method' => 'ConduitAPIMethod',
'ConduitAPI_arcanist_projectinfo_Method' => 'ConduitAPI_arcanist_Method',
'ConduitAPI_audit_Method' => 'ConduitAPIMethod',
@@ -4663,7 +4665,6 @@
'ReleephStatusFieldSpecification' => 'ReleephFieldSpecification',
'ReleephSummaryFieldSpecification' => 'ReleephFieldSpecification',
'ReleephUserView' => 'AphrontView',
- 'SleepBuildStepImplementation' => 'BuildStepImplementation',
'SlowvoteEmbedView' => 'AphrontView',
'SlowvoteRemarkupRule' => 'PhabricatorRemarkupRuleObject',
),
Index: src/applications/harbormaster/conduit/ConduitAPI_agent_Method.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/conduit/ConduitAPI_agent_Method.php
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * @group conduit
+ */
+abstract class ConduitAPI_agent_Method extends ConduitAPIMethod {
+
+ public function getApplication() {
+ return PhabricatorApplication::getByClass(
+ 'PhabricatorApplicationHarbormaster');
+ }
+
+}
Index: src/applications/harbormaster/conduit/ConduitAPI_agent_nextbuild_Method.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/conduit/ConduitAPI_agent_nextbuild_Method.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @group conduit
+ */
+final class ConduitAPI_agent_nextbuild_Method
+ extends ConduitAPI_agent_Method {
+
+ public function getMethodDescription() {
+ return "Retrieve the next build an agent should pick up.";
+ }
+
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'category' => 'optional string',
+ );
+ }
+
+ public function defineReturnType() {
+ return 'list<dict>';
+ }
+
+ public function defineErrorTypes() {
+ return array(
+ );
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ return array(
+ "exists" => false,
+ "steps" => array());
+ }
+}
Index: src/applications/harbormaster/controller/HarbormasterStepAddController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterStepAddController.php
+++ src/applications/harbormaster/controller/HarbormasterStepAddController.php
@@ -9,6 +9,9 @@
$this->id = $data['id'];
}
+ /**
+ * @phutil-external-symbol class BuildStepImplementation
+ */
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
Index: src/applications/harbormaster/controller/HarbormasterStepEditController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterStepEditController.php
+++ src/applications/harbormaster/controller/HarbormasterStepEditController.php
@@ -9,6 +9,9 @@
$this->id = idx($data, 'id');
}
+ /**
+ * @phutil-external-symbol class BuildStepImplementation
+ */
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
Index: src/applications/harbormaster/step/BuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/BuildStepImplementation.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-abstract class BuildStepImplementation {
-
- private $settings;
-
- const SETTING_TYPE_STRING = 'string';
- const SETTING_TYPE_INTEGER = 'integer';
- const SETTING_TYPE_BOOLEAN = 'boolean';
-
- public static function getImplementations() {
- $symbols = id(new PhutilSymbolLoader())
- ->setAncestorClass("BuildStepImplementation")
- ->setConcreteOnly(true)
- ->selectAndLoadSymbols();
- return ipull($symbols, 'name');
- }
-
- /**
- * The name of the implementation.
- */
- abstract public function getName();
-
- /**
- * The generic description of the implementation.
- */
- public function getGenericDescription() {
- return '';
- }
-
- /**
- * The description of the implementation, based on the current settings.
- */
- public function getDescription() {
- return '';
- }
-
- /**
- * Run the build step against the specified build.
- */
- abstract public function execute(HarbormasterBuild $build);
-
- /**
- * Gets the settings for this build step.
- */
- public function getSettings() {
- return $this->settings;
- }
-
- /**
- * Validate the current settings of this build step.
- */
- public function validate() {
- return true;
- }
-
- /**
- * Loads the settings for this build step implementation from the build step.
- */
- public final function loadSettings(HarbormasterBuildStep $build_step) {
- $this->settings = array();
- $this->validateSettingDefinitions();
- foreach ($this->getSettingDefinitions() as $name => $opt) {
- $this->settings[$name] = $build_step->getDetail($name);
- }
- return $this->settings;
- }
-
- /**
- * Validates that the setting definitions for this implementation are valid.
- */
- public final function validateSettingDefinitions() {
- foreach ($this->getSettingDefinitions() as $name => $opt) {
- if (!isset($opt['type'])) {
- throw new Exception(
- 'Setting definition \''.$name.
- '\' is missing type requirement.');
- }
- }
- }
-
- /**
- * Return an array of settings for this step implementation.
- */
- public function getSettingDefinitions() {
- return array();
- }
-}
Index: src/applications/harbormaster/step/SleepBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/SleepBuildStepImplementation.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-final class SleepBuildStepImplementation extends BuildStepImplementation {
-
- public function getName() {
- return pht('Sleep');
- }
-
- public function getGenericDescription() {
- return pht('Sleep for a specified number of seconds.');
- }
-
- public function getDescription() {
- $settings = $this->getSettings();
-
- return pht('Sleep for %s seconds.', $settings['seconds']);
- }
-
- public function execute(HarbormasterBuild $build) {
- $settings = $this->getSettings();
-
- sleep($settings['seconds']);
- }
-
- public function validateSettings() {
- $settings = $this->getSettings();
-
- if ($settings['seconds'] === null) {
- return false;
- }
- if (!is_int($settings['seconds'])) {
- return false;
- }
- return true;
- }
-
- public function getSettingDefinitions() {
- return array(
- 'seconds' => array(
- 'name' => 'Seconds',
- 'description' => 'The number of seconds to sleep for.',
- 'type' => BuildStepImplementation::SETTING_TYPE_INTEGER));
- }
-
-}
Index: src/applications/harbormaster/storage/build/HarbormasterBuild.php
===================================================================
--- src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -50,6 +50,15 @@
->setBuildStatus(self::STATUS_INACTIVE);
}
+ /**
+ * Create a remote representation of this build.
+ *
+ * @phutil-external-symbol class RemoteHarbormasterBuild
+ */
+ public function createRemoteBuild() {
+ return new RemoteHarbormasterBuild();
+ }
+
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
Index: src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
===================================================================
--- src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
+++ src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
@@ -41,6 +41,9 @@
return $this;
}
+ /**
+ * @phutil-external-symbol class BuildStepImplementation
+ */
public function getStepImplementation() {
if ($this->className === null) {
throw new Exception("No implementation set for the given step.");
Index: src/applications/harbormaster/worker/HarbormasterBuildWorker.php
===================================================================
--- src/applications/harbormaster/worker/HarbormasterBuildWorker.php
+++ src/applications/harbormaster/worker/HarbormasterBuildWorker.php
@@ -44,7 +44,7 @@
$build->setBuildStatus(HarbormasterBuild::STATUS_ERROR);
break;
}
- $implementation->execute($build);
+ $implementation->execute($build->createRemoteBuild());
if ($build->getBuildStatus() !== HarbormasterBuild::STATUS_BUILDING) {
break;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 8:57 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7382826
Default Alt Text
D7511.id.diff (10 KB)

Event Timeline