diff --git a/osbs/api.py b/osbs/api.py index a98320ac..54a5af3b 100644 --- a/osbs/api.py +++ b/osbs/api.py @@ -744,14 +744,6 @@ def _do_create_prod_build(self, if missing_params: raise OsbsException('required parameter {} missing'.format(", ".join(missing_params))) - if flatpak: - if isolated: - # Flatpak builds from a particular stream autogenerate the release - # as .; it doesn't make sense to make a fix - # from specific one of these autogenerated version. What an isolated - # fix for module requires will have to be determined from experience. - raise ValueError("Flatpak build cannot be isolated") - if not git_branch: raise OsbsValidationException("required argument 'git_branch' can't be None") diff --git a/osbs/build/plugins_configuration.py b/osbs/build/plugins_configuration.py index 8060f50d..e44f6dd6 100644 --- a/osbs/build/plugins_configuration.py +++ b/osbs/build/plugins_configuration.py @@ -277,7 +277,7 @@ def render_bump_release(self): # For flatpak, we want a name-version-release of # --., where the . makes # sure that the build is unique in Koji - if self.user_params.flatpak: + if self.user_params.flatpak and not self.user_params.isolated: self.pt.set_plugin_arg(phase, plugin, 'append', True) def render_check_and_set_platforms(self): diff --git a/tests/build_/test_plugins_configuration.py b/tests/build_/test_plugins_configuration.py index 34108453..e1c526e2 100644 --- a/tests/build_/test_plugins_configuration.py +++ b/tests/build_/test_plugins_configuration.py @@ -291,6 +291,9 @@ def check_plugin_presence(self, build_type, plugins, invited_plugins, uninvited_ with pytest.raises(NoSuchPluginException): get_plugin(plugins, phase, plugin) + @pytest.mark.parametrize(('release', 'isolated'), + [(None, False), + ('1.0', True)]) @pytest.mark.parametrize('build_type', (BUILD_TYPE_ORCHESTRATOR, BUILD_TYPE_WORKER)) @pytest.mark.parametrize(('compose_ids', 'signing_intent'), [(None, None), @@ -299,13 +302,15 @@ def check_plugin_presence(self, build_type, plugins, invited_plugins, uninvited_ ([], 'release'), ([42], None), ([42, 2], None)]) - def test_render_flatpak(self, compose_ids, signing_intent, build_type): + def test_render_flatpak(self, release, isolated, compose_ids, signing_intent, build_type): extra_args = { 'flatpak': True, + 'isolated': isolated, 'compose_ids': compose_ids, 'signing_intent': signing_intent, 'base_image': TEST_FLATPAK_BASE_IMAGE, 'build_type': build_type, + 'release': release, } user_params = get_sample_user_params(extra_args=extra_args) @@ -343,8 +348,11 @@ def test_render_flatpak(self, compose_ids, signing_intent, build_type): plugin = get_plugin(plugins, "prebuild_plugins", "bump_release") assert plugin - args = plugin['args'] - assert args['append'] is True + if isolated: + assert 'args' not in plugin + else: + args = plugin['args'] + assert args['append'] is True else: plugin = get_plugin(plugins, "prebuild_plugins", "koji") assert plugin diff --git a/tests/test_api.py b/tests/test_api.py index e5f0a001..06df1381 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -2601,7 +2601,7 @@ def __init__(self, isolated): self.git_branch = TEST_GIT_BRANCH self.koji_parent_build = None self.flatpak = True - self.signing_intent = 'release' + self.signing_intent = None self.compose_ids = [1, 2] self.skip_build = False self.operator_csv_modifications_url = None @@ -2609,7 +2609,7 @@ def __init__(self, isolated): expected_kwargs = { 'platform': None, 'scratch': None, - 'isolated': False, + 'isolated': isolated, 'platforms': 'platforms', 'release': None, 'flatpak': True, @@ -2623,7 +2623,7 @@ def __init__(self, isolated): 'yum_repourls': None, 'dependency_replacements': None, 'koji_parent_build': None, - 'signing_intent': 'release', + 'signing_intent': None, 'compose_ids': [1, 2], 'skip_build': False, 'operator_csv_modifications_url': None, @@ -2631,8 +2631,9 @@ def __init__(self, isolated): (flexmock(utils) .should_receive('get_repo_info') - .with_args(TEST_GIT_URI, TEST_GIT_REF, git_branch=TEST_GIT_BRANCH, depth=None) - .and_return(self.mock_repo_info(mock_config=MockConfiguration(modules=TEST_MODULES)))) + .with_args(None, None, git_branch=TEST_GIT_BRANCH, depth=None) + .and_return(self.mock_repo_info(mock_config=MockConfiguration(modules=TEST_MODULES, + is_flatpak=True)))) args = MockArgs(isolated) # Some of the command line arguments are pulled through the config @@ -2640,21 +2641,29 @@ def __init__(self, isolated): osbs.build_conf.args = args flexmock(osbs.build_conf, get_git_branch=lambda: TEST_GIT_BRANCH) - if not isolated: - # and_raise is called to prevent cmd_build to continue - # as we only want to check if arguments are correct + (flexmock(osbs) + .should_call("create_orchestrator_build") + .once() + .with_args(**expected_kwargs)) + + exc_msg = "stop for test" + # and_raise is called to prevent cmd_build to continue + # as we only want to check if arguments are correct + if isolated: (flexmock(osbs) - .should_receive("create_orchestrator_build") + .should_receive("_create_isolated_build") .once() - .with_args(**expected_kwargs) - .and_raise(CustomTestException)) - with pytest.raises(CustomTestException): - cmd_build(args, osbs) + .and_raise(CustomTestException(exc_msg))) else: - with pytest.raises(OsbsException) as exc_info: - cmd_build(args, osbs) - assert isinstance(exc_info.value.cause, ValueError) - assert "Flatpak build cannot be isolated" in exc_info.value.message + (flexmock(osbs) + .should_receive("_create_build_config_and_build") + .once() + .and_raise(CustomTestException(exc_msg))) + + with pytest.raises(OsbsException) as exc: + cmd_build(args, osbs) + + assert exc_msg in str(exc.value) @pytest.mark.parametrize('isolated', [True, False]) def test_operator_csv_modifications_url_cli(self, osbs, isolated):