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

Proposed by Colin Watson on 2016-01-15
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 2016-01-15 Approve on 2016-01-18
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.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
2--- lib/lp/code/interfaces/sourcepackagerecipe.py 2016-01-12 01:24:06 +0000
3+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2016-01-15 11:54:53 +0000
4@@ -140,6 +140,12 @@
5 required=True, readonly=True,
6 vocabulary='ValidPersonOrTeam'))
7
8+ def getRecipeText(validate=False):
9+ """Return the text of this recipe.
10+
11+ :param validate: If True, check that the recipe text can be parsed.
12+ """
13+
14 recipe_text = exported(Text(readonly=True))
15
16 pending_builds = exported(doNotSnapshot(
17
18=== modified file 'lib/lp/code/model/recipebuilder.py'
19--- lib/lp/code/model/recipebuilder.py 2015-08-04 11:03:04 +0000
20+++ lib/lp/code/model/recipebuilder.py 2016-01-15 11:54:53 +0000
21@@ -1,4 +1,4 @@
22-# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
23+# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
24 # GNU Affero General Public License version 3 (see the file LICENSE).
25
26 """Code to build recipes on the buildfarm."""
27@@ -60,7 +60,7 @@
28 # Don't keep the naked requester around though.
29 args["author_email"] = removeSecurityProxy(
30 requester).preferredemail.email
31- args["recipe_text"] = str(self.build.recipe.builder_recipe)
32+ args["recipe_text"] = self.build.recipe.getRecipeText(validate=True)
33 args['archive_purpose'] = self.build.archive.purpose.name
34 args["ogrecomponent"] = get_primary_current_component(
35 self.build.archive, self.build.distroseries,
36@@ -71,6 +71,8 @@
37 logger=logger)
38 args['archive_private'] = self.build.archive.private
39 args['distroseries_name'] = self.build.distroseries.name
40+ if self.build.recipe.base_git_repository is not None:
41+ args['git'] = True
42 return args
43
44 def composeBuildRequest(self, logger):
45
46=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
47--- lib/lp/code/model/sourcepackagerecipe.py 2016-01-12 01:24:06 +0000
48+++ lib/lp/code/model/sourcepackagerecipe.py 2016-01-15 11:54:53 +0000
49@@ -184,9 +184,9 @@
50 parsed = getUtility(IRecipeBranchSource).getParsedRecipe(recipe_text)
51 self._recipe_data.setRecipe(parsed)
52
53- @property
54- def recipe_text(self):
55- recipe_text = self.builder_recipe.get_recipe_text()
56+ def getRecipeText(self, validate=False):
57+ """See `ISourcePackageRecipe`."""
58+ recipe_text = self.builder_recipe.get_recipe_text(validate=validate)
59 # For git-based recipes, mangle the header line to say
60 # "git-build-recipe" to reduce confusion; bzr-builder's recipe
61 # parser will always round-trip this to "bzr-builder".
62@@ -195,6 +195,10 @@
63 r"^(#\s*)bzr-builder", r"\1git-build-recipe", recipe_text)
64 return recipe_text
65
66+ @property
67+ def recipe_text(self):
68+ return self.getRecipeText()
69+
70 def updateSeries(self, distroseries):
71 if distroseries != self.distroseries:
72 self.distroseries.clear()
73
74=== modified file 'lib/lp/code/model/tests/test_recipebuilder.py'
75--- lib/lp/code/model/tests/test_recipebuilder.py 2015-08-04 11:03:04 +0000
76+++ lib/lp/code/model/tests/test_recipebuilder.py 2016-01-15 11:54:53 +0000
77@@ -1,4 +1,4 @@
78-# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
79+# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
80 # GNU Affero General Public License version 3 (see the file LICENSE).
81
82 """Test RecipeBuildBehaviour."""
83@@ -54,7 +54,7 @@
84 layer = LaunchpadZopelessLayer
85
86 def makeJob(self, recipe_registrant=None, recipe_owner=None,
87- archive=None):
88+ archive=None, git=False):
89 """Create a sample `ISourcePackageRecipeBuild`."""
90 spn = self.factory.makeSourcePackageName("apackage")
91 distro = self.factory.makeDistribution(name="distro")
92@@ -70,9 +70,15 @@
93 name="joe", displayname="Joe User")
94 if recipe_owner is None:
95 recipe_owner = recipe_registrant
96- somebranch = self.factory.makeBranch(
97- owner=recipe_owner, name="pkg",
98- product=self.factory.makeProduct("someapp"))
99+ if git:
100+ [somebranch] = self.factory.makeGitRefs(
101+ owner=recipe_owner, name=u"pkg",
102+ target=self.factory.makeProduct("someapp"),
103+ paths=[u"refs/heads/packaging"])
104+ else:
105+ somebranch = self.factory.makeBranch(
106+ owner=recipe_owner, name="pkg",
107+ product=self.factory.makeProduct("someapp"))
108 recipe = self.factory.makeSourcePackageRecipe(
109 recipe_registrant, recipe_owner, distroseries, u"recept",
110 u"Recipe description", branches=[somebranch])
111@@ -251,6 +257,28 @@
112 job.build, distroarchseries, None)
113 self.assertEqual(args["archives"], expected_archives)
114
115+ def test_extraBuildArgs_git(self):
116+ job = self.makeJob(git=True)
117+ distroarchseries = job.build.distroseries.architectures[0]
118+ expected_archives = get_sources_list_for_building(
119+ job.build, distroarchseries, None)
120+ self.assertEqual({
121+ 'archive_private': False,
122+ 'arch_tag': 'i386',
123+ 'author_email': u'requester@ubuntu.com',
124+ 'suite': u'mydistro',
125+ 'author_name': u'Joe User',
126+ 'archive_purpose': 'PPA',
127+ 'ogrecomponent': 'universe',
128+ 'recipe_text':
129+ '# git-build-recipe format 0.4 deb-version '
130+ '{debupstream}-0~{revtime}\n'
131+ 'lp:~joe/someapp/+git/pkg packaging\n',
132+ 'archives': expected_archives,
133+ 'distroseries_name': job.build.distroseries.name,
134+ 'git': True,
135+ }, job._extraBuildArgs(distroarchseries))
136+
137 def test_getByID(self):
138 job = self.makeJob()
139 transaction.commit()