From cb6431ba66926e0707cf09621e833f781e4d730e Mon Sep 17 00:00:00 2001 From: mprahl Date: Apr 09 2019 15:51:46 +0000 Subject: Remove the ability to parse a module's branch automatically to determine the base module stream override This functionality was moved to MBS directly instead of having rpkg do it: https://pagure.io/fm-orchestrator/pull-request/1176 Signed-off-by: mprahl --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 1f4bcdb..63e60b4 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -2134,50 +2134,13 @@ see API KEY section of copr-cli(1) man page. if not modmd_path: raise(e) - buildrequires = self.args.buildrequires or [] - branch_search = None - if branch: - try: - # The regexes to parse the base module stream override from the dist-git branch - # name. For example, if you had a branch called `10-fedora-29.0.1` and you wanted to - # parse `f29.0.1` from that as the stream to use for the base module, you could - # have a regex of `(f)(?:edora)(?:\-)(\d+\.\d+\.\d+)$`. Then after combining - # the capture groups, you'd get the desired result of `f29.0.1`. - branch_bm_regexes = self.config.get( - self.config_section, 'base_module_stream_regex_from_branch').strip().split('\n') - # The base module (e.g. platform) to apply the buildrequire override to if the - # parsing of the branch name is successfull - bm = self.config.get(self.config_section, 'base_module') - except configparser.NoOptionError: - pass - else: - # Check if any of the regexes match, and break after the first match - for regex in branch_bm_regexes: - branch_search = re.search(regex, branch) - if branch_search: - break - - if branch_search: - # Concatenate all the groups that are not None together to get the desired stream. - # This approach is taken in case there are sections to ignore. - # For instance, if we need to parse `f27.0.0` from `fedora-27.0.0`. - bm_stream = ''.join(group for group in branch_search.groups() if group) - # Don't override the base module buildrequire if the user - # manually already overrode it with the `--buildrequire` argument - if not any(br[0] == bm for br in buildrequires): - buildrequires.append((bm, bm_stream)) - if not self.args.q: - print('Added the buildrequire override "{0}" based on ' - 'the module branch name' - .format('{0}:{1}'.format(bm, bm_stream))) - auth_method, oidc_id_provider, oidc_client_id, oidc_client_secret, \ oidc_scopes = self.module_get_auth_config() if not self.args.q: print('Submitting the module build...') build_ids = self._cmd.module_submit_build( - scm_url, branch, auth_method, buildrequires, self.args.requires, + scm_url, branch, auth_method, self.args.buildrequires, self.args.requires, self.args.optional, oidc_id_provider, oidc_client_id, oidc_client_secret, oidc_scopes, self.args.scratch, modmd_path, srpm_links) diff --git a/tests/fixtures/rpkg.conf b/tests/fixtures/rpkg.conf index 0a3a79e..241194e 100644 --- a/tests/fixtures/rpkg.conf +++ b/tests/fixtures/rpkg.conf @@ -17,7 +17,3 @@ oidc_id_provider = https://id.fedoraproject.org/openidc/ oidc_client_id = mbs-authorizer oidc_client_secret = notsecret oidc_scopes = openid,https://id.fedoraproject.org/scope/groups,https://mbs.fedoraproject.org/oidc/submit-build -base_module_stream_regex_from_branch = - (f)(?:edora)(?:\-)(\d+\.\d+\.\d+)$ - (?:\-LP\-)(.+)$ -base_module = platform diff --git a/tests/test_cli.py b/tests/test_cli.py index 85874ad..ffea852 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2205,88 +2205,6 @@ class TestModulesCli(FakeKojiCreds, CliTestCase): reqs = mock_oidc_req.call_args[1]['json']['require_overrides'] assert reqs['platform'] == ['f29'] - @patch('requests.get') - @patch('openidc_client.OpenIDCClient.send_request') - def test_module_build_override_from_branch(self, mock_oidc_req, mock_get): - """ - Test a module build with dep overrides from the branch name - """ - cli_cmd = [ - 'rpkg', - '--path', self.cloned_repo_path, - 'module-build', - 'git://pkgs.fedoraproject.org/modules/testmodule?#79d87a5a', - '10-LP-f27.0.1' - ] - mock_get.return_value.ok = True - mock_get.return_value.json.return_value = { - 'auth_method': 'oidc', - 'api_version': 2 - } - mock_oidc_req.return_value.json.return_value = [{'id': 1094}] - - with patch('sys.argv', new=cli_cmd): - cli = self.new_cli() - cli.module_build() - - exp_json = { - 'scmurl': ('git://pkgs.fedoraproject.org/modules/testmodule?' - '#79d87a5a'), - 'branch': '10-LP-f27.0.1', - 'scratch': False, - 'buildrequire_overrides': {'platform': ['f27.0.1']} - } - exp_url = ('https://mbs.fedoraproject.org/module-build-service/2/' - 'module-builds/') - mock_oidc_req.assert_called_once_with( - exp_url, - http_method='POST', - json=exp_json, - scopes=self.scopes, - timeout=120) - - @patch('requests.get') - @patch('openidc_client.OpenIDCClient.send_request') - def test_module_build_override_from_branch_with_manual_input( - self, mock_oidc_req, mock_get): - """ - Test that dep overrides aren't preferred over manual input - """ - cli_cmd = [ - 'rpkg', - '--path', self.cloned_repo_path, - 'module-build', - 'git://pkgs.fedoraproject.org/modules/testmodule?#79d87a5a', - '10-fedora-27.0.1', - '--buildrequire', 'platform:f29' - ] - mock_get.return_value.ok = True - mock_get.return_value.json.return_value = { - 'auth_method': 'oidc', - 'api_version': 2 - } - mock_oidc_req.return_value.json.return_value = [{'id': 1094}] - - with patch('sys.argv', new=cli_cmd): - cli = self.new_cli() - cli.module_build() - - exp_json = { - 'scmurl': ('git://pkgs.fedoraproject.org/modules/testmodule?' - '#79d87a5a'), - 'branch': '10-fedora-27.0.1', - 'scratch': False, - 'buildrequire_overrides': {'platform': ['f29']} - } - exp_url = ('https://mbs.fedoraproject.org/module-build-service/2/' - 'module-builds/') - mock_oidc_req.assert_called_once_with( - exp_url, - http_method='POST', - json=exp_json, - scopes=self.scopes, - timeout=120) - @patch('sys.stderr', new_callable=StringIO) def test_module_build_conflicting_keys(self, stderr): """