← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:ci-build-link into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:ci-build-link into launchpad:master.

Commit message:
Link to CIBuild from revision status reports

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/422027

If a revision status report has an associated CI build, link to it from the web UI.  It can otherwise be rather difficult to find.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:ci-build-link into launchpad:master.
diff --git a/lib/lp/code/browser/tests/test_gitref.py b/lib/lp/code/browser/tests/test_gitref.py
index a7dcf14..61a4b14 100644
--- a/lib/lp/code/browser/tests/test_gitref.py
+++ b/lib/lp/code/browser/tests/test_gitref.py
@@ -203,7 +203,9 @@ class TestGitRefView(BrowserTestCase):
             title="Lint", commit_sha1=log[1]["sha1"],
             result_summary="Invalid import in test_file.py",
             url="https://foo2.com";,
-            result=RevisionStatusResult.FAILED)
+            result=RevisionStatusResult.FAILED,
+            ci_build=self.factory.makeCIBuild(
+                git_repository=repository, commit_sha1=log[1]["sha1"]))
         pending_report = self.factory.makeRevisionStatusReport(
             user=repository.owner, git_repository=repository,
             title="Build", commit_sha1=log[1]["sha1"])
@@ -238,6 +240,13 @@ class TestGitRefView(BrowserTestCase):
                         attrs={"href": report1.url})))
             self.assertThat(
                 reports_section[0],
+                Not(
+                    soupmatchers.Within(
+                        soupmatchers.Tag("first report title", "td"),
+                        soupmatchers.Tag(
+                            "first report CI build link", "a", text="build"))))
+            self.assertThat(
+                reports_section[0],
                 soupmatchers.Tag(
                     "first report summary", "td",
                     text=report1.result_summary))
@@ -250,6 +259,16 @@ class TestGitRefView(BrowserTestCase):
                         attrs={"href": report2.url})))
             self.assertThat(
                 reports_section[1],
+                soupmatchers.Within(
+                    soupmatchers.Tag("second report title", "td"),
+                    soupmatchers.Tag(
+                        "second report CI build link", "a", text="build",
+                        attrs={
+                            "href": canonical_url(
+                                report2.ci_build, force_local_path=True),
+                            })))
+            self.assertThat(
+                reports_section[1],
                 soupmatchers.Tag(
                     "second report summary", "td",
                     text=report2.result_summary))
diff --git a/lib/lp/code/templates/git-macros.pt b/lib/lp/code/templates/git-macros.pt
index 262586b..1d02912 100644
--- a/lib/lp/code/templates/git-macros.pt
+++ b/lib/lp/code/templates/git-macros.pt
@@ -237,6 +237,9 @@
               <td class="icon" tal:content="structure report/image:icon" />
               <td tal:define="url python: report.url if report.url is not None else path('report/latest_log/download_url | nothing')">
                 <a tal:attributes="href url" tal:content="report/title" />
+                <tal:ci_build condition="report/ci_build">
+                  (<a tal:attributes="href report/ci_build/fmt:url">build</a>)
+                </tal:ci_build>
               </td>
               <td tal:content="report/result_summary" />
             </tr>