Merge lp:~cjwatson/launchpad/git-recipe-build-behaviour into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17899
Proposed branch: lp:~cjwatson/launchpad/git-recipe-build-behaviour
Merge into: lp:launchpad
Diff against target: 139 lines (+50/-10)
4 files modified
lib/lp/code/interfaces/sourcepackagerecipe.py (+6/-0)
lib/lp/code/model/recipebuilder.py (+4/-2)
lib/lp/code/model/sourcepackagerecipe.py (+7/-3)
lib/lp/code/model/tests/test_recipebuilder.py (+33/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/git-recipe-build-behaviour
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+282723@code.launchpad.net

Commit message

Pass git=True to the recipe builder if building a Git recipe.

Description of the change

Pass git=True to the recipe builder if building a Git recipe.

Compare: https://code.launchpad.net/~cjwatson/launchpad-buildd/git-recipes/+merge/281680

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
--- lib/lp/code/interfaces/sourcepackagerecipe.py 2016-01-12 01:24:06 +0000
+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2016-01-15 11:54:53 +0000
@@ -140,6 +140,12 @@
140 required=True, readonly=True,140 required=True, readonly=True,
141 vocabulary='ValidPersonOrTeam'))141 vocabulary='ValidPersonOrTeam'))
142142
143 def getRecipeText(validate=False):
144 """Return the text of this recipe.
145
146 :param validate: If True, check that the recipe text can be parsed.
147 """
148
143 recipe_text = exported(Text(readonly=True))149 recipe_text = exported(Text(readonly=True))
144150
145 pending_builds = exported(doNotSnapshot(151 pending_builds = exported(doNotSnapshot(
146152
=== modified file 'lib/lp/code/model/recipebuilder.py'
--- lib/lp/code/model/recipebuilder.py 2015-08-04 11:03:04 +0000
+++ lib/lp/code/model/recipebuilder.py 2016-01-15 11:54:53 +0000
@@ -1,4 +1,4 @@
1# Copyright 2010-2014 Canonical Ltd. This software is licensed under the1# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Code to build recipes on the buildfarm."""4"""Code to build recipes on the buildfarm."""
@@ -60,7 +60,7 @@
60 # Don't keep the naked requester around though.60 # Don't keep the naked requester around though.
61 args["author_email"] = removeSecurityProxy(61 args["author_email"] = removeSecurityProxy(
62 requester).preferredemail.email62 requester).preferredemail.email
63 args["recipe_text"] = str(self.build.recipe.builder_recipe)63 args["recipe_text"] = self.build.recipe.getRecipeText(validate=True)
64 args['archive_purpose'] = self.build.archive.purpose.name64 args['archive_purpose'] = self.build.archive.purpose.name
65 args["ogrecomponent"] = get_primary_current_component(65 args["ogrecomponent"] = get_primary_current_component(
66 self.build.archive, self.build.distroseries,66 self.build.archive, self.build.distroseries,
@@ -71,6 +71,8 @@
71 logger=logger)71 logger=logger)
72 args['archive_private'] = self.build.archive.private72 args['archive_private'] = self.build.archive.private
73 args['distroseries_name'] = self.build.distroseries.name73 args['distroseries_name'] = self.build.distroseries.name
74 if self.build.recipe.base_git_repository is not None:
75 args['git'] = True
74 return args76 return args
7577
76 def composeBuildRequest(self, logger):78 def composeBuildRequest(self, logger):
7779
=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
--- lib/lp/code/model/sourcepackagerecipe.py 2016-01-12 01:24:06 +0000
+++ lib/lp/code/model/sourcepackagerecipe.py 2016-01-15 11:54:53 +0000
@@ -184,9 +184,9 @@
184 parsed = getUtility(IRecipeBranchSource).getParsedRecipe(recipe_text)184 parsed = getUtility(IRecipeBranchSource).getParsedRecipe(recipe_text)
185 self._recipe_data.setRecipe(parsed)185 self._recipe_data.setRecipe(parsed)
186186
187 @property187 def getRecipeText(self, validate=False):
188 def recipe_text(self):188 """See `ISourcePackageRecipe`."""
189 recipe_text = self.builder_recipe.get_recipe_text()189 recipe_text = self.builder_recipe.get_recipe_text(validate=validate)
190 # For git-based recipes, mangle the header line to say190 # For git-based recipes, mangle the header line to say
191 # "git-build-recipe" to reduce confusion; bzr-builder's recipe191 # "git-build-recipe" to reduce confusion; bzr-builder's recipe
192 # parser will always round-trip this to "bzr-builder".192 # parser will always round-trip this to "bzr-builder".
@@ -195,6 +195,10 @@
195 r"^(#\s*)bzr-builder", r"\1git-build-recipe", recipe_text)195 r"^(#\s*)bzr-builder", r"\1git-build-recipe", recipe_text)
196 return recipe_text196 return recipe_text
197197
198 @property
199 def recipe_text(self):
200 return self.getRecipeText()
201
198 def updateSeries(self, distroseries):202 def updateSeries(self, distroseries):
199 if distroseries != self.distroseries:203 if distroseries != self.distroseries:
200 self.distroseries.clear()204 self.distroseries.clear()
201205
=== modified file 'lib/lp/code/model/tests/test_recipebuilder.py'
--- lib/lp/code/model/tests/test_recipebuilder.py 2015-08-04 11:03:04 +0000
+++ lib/lp/code/model/tests/test_recipebuilder.py 2016-01-15 11:54:53 +0000
@@ -1,4 +1,4 @@
1# Copyright 2010-2014 Canonical Ltd. This software is licensed under the1# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test RecipeBuildBehaviour."""4"""Test RecipeBuildBehaviour."""
@@ -54,7 +54,7 @@
54 layer = LaunchpadZopelessLayer54 layer = LaunchpadZopelessLayer
5555
56 def makeJob(self, recipe_registrant=None, recipe_owner=None,56 def makeJob(self, recipe_registrant=None, recipe_owner=None,
57 archive=None):57 archive=None, git=False):
58 """Create a sample `ISourcePackageRecipeBuild`."""58 """Create a sample `ISourcePackageRecipeBuild`."""
59 spn = self.factory.makeSourcePackageName("apackage")59 spn = self.factory.makeSourcePackageName("apackage")
60 distro = self.factory.makeDistribution(name="distro")60 distro = self.factory.makeDistribution(name="distro")
@@ -70,9 +70,15 @@
70 name="joe", displayname="Joe User")70 name="joe", displayname="Joe User")
71 if recipe_owner is None:71 if recipe_owner is None:
72 recipe_owner = recipe_registrant72 recipe_owner = recipe_registrant
73 somebranch = self.factory.makeBranch(73 if git:
74 owner=recipe_owner, name="pkg",74 [somebranch] = self.factory.makeGitRefs(
75 product=self.factory.makeProduct("someapp"))75 owner=recipe_owner, name=u"pkg",
76 target=self.factory.makeProduct("someapp"),
77 paths=[u"refs/heads/packaging"])
78 else:
79 somebranch = self.factory.makeBranch(
80 owner=recipe_owner, name="pkg",
81 product=self.factory.makeProduct("someapp"))
76 recipe = self.factory.makeSourcePackageRecipe(82 recipe = self.factory.makeSourcePackageRecipe(
77 recipe_registrant, recipe_owner, distroseries, u"recept",83 recipe_registrant, recipe_owner, distroseries, u"recept",
78 u"Recipe description", branches=[somebranch])84 u"Recipe description", branches=[somebranch])
@@ -251,6 +257,28 @@
251 job.build, distroarchseries, None)257 job.build, distroarchseries, None)
252 self.assertEqual(args["archives"], expected_archives)258 self.assertEqual(args["archives"], expected_archives)
253259
260 def test_extraBuildArgs_git(self):
261 job = self.makeJob(git=True)
262 distroarchseries = job.build.distroseries.architectures[0]
263 expected_archives = get_sources_list_for_building(
264 job.build, distroarchseries, None)
265 self.assertEqual({
266 'archive_private': False,
267 'arch_tag': 'i386',
268 'author_email': u'requester@ubuntu.com',
269 'suite': u'mydistro',
270 'author_name': u'Joe User',
271 'archive_purpose': 'PPA',
272 'ogrecomponent': 'universe',
273 'recipe_text':
274 '# git-build-recipe format 0.4 deb-version '
275 '{debupstream}-0~{revtime}\n'
276 'lp:~joe/someapp/+git/pkg packaging\n',
277 'archives': expected_archives,
278 'distroseries_name': job.build.distroseries.name,
279 'git': True,
280 }, job._extraBuildArgs(distroarchseries))
281
254 def test_getByID(self):282 def test_getByID(self):
255 job = self.makeJob()283 job = self.makeJob()
256 transaction.commit()284 transaction.commit()