Merge ~cjwatson/launchpad:cibuild-traversal into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 785c383daf4e71eba4a2d0a970b6391571a4059f
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:cibuild-traversal
Merge into: launchpad:master
Diff against target: 48 lines (+20/-0)
2 files modified
lib/lp/buildmaster/browser/builder.py (+8/-0)
lib/lp/buildmaster/browser/tests/test_builder.py (+12/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+417863@code.launchpad.net

Commit message

Add +cibuild stepthrough navigation on BuilderSet

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Code changes look good. I have a question about the used decorator though.

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/browser/builder.py b/lib/lp/buildmaster/browser/builder.py
2index 6fa3e16..88b3d20 100644
3--- a/lib/lp/buildmaster/browser/builder.py
4+++ b/lib/lp/buildmaster/browser/builder.py
5@@ -42,6 +42,7 @@ from lp.buildmaster.interfaces.builder import (
6 IBuilder,
7 IBuilderSet,
8 )
9+from lp.code.interfaces.cibuild import ICIBuildSet
10 from lp.code.interfaces.sourcepackagerecipebuild import (
11 ISourcePackageRecipeBuildSource,
12 )
13@@ -108,6 +109,13 @@ class BuilderSetNavigation(GetitemNavigation):
14 return None
15 return self.redirectSubTree(canonical_url(build, request=self.request))
16
17+ @stepthrough('+cibuild')
18+ def traverse_cibuild(self, name):
19+ build = get_build_by_id_str(ICIBuildSet, name)
20+ if build is None:
21+ return None
22+ return self.redirectSubTree(canonical_url(build, request=self.request))
23+
24
25 class BuilderSetBreadcrumb(Breadcrumb):
26 """Builds a breadcrumb for an `IBuilderSet`."""
27diff --git a/lib/lp/buildmaster/browser/tests/test_builder.py b/lib/lp/buildmaster/browser/tests/test_builder.py
28index 0a3ce50..4037d31 100644
29--- a/lib/lp/buildmaster/browser/tests/test_builder.py
30+++ b/lib/lp/buildmaster/browser/tests/test_builder.py
31@@ -116,6 +116,18 @@ class TestBuilderSetNavigation(TestCaseWithFactory):
32 browser.open(url)
33 self.assertEqual(expected_url, browser.url)
34
35+ def test_ci_build_api_redirects(self):
36+ build = self.factory.makeCIBuild()
37+ url = (
38+ "http://api.launchpad.test/devel/builders/+cibuild/%s" % build.id)
39+ expected_url = (
40+ "http://api.launchpad.test/devel" +
41+ canonical_url(build, path_only_if_possible=True))
42+ logout()
43+ browser = setupBrowser()
44+ browser.open(url)
45+ self.assertEqual(expected_url, browser.url)
46+
47
48 class TestBuildersHomepage(TestCaseWithFactory, BuildCreationMixin):
49

Subscribers

People subscribed via source and target branches

to status/vote changes: