From 95bb147015e116df48e0bd1f197ed6418bf0c76f Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Mar 13 2018 14:54:52 +0000 Subject: buildinstall: Add option to disable it Fixes: https://pagure.io/pungi/issue/854 Signed-off-by: Lubomír Sedlář --- diff --git a/doc/configuration.rst b/doc/configuration.rst index dbe5ba0..e5f1e9e 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -504,6 +504,11 @@ Options task using HTTP and set the output directory for this task to ``buildinstall_topdir``. Once the runroot task finishes, Pungi will copy the results of runroot tasks to the compose working directory. +**buildinstall_skip** + (*list*) -- mapping that defines which variants and arches to skip during + buildinstall; format: ``[(variant_uid_regex, {arch|*: True})]``. This is + only supported for lorax. + Example ------- @@ -525,6 +530,13 @@ Example }) ] + # Don't run buildinstall phase for Modular variant + buildinstall_skip = [ + ('^Modular', { + '*': True + }) + ] + .. note:: diff --git a/pungi/checks.py b/pungi/checks.py index c6082ea..36764f2 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -727,6 +727,7 @@ def make_schema(): "buildinstall_topdir": {"type": "string"}, "buildinstall_kickstart": {"$ref": "#/definitions/str_or_scm_dict"}, "buildinstall_use_guestmount": {"type": "boolean", "default": True}, + "buildinstall_skip": _variant_arch_mapping({"type": "boolean"}), "global_ksurl": {"type": "string"}, "global_version": {"type": "string"}, diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index 69813c2..3ec523b 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -134,10 +134,18 @@ class BuildinstallPhase(PhaseBase): repo_baseurl = translate_path(self.compose, repo_baseurl) if self.buildinstall_method == "lorax": + buildarch = get_valid_arches(arch)[0] for variant in self.compose.get_variants(arch=arch, types=['variant']): if variant.is_empty: continue + + skip = get_arch_variant_data(self.compose.conf, "buildinstall_skip", arch, variant) + if skip == [True]: + self.compose.log_info( + 'Skipping buildinstall for %s.%s due to config option' % (variant, arch)) + continue + volid = get_volid(self.compose, arch, variant=variant, disc_type=disc_type) commands.append( (variant, diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 335b0d2..aa8f527 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -43,6 +43,33 @@ class TestBuildinstallPhase(PungiTestCase): self.assertTrue(phase.skip()) + @mock.patch('pungi.phases.buildinstall.ThreadPool') + @mock.patch('pungi.phases.buildinstall.LoraxWrapper') + @mock.patch('pungi.phases.buildinstall.get_volid') + def test_skip_option(self, get_volid, loraxCls, poolCls): + compose = BuildInstallCompose(self.topdir, { + 'bootable': True, + 'buildinstall_method': 'lorax', + 'buildinstall_skip': [ + ('^Server$', { + 'amd64': True + }), + ('^Client$', { + '*': True, + }), + ] + }) + + get_volid.return_value = 'vol_id' + loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...'] + + phase = BuildinstallPhase(compose) + + phase.run() + + pool = poolCls.return_value + self.assertEqual(1, len(pool.queue_put.mock_calls)) + def test_does_not_skip_on_bootable(self): compose = BuildInstallCompose(self.topdir, {'bootable': True}) compose.just_phases = None