Index: src/__phutil_library_map__.php =================================================================== --- src/__phutil_library_map__.php +++ src/__phutil_library_map__.php @@ -901,9 +901,14 @@ 'HarbormasterCommandBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php', 'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php', 'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php', + 'HarbormasterCustomFieldRepository' => 'applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php', 'HarbormasterDAO' => 'applications/harbormaster/storage/HarbormasterDAO.php', 'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.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', @@ -4411,9 +4416,14 @@ 'HarbormasterCommandBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod', 'HarbormasterController' => 'PhabricatorController', + 'HarbormasterCustomFieldRepository' => 'PhabricatorStandardCustomFieldPHIDs', 'HarbormasterDAO' => 'PhabricatorLiskDAO', 'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 'HarbormasterLeaseHostBuildStepImplementation' => 'HarbormasterBuildStepImplementation', + 'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation', + 'HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation', + 'HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation', + 'HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation', 'HarbormasterLintMessagesController' => 'HarbormasterController', 'HarbormasterLintPropertyView' => 'AphrontView', 'HarbormasterManagePlansCapability' => 'PhabricatorPolicyCapability', Index: src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php =================================================================== --- src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php +++ 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( Index: src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php =================================================================== --- /dev/null +++ src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php @@ -0,0 +1,43 @@ +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); + } + +} Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php =================================================================== --- /dev/null +++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php @@ -0,0 +1,83 @@ +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, + ), + ); + } + +} Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php =================================================================== --- /dev/null +++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php @@ -0,0 +1,30 @@ + $build->getBuildablePHID(), + ); + } + + protected function getLeaseFieldSpecifications() { + return array(); + } + +} Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php =================================================================== --- /dev/null +++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php @@ -0,0 +1,44 @@ + + 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'), + ), + ); + } + +} Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php =================================================================== --- /dev/null +++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php @@ -0,0 +1,43 @@ + 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'), + ), + ); + } + +}