← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/git-recipe-build-behaviour into lp:launchpad.

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1453022 in Launchpad itself: "Please support daily builds via git"
  https://bugs.launchpad.net/launchpad/+bug/1453022

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-recipe-build-behaviour/+merge/282723

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

Compare: https://code.launchpad.net/~cjwatson/launchpad-buildd/git-recipes/+merge/281680
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-recipe-build-behaviour into lp:launchpad.
=== 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 @@
             required=True, readonly=True,
             vocabulary='ValidPersonOrTeam'))
 
+    def getRecipeText(validate=False):
+        """Return the text of this recipe.
+
+        :param validate: If True, check that the recipe text can be parsed.
+        """
+
     recipe_text = exported(Text(readonly=True))
 
     pending_builds = exported(doNotSnapshot(

=== 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 @@
-# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Code to build recipes on the buildfarm."""
@@ -60,7 +60,7 @@
             # Don't keep the naked requester around though.
             args["author_email"] = removeSecurityProxy(
                 requester).preferredemail.email
-        args["recipe_text"] = str(self.build.recipe.builder_recipe)
+        args["recipe_text"] = self.build.recipe.getRecipeText(validate=True)
         args['archive_purpose'] = self.build.archive.purpose.name
         args["ogrecomponent"] = get_primary_current_component(
             self.build.archive, self.build.distroseries,
@@ -71,6 +71,8 @@
             logger=logger)
         args['archive_private'] = self.build.archive.private
         args['distroseries_name'] = self.build.distroseries.name
+        if self.build.recipe.base_git_repository is not None:
+            args['git'] = True
         return args
 
     def composeBuildRequest(self, logger):

=== 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 @@
         parsed = getUtility(IRecipeBranchSource).getParsedRecipe(recipe_text)
         self._recipe_data.setRecipe(parsed)
 
-    @property
-    def recipe_text(self):
-        recipe_text = self.builder_recipe.get_recipe_text()
+    def getRecipeText(self, validate=False):
+        """See `ISourcePackageRecipe`."""
+        recipe_text = self.builder_recipe.get_recipe_text(validate=validate)
         # For git-based recipes, mangle the header line to say
         # "git-build-recipe" to reduce confusion; bzr-builder's recipe
         # parser will always round-trip this to "bzr-builder".
@@ -195,6 +195,10 @@
                 r"^(#\s*)bzr-builder", r"\1git-build-recipe", recipe_text)
         return recipe_text
 
+    @property
+    def recipe_text(self):
+        return self.getRecipeText()
+
     def updateSeries(self, distroseries):
         if distroseries != self.distroseries:
             self.distroseries.clear()

=== 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 @@
-# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test RecipeBuildBehaviour."""
@@ -54,7 +54,7 @@
     layer = LaunchpadZopelessLayer
 
     def makeJob(self, recipe_registrant=None, recipe_owner=None,
-                archive=None):
+                archive=None, git=False):
         """Create a sample `ISourcePackageRecipeBuild`."""
         spn = self.factory.makeSourcePackageName("apackage")
         distro = self.factory.makeDistribution(name="distro")
@@ -70,9 +70,15 @@
                 name="joe", displayname="Joe User")
         if recipe_owner is None:
             recipe_owner = recipe_registrant
-        somebranch = self.factory.makeBranch(
-            owner=recipe_owner, name="pkg",
-            product=self.factory.makeProduct("someapp"))
+        if git:
+            [somebranch] = self.factory.makeGitRefs(
+                owner=recipe_owner, name=u"pkg",
+                target=self.factory.makeProduct("someapp"),
+                paths=[u"refs/heads/packaging"])
+        else:
+            somebranch = self.factory.makeBranch(
+                owner=recipe_owner, name="pkg",
+                product=self.factory.makeProduct("someapp"))
         recipe = self.factory.makeSourcePackageRecipe(
             recipe_registrant, recipe_owner, distroseries, u"recept",
             u"Recipe description", branches=[somebranch])
@@ -251,6 +257,28 @@
             job.build, distroarchseries, None)
         self.assertEqual(args["archives"], expected_archives)
 
+    def test_extraBuildArgs_git(self):
+        job = self.makeJob(git=True)
+        distroarchseries = job.build.distroseries.architectures[0]
+        expected_archives = get_sources_list_for_building(
+            job.build, distroarchseries, None)
+        self.assertEqual({
+            'archive_private': False,
+            'arch_tag': 'i386',
+            'author_email': u'requester@xxxxxxxxxx',
+            'suite': u'mydistro',
+            'author_name': u'Joe User',
+            'archive_purpose': 'PPA',
+            'ogrecomponent': 'universe',
+            'recipe_text':
+                '# git-build-recipe format 0.4 deb-version '
+                '{debupstream}-0~{revtime}\n'
+                'lp:~joe/someapp/+git/pkg packaging\n',
+            'archives': expected_archives,
+            'distroseries_name': job.build.distroseries.name,
+            'git': True,
+            }, job._extraBuildArgs(distroarchseries))
+
     def test_getByID(self):
         job = self.makeJob()
         transaction.commit()


Follow ups