#434 Remove the ability to parse a module's branch automatically to determine the base module stream override
Merged 5 years ago by onosek. Opened 5 years ago by mprahl.

file modified
+1 -38
@@ -2134,50 +2134,13 @@ 

              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)

@@ -17,7 +17,3 @@ 

  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

file modified
-82
@@ -2205,88 +2205,6 @@ 

          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):

          """

This functionality was moved to MBS directly instead of having rpkg do it:
https://pagure.io/fm-orchestrator/pull-request/1176

Does the user experience change with this patch?

Anyway :thumbsup: from me.

@lsedlar the UX should be similar, but it is removing functionality from rpkg, so that'd likely require a major version bump.

Yes, I will look at it. Just, please, rebase it. There are some confict due to previous merged pull-request. Thanks.

rebased onto cb6431b

5 years ago

Thanks @onosek. It's rebased now.

Pagure is probably facing some issue. It is still waiting for merge since my last post.

Pull-Request has been merged by onosek

5 years ago