launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28218
[Merge] ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad:master
Jürgen Gmach has proposed merging ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad:master.
Commit message:
Fix regression introduced with `create lpcraft jobs on push`.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/416818
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad:master.
diff --git a/lib/lp/code/browser/tests/test_gitref.py b/lib/lp/code/browser/tests/test_gitref.py
index 8af99ca..75f13b6 100644
--- a/lib/lp/code/browser/tests/test_gitref.py
+++ b/lib/lp/code/browser/tests/test_gitref.py
@@ -6,6 +6,7 @@
from datetime import datetime
import hashlib
import re
+from textwrap import dedent
from fixtures import FakeLogger
import pytz
@@ -153,7 +154,20 @@ class TestGitRefView(BrowserTestCase):
[ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
log = self.makeCommitLog()
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
# Make code hosting fail.
self.hosting_fixture.getLog = FakeMethod(
@@ -193,7 +207,20 @@ class TestGitRefView(BrowserTestCase):
result=RevisionStatusResult.FAILED)
self.hosting_fixture.getLog.result = list(log)
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
view = create_initialized_view(ref, "+index",
principal=repository.owner)
with person_logged_in(repository.owner):
@@ -533,7 +560,10 @@ class TestGitRefView(BrowserTestCase):
}
for i in range(5)]
- def scanRef(self, ref, tip):
+ def scanRef(self, ref, tip, blobs=None):
+ # import pdb;pdb.set_trace()
+ if blobs is not None:
+ tip["blobs"] = blobs
self.hosting_fixture.getRefs.result = {
ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}},
}
@@ -550,7 +580,20 @@ class TestGitRefView(BrowserTestCase):
[ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
log = self.makeCommitLog()
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
view = create_initialized_view(ref, "+index")
contents = view()
expected_texts = list(reversed([
@@ -573,7 +616,20 @@ class TestGitRefView(BrowserTestCase):
[ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
log = self.makeCommitLog()
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
merged_tip = dict(log[-1])
merged_tip["sha1"] = six.ensure_text(
@@ -603,7 +659,20 @@ class TestGitRefView(BrowserTestCase):
[ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
log = self.makeCommitLog()
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
merged_tip = dict(log[-1])
merged_tip["sha1"] = six.ensure_text(
@@ -638,7 +707,20 @@ class TestGitRefView(BrowserTestCase):
log = self.makeCommitLog()
log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"]
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
view = create_initialized_view(ref, "+index")
contents = view()
expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]]
@@ -675,7 +757,20 @@ class TestGitRefView(BrowserTestCase):
[ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name])
log = self.makeCommitLog()
self.hosting_fixture.getLog.result = list(reversed(log))
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
view = create_initialized_view(ref, "+index")
recent_commits_tag = soupmatchers.Tag(
'recent commits', 'div', attrs={'id': 'recent-commits'})
@@ -734,7 +829,20 @@ class TestGitRefView(BrowserTestCase):
self.useFixture(FakeLogger())
[ref] = self.factory.makeGitRefs()
log = self.makeCommitLog()
- self.scanRef(ref, log[-1])
+ # XXX jugmac00 2022-03-14
+ # This is a workaround for the limitation of `GitHostingFixture` not
+ # implementing a proper `getCommits` method.
+ # If we would not supply the following configuration file,
+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
+ # would fail.
+ configuration = dedent("""\
+ pipeline: [test]
+ jobs:
+ test:
+ series: foo
+ architectures: ["bar"]
+ """)
+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
self.hosting_fixture.getLog.failure = TimeoutError
view = create_initialized_view(ref, "+index")
contents = view()
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index b3b4475..a697657 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -31,6 +31,7 @@ from zope.security.proxy import removeSecurityProxy
from lp.app.enums import InformationType
from lp.buildmaster.enums import BuildStatus
from lp.buildmaster.interfaces.processor import IProcessorSet
+from lp.code.tests.helpers import GitHostingFixture
from lp.oci.interfaces.ocipushrule import (
IOCIPushRuleSet,
OCIPushRuleAlreadyExists,
@@ -1296,6 +1297,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
def test_findByGitRepository(self):
# IOCIRecipeSet.findByGitRepository returns all OCI recipes with the
# given Git repository.
+ self.useFixture(GitHostingFixture())
repositories = [self.factory.makeGitRepository() for i in range(2)]
oci_recipes = []
for repository in repositories:
@@ -1338,6 +1340,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path]))
def test_detachFromGitRepository(self):
+ self.useFixture(GitHostingFixture())
repositories = [self.factory.makeGitRepository() for i in range(2)]
oci_recipes = []
paths = []