Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15454970
D13506.id33779.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D13506.id33779.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
@@ -992,12 +992,17 @@
'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php',
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
'HarbormasterCreateArtifactConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php',
+ 'HarbormasterCustomFieldRepository' => 'applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php',
'HarbormasterDAO' => 'applications/harbormaster/storage/HarbormasterDAO.php',
'HarbormasterExternalBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterExternalBuildStepGroup.php',
'HarbormasterFileArtifact' => 'applications/harbormaster/artifact/HarbormasterFileArtifact.php',
'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php',
'HarbormasterHostArtifact' => 'applications/harbormaster/artifact/HarbormasterHostArtifact.php',
'HarbormasterLeaseHostBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php',
'HarbormasterLintMessagesController' => 'applications/harbormaster/controller/HarbormasterLintMessagesController.php',
'HarbormasterLintPropertyView' => 'applications/harbormaster/view/HarbormasterLintPropertyView.php',
'HarbormasterManagePlansCapability' => 'applications/harbormaster/capability/HarbormasterManagePlansCapability.php',
@@ -4741,12 +4746,17 @@
'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod',
'HarbormasterController' => 'PhabricatorController',
'HarbormasterCreateArtifactConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
+ 'HarbormasterCustomFieldRepository' => 'PhabricatorStandardCustomFieldPHIDs',
'HarbormasterDAO' => 'PhabricatorLiskDAO',
'HarbormasterExternalBuildStepGroup' => 'HarbormasterBuildStepGroup',
'HarbormasterFileArtifact' => 'HarbormasterArtifact',
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterHostArtifact' => 'HarbormasterArtifact',
'HarbormasterLeaseHostBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
'HarbormasterLintMessagesController' => 'HarbormasterController',
'HarbormasterLintPropertyView' => 'AphrontView',
'HarbormasterManagePlansCapability' => 'PhabricatorPolicyCapability',
diff --git a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
@@ -271,6 +271,13 @@
$this->log(pht('Checked out commit'));
} else if ($lease->getAttribute('resolved.target') === 'diff') {
$this->log(pht(
+ 'Fetching diff tag from origin'));
+ $cmd->exec(
+ 'git fetch origin +refs/tags/phabricator/diff/%d:'.
+ 'refs/tags/phabricator/diff/%d',
+ $lease->getAttribute('resolved.diffID'),
+ $lease->getAttribute('resolved.diffID'));
+ $this->log(pht(
'Checking out target diff at tag "phabricator/diff/%d"',
$lease->getAttribute('resolved.diffID')));
$cmd->execx(
diff --git a/src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php b/src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php
@@ -0,0 +1,43 @@
+<?php
+
+final class HarbormasterCustomFieldRepository
+ extends PhabricatorStandardCustomFieldPHIDs {
+
+ public function getFieldType() {
+ return 'repository';
+ }
+
+ public function renderEditControl(array $handles) {
+ $value = $this->getFieldValue();
+
+ $control = id(new AphrontFormTokenizerControl())
+ ->setUser($this->getViewer())
+ ->setLabel($this->getFieldName())
+ ->setName($this->getFieldKey())
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setCaption($this->getCaption())
+ ->setValue(nonempty($value, array()));
+
+ $limit = $this->getFieldConfigValue('limit');
+ if ($limit) {
+ $control->setLimit($limit);
+ }
+
+ return $control;
+ }
+
+ public function appendToApplicationSearchForm(
+ PhabricatorApplicationSearchEngine $engine,
+ AphrontFormView $form,
+ $value) {
+
+ $control = id(new AphrontFormTokenizerControl())
+ ->setLabel($this->getFieldName())
+ ->setName($this->getFieldKey())
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setValue(nonempty($value, array()));
+
+ $form->appendControl($control);
+ }
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
@@ -0,0 +1,83 @@
+<?php
+
+abstract class HarbormasterLeaseWorkingCopyBuildStepImplementation
+ extends HarbormasterBuildStepImplementation {
+
+ abstract protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings);
+
+ public function execute(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target) {
+
+ $settings = $this->getSettings();
+
+ $custom_attributes = DrydockCustomAttributes::parse(
+ $settings['attributes']);
+
+ // Create the lease.
+ $lease = id(new DrydockLease())
+ ->setResourceType('working-copy')
+ ->setAttributes(
+ array(
+ 'platform' => $settings['platform'],
+ 'buildablePHID' => $build->getBuildablePHID(),
+ ) + $this->getLeaseAttributes($build, $build_target, $settings)
+ + $custom_attributes)
+ ->queueForActivation();
+
+ // Create the associated artifact.
+ $artifact = $build->createArtifact(
+ $build_target,
+ $settings['name'],
+ HarbormasterBuildArtifact::TYPE_HOST);
+ $artifact->setArtifactData(array(
+ 'drydock-lease' => $lease->getID(),
+ ));
+ $artifact->save();
+
+ // Wait until the lease is fulfilled.
+ // TODO: This will throw an exception if the lease can't be fulfilled;
+ // we should treat that as build failure not build error.
+ $lease->waitUntilActive();
+ }
+
+ public function getArtifactOutputs() {
+ return array(
+ array(
+ 'name' => pht('Leased Working Copy'),
+ 'key' => $this->getSetting('name'),
+ 'type' => HarbormasterBuildArtifact::TYPE_HOST,
+ ),
+ );
+ }
+
+ abstract protected function getLeaseFieldSpecifications();
+
+ public function getFieldSpecifications() {
+ return array(
+ 'name' => array(
+ 'name' => pht('Artifact Name'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+ 'platform' => array(
+ 'name' => pht('Host Platform'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+ ) + $this->getLeaseFieldSpecifications() + array(
+ 'attributes' => array(
+ 'name' => pht('Required Attributes'),
+ 'type' => 'textarea',
+ 'caption' => pht(
+ 'A newline separated list of required working copy attributes. '.
+ 'Each attribute should be specified in a key=value format.'),
+ 'monospace' => true,
+ ),
+ );
+ }
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php
@@ -0,0 +1,30 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from Buildable');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of the '.
+ 'current buildable for performing builds.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'buildablePHID' => $build->getBuildablePHID(),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array();
+ }
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php
@@ -0,0 +1,44 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from Repository');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of a '.
+ 'repository hosted on Phabricator.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'repositoryPHID' =>
+ head(phutil_json_decode(idx($settings, 'repositoryPHID'))),
+ 'ref' => idx($settings, 'ref'),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array(
+ 'repositoryPHID' => array(
+ 'name' => pht('Repository'),
+ 'type' => 'repository',
+ 'required' => true,
+ ),
+ 'ref' => array(
+ 'name' => pht('Reference to Checkout'),
+ 'type' => 'text',
+ 'required' => true,
+ 'caption' => pht('e.g. master'),
+ ),
+ );
+ }
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php
@@ -0,0 +1,43 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from URL');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of a '.
+ 'repository at a given URL.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'url' => idx($settings, 'url'),
+ 'ref' => idx($settings, 'ref'),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array(
+ 'url' => array(
+ 'name' => pht('Repository URL'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+ 'ref' => array(
+ 'name' => pht('Reference to Checkout'),
+ 'type' => 'text',
+ 'required' => true,
+ 'caption' => pht('e.g. master'),
+ ),
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 9:39 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7727562
Default Alt Text
D13506.id33779.diff (12 KB)
Attached To
Mode
D13506: [harbormaster/working-copies/v0] Implement lease working copy build steps
Attached
Detach File
Event Timeline
Log In to Comment