launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28268
[Merge] ~cjwatson/launchpad:cibuild-traversal into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:cibuild-traversal into launchpad:master.
Commit message:
Add +cibuild stepthrough navigation on BuilderSet
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/417863
This is useful when repairing the build farm after outages, or otherwise needing to look up a CI build by its ID alone. It goes with similar stepthroughs for other build types.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:cibuild-traversal into launchpad:master.
diff --git a/lib/lp/buildmaster/browser/builder.py b/lib/lp/buildmaster/browser/builder.py
index 6fa3e16..88b3d20 100644
--- a/lib/lp/buildmaster/browser/builder.py
+++ b/lib/lp/buildmaster/browser/builder.py
@@ -42,6 +42,7 @@ from lp.buildmaster.interfaces.builder import (
IBuilder,
IBuilderSet,
)
+from lp.code.interfaces.cibuild import ICIBuildSet
from lp.code.interfaces.sourcepackagerecipebuild import (
ISourcePackageRecipeBuildSource,
)
@@ -108,6 +109,13 @@ class BuilderSetNavigation(GetitemNavigation):
return None
return self.redirectSubTree(canonical_url(build, request=self.request))
+ @stepthrough('+cibuild')
+ def traverse_cibuild(self, name):
+ build = get_build_by_id_str(ICIBuildSet, name)
+ if build is None:
+ return None
+ return self.redirectSubTree(canonical_url(build, request=self.request))
+
class BuilderSetBreadcrumb(Breadcrumb):
"""Builds a breadcrumb for an `IBuilderSet`."""
diff --git a/lib/lp/buildmaster/browser/tests/test_builder.py b/lib/lp/buildmaster/browser/tests/test_builder.py
index 0a3ce50..4037d31 100644
--- a/lib/lp/buildmaster/browser/tests/test_builder.py
+++ b/lib/lp/buildmaster/browser/tests/test_builder.py
@@ -116,6 +116,18 @@ class TestBuilderSetNavigation(TestCaseWithFactory):
browser.open(url)
self.assertEqual(expected_url, browser.url)
+ def test_ci_build_api_redirects(self):
+ build = self.factory.makeCIBuild()
+ url = (
+ "http://api.launchpad.test/devel/builders/+cibuild/%s" % build.id)
+ expected_url = (
+ "http://api.launchpad.test/devel" +
+ canonical_url(build, path_only_if_possible=True))
+ logout()
+ browser = setupBrowser()
+ browser.open(url)
+ self.assertEqual(expected_url, browser.url)
+
class TestBuildersHomepage(TestCaseWithFactory, BuildCreationMixin):