mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Navigage Buildkite builds with more nuance
Summary: Ref T12173. - If we want to fetch a tag, Buildkite needs it as a "branch" (this means more like "ref to fetch"). - The API gets upset if we pass "refs/tags/...", so just pass the tag name without the prefix, which works. - Do a better job with commits and pass a real branch to fetch. Test Plan: - Built a commit with Buildkite. - Build a revision with Buildkite. Reviewers: chad Reviewed By: chad Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T12173 Differential Revision: https://secure.phabricator.com/D17282
This commit is contained in:
parent
206b16d2bb
commit
bd9e54b621
5 changed files with 78 additions and 3 deletions
|
@ -1211,6 +1211,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
|
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
|
||||||
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
|
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
|
||||||
'HarbormasterBuildkiteBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php',
|
'HarbormasterBuildkiteBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php',
|
||||||
|
'HarbormasterBuildkiteBuildableInterface' => 'applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php',
|
||||||
'HarbormasterBuildkiteHookController' => 'applications/harbormaster/controller/HarbormasterBuildkiteHookController.php',
|
'HarbormasterBuildkiteHookController' => 'applications/harbormaster/controller/HarbormasterBuildkiteHookController.php',
|
||||||
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
|
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
|
||||||
'HarbormasterCircleCIBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php',
|
'HarbormasterCircleCIBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php',
|
||||||
|
@ -5091,6 +5092,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorExtendedPolicyInterface',
|
'PhabricatorExtendedPolicyInterface',
|
||||||
'HarbormasterBuildableInterface',
|
'HarbormasterBuildableInterface',
|
||||||
'HarbormasterCircleCIBuildableInterface',
|
'HarbormasterCircleCIBuildableInterface',
|
||||||
|
'HarbormasterBuildkiteBuildableInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
|
@ -8789,6 +8791,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMentionableInterface',
|
'PhabricatorMentionableInterface',
|
||||||
'HarbormasterBuildableInterface',
|
'HarbormasterBuildableInterface',
|
||||||
'HarbormasterCircleCIBuildableInterface',
|
'HarbormasterCircleCIBuildableInterface',
|
||||||
|
'HarbormasterBuildkiteBuildableInterface',
|
||||||
'PhabricatorCustomFieldInterface',
|
'PhabricatorCustomFieldInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorFulltextInterface',
|
'PhabricatorFulltextInterface',
|
||||||
|
|
|
@ -7,6 +7,7 @@ final class DifferentialDiff
|
||||||
PhabricatorExtendedPolicyInterface,
|
PhabricatorExtendedPolicyInterface,
|
||||||
HarbormasterBuildableInterface,
|
HarbormasterBuildableInterface,
|
||||||
HarbormasterCircleCIBuildableInterface,
|
HarbormasterCircleCIBuildableInterface,
|
||||||
|
HarbormasterBuildkiteBuildableInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorDestructibleInterface {
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
|
@ -621,6 +622,27 @@ final class DifferentialDiff
|
||||||
return $ref;
|
return $ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( HarbormasterBuildkiteBuildableInterface )---------------------------- */
|
||||||
|
|
||||||
|
public function getBuildkiteBranch() {
|
||||||
|
$ref = $this->getStagingRef();
|
||||||
|
|
||||||
|
// NOTE: Circa late January 2017, Buildkite fails with the error message
|
||||||
|
// "Tags have been disabled for this project" if we pass the "refs/tags/"
|
||||||
|
// prefix via the API and the project doesn't have GitHub tag builds
|
||||||
|
// enabled, even if GitHub builds are disabled. The tag builds fine
|
||||||
|
// without this prefix.
|
||||||
|
$ref = preg_replace('(^refs/tags/)', '', $ref);
|
||||||
|
|
||||||
|
return $ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBuildkiteCommit() {
|
||||||
|
return 'HEAD';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getStagingRef() {
|
public function getStagingRef() {
|
||||||
// TODO: We're just hoping to get lucky. Instead, `arc` should store
|
// TODO: We're just hoping to get lucky. Instead, `arc` should store
|
||||||
// where it sent changes and we should only provide staging details
|
// where it sent changes and we should only provide staging details
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support for Buildkite.
|
||||||
|
*/
|
||||||
|
interface HarbormasterBuildkiteBuildableInterface {
|
||||||
|
|
||||||
|
public function getBuildkiteBranch();
|
||||||
|
public function getBuildkiteCommit();
|
||||||
|
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ EOTEXT
|
||||||
$buildable = $build->getBuildable();
|
$buildable = $build->getBuildable();
|
||||||
|
|
||||||
$object = $buildable->getBuildableObject();
|
$object = $buildable->getBuildableObject();
|
||||||
if (!($object instanceof HarbormasterCircleCIBuildableInterface)) {
|
if (!($object instanceof HarbormasterBuildkiteBuildableInterface)) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht('This object does not support builds with Buildkite.'));
|
pht('This object does not support builds with Buildkite.'));
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ EOTEXT
|
||||||
$pipeline);
|
$pipeline);
|
||||||
|
|
||||||
$data_structure = array(
|
$data_structure = array(
|
||||||
'commit' => $object->getCircleCIBuildIdentifier(),
|
'commit' => $object->getBuildkiteCommit(),
|
||||||
'branch' => 'master',
|
'branch' => $object->getBuildkiteBranch(),
|
||||||
'message' => pht(
|
'message' => pht(
|
||||||
'Harbormaster Build %s ("%s") for %s',
|
'Harbormaster Build %s ("%s") for %s',
|
||||||
$build->getID(),
|
$build->getID(),
|
||||||
|
|
|
@ -11,6 +11,7 @@ final class PhabricatorRepositoryCommit
|
||||||
PhabricatorMentionableInterface,
|
PhabricatorMentionableInterface,
|
||||||
HarbormasterBuildableInterface,
|
HarbormasterBuildableInterface,
|
||||||
HarbormasterCircleCIBuildableInterface,
|
HarbormasterCircleCIBuildableInterface,
|
||||||
|
HarbormasterBuildkiteBuildableInterface,
|
||||||
PhabricatorCustomFieldInterface,
|
PhabricatorCustomFieldInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorFulltextInterface,
|
PhabricatorFulltextInterface,
|
||||||
|
@ -590,6 +591,44 @@ final class PhabricatorRepositoryCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( HarbormasterBuildkiteBuildableInterface )---------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getBuildkiteBranch() {
|
||||||
|
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
|
$branches = DiffusionQuery::callConduitWithDiffusionRequest(
|
||||||
|
$viewer,
|
||||||
|
DiffusionRequest::newFromDictionary(
|
||||||
|
array(
|
||||||
|
'repository' => $repository,
|
||||||
|
'user' => $viewer,
|
||||||
|
)),
|
||||||
|
'diffusion.branchquery',
|
||||||
|
array(
|
||||||
|
'contains' => $this->getCommitIdentifier(),
|
||||||
|
'repository' => $repository->getPHID(),
|
||||||
|
));
|
||||||
|
|
||||||
|
if (!$branches) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Commit "%s" is not an ancestor of any branch head, so it can not '.
|
||||||
|
'be built with Buildkite.',
|
||||||
|
$this->getCommitIdentifier()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$branch = head($branches);
|
||||||
|
|
||||||
|
return 'refs/heads/'.$branch['shortName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBuildkiteCommit() {
|
||||||
|
return $this->getCommitIdentifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
|
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue