launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25164
[Merge] ~twom/launchpad:oci-build-path into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:oci-build-path into launchpad:master.
Commit message:
Add OCIRecipe.build_path
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/389241
Add build context directory to OCIRecipe to be passed to the buildd as a build argument.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-build-path into launchpad:master.
diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py
index 37f74a2..b290f42 100644
--- a/lib/lp/oci/interfaces/ocirecipe.py
+++ b/lib/lp/oci/interfaces/ocirecipe.py
@@ -383,6 +383,14 @@ class IOCIRecipeEditableAttributes(IHasOwner):
required=True,
readonly=False))
+ build_path = exported(TextLine(
+ title=_("Build directory context"),
+ description=_("Directory to use for build context "
+ "and OCIRecipe.build_file location."),
+ constraint=path_does_not_escape,
+ required=True,
+ readonly=False))
+
build_daily = exported(Bool(
title=_("Build daily"),
required=True,
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 0125114..e95c8c6 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -145,6 +145,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
git_repository = Reference(git_repository_id, "GitRepository.id")
git_path = Unicode(name="git_path", allow_none=True)
build_file = Unicode(name="build_file", allow_none=False)
+ build_path = Unicode(name="build_path", allow_none=False)
require_virtualized = Bool(name="require_virtualized", default=True,
allow_none=False)
@@ -156,7 +157,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
def __init__(self, name, registrant, owner, oci_project, git_ref,
description=None, official=False, require_virtualized=True,
build_file=None, build_daily=False, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
if not getFeatureFlag(OCI_RECIPE_ALLOW_CREATE):
raise OCIRecipeFeatureDisabled()
super(OCIRecipe, self).__init__()
@@ -173,6 +174,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
self.date_last_modified = date_created
self.git_ref = git_ref
self.allow_internet = allow_internet
+ self.build_path = build_path
def __repr__(self):
return "<OCIRecipe ~%s/%s/+oci/%s/+recipe/%s>" % (
@@ -532,7 +534,7 @@ class OCIRecipeSet:
def new(self, name, registrant, owner, oci_project, git_ref, build_file,
description=None, official=False, require_virtualized=True,
build_daily=False, processors=None, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
"""See `IOCIRecipeSet`."""
if not registrant.inTeam(owner):
if owner.is_team:
@@ -550,11 +552,14 @@ class OCIRecipeSet:
if self.exists(owner, oci_project, name):
raise DuplicateOCIRecipeName
+ if build_path is None:
+ build_path = "."
+
store = IMasterStore(OCIRecipe)
oci_recipe = OCIRecipe(
name, registrant, owner, oci_project, git_ref, description,
official, require_virtualized, build_file, build_daily,
- date_created, allow_internet)
+ date_created, allow_internet, build_path)
store.add(oci_recipe)
if processors is None:
diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py
index fce6dd3..844a2c8 100644
--- a/lib/lp/oci/model/ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py
@@ -96,6 +96,7 @@ class OCIRecipeBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase):
logger=logger))
args['build_file'] = build.recipe.build_file
+ args['build_path'] = build.recipe.build_path
if build.recipe.git_ref is not None:
args["git_repository"] = (
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index 880c351..024b8e7 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -799,7 +799,8 @@ class TestOCIRecipeSet(TestCaseWithFactory):
description='a description',
official=False,
require_virtualized=False,
- build_file='build file')
+ build_file='build file',
+ build_path='build path')
self.assertEqual(target.registrant, registrant)
self.assertEqual(target.owner, owner)
self.assertEqual(target.oci_project, oci_project)
@@ -992,7 +993,8 @@ class TestOCIRecipeWebservice(OCIConfigHelperMixin, TestCaseWithFactory):
git_ref_link=Equals(self.getAbsoluteURL(recipe.git_ref)),
description=Equals(recipe.description),
build_file=Equals(recipe.build_file),
- build_daily=Equals(recipe.build_daily)
+ build_daily=Equals(recipe.build_daily),
+ build_path=Equals(recipe.build_path)
)))
def test_api_patch_oci_recipe(self):
diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
index 3fdf8b4..bbc1ee6 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
@@ -242,6 +242,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory):
"archives": Equals(expected_archives),
"arch_tag": Equals("i386"),
"build_file": Equals(job.build.recipe.build_file),
+ "build_path": Equals(job.build.recipe.build_path),
"build_url": Equals(canonical_url(job.build)),
"fast_cleanup": Is(True),
"git_repository": Equals(ref.repository.git_https_url),
@@ -272,6 +273,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory):
"archives": Equals(expected_archives),
"arch_tag": Equals("i386"),
"build_file": Equals(job.build.recipe.build_file),
+ "build_path": Equals(job.build.recipe.build_path),
"build_url": Equals(canonical_url(job.build)),
"fast_cleanup": Is(True),
"git_repository": Equals(ref.repository.git_https_url),
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 431cce1..a6a04bc 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -4999,7 +4999,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
oci_project=None, git_ref=None, description=None,
official=False, require_virtualized=True,
build_file=None, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
"""Make a new OCIRecipe."""
if name is None:
name = self.getUniqueString(u"oci-recipe-name")
@@ -5015,6 +5015,8 @@ class BareLaunchpadObjectFactory(ObjectFactory):
[git_ref] = self.makeGitRefs()
if build_file is None:
build_file = self.getUniqueUnicode(u"build_file_for")
+ if build_path is None:
+ build_path = self.getUniqueUnicode(u"build_path_for")
return getUtility(IOCIRecipeSet).new(
name=name,
registrant=registrant,
@@ -5022,6 +5024,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
oci_project=oci_project,
git_ref=git_ref,
build_file=build_file,
+ build_path=build_path,
description=description,
official=official,
require_virtualized=require_virtualized,