#401 Make it easier to opt-out from the playground
Closed 3 years ago by onosek. Opened 3 years ago by onosek.
onosek/fedpkg playground_opt_out  into  master

file modified
+25 -14
@@ -323,16 +323,13 @@ 

  

      def register_request_tests_repo(self):

          help_msg = 'Request a new tests dist-git repository'

-         pagure_section = '{0}.pagure'.format(self.name)

-         pagure_url = config_get_safely(self.config, pagure_section, 'url')

-         pagure_url_parsed = urlparse(pagure_url).netloc

          anongiturl = self.config.get(

              self.name, 'anongiturl', vars={'repo': 'any', 'module': 'any'}

          )

          description = textwrap.dedent('''

              Request a new dist-git repository in tests shared namespace

  

-                 {2}/projects/tests/*

+                 {1}/projects/tests/*

  

              For more information about tests shared namespace see

  
@@ -348,7 +345,7 @@ 

  

              Note that the space name needs to reflect the intent of the tests and will

              undergo a manual review.

-         '''.format(self.name, pagure_url_parsed, get_dist_git_url(anongiturl)))

+         '''.format(self.name, get_dist_git_url(anongiturl)))

  

          request_tests_repo_parser = self.subparsers.add_parser(

              'request-tests-repo',
@@ -415,7 +412,8 @@ 

              required=False,

              dest='repo_ns_for_branch',

              choices=self.get_distgit_namespaces(),

-             help='Repository name the new branch is requested for.'

+             help=("Repository name the new branch is requested for. Requires "

+                   "filling the '--repo' argument")

          )

          request_branch_parser.add_argument(

              '--sl', nargs='*',
@@ -439,6 +437,13 @@ 

              '--all-releases', default=False, action='store_true',

              help='Make a new branch request for every active Fedora release'

          )

+         request_branch_parser.add_argument(

+             '--without-playground', default=False, action='store_true',

+             help=("In case of requesting 'epelX' branch (where X is >7), "

+                   "'epelX-playground' branch will not be automatically "

+                   "requested. Branch will be created in pdc; user has to "

+                   "create git branch manually afterwards.")

+         )

          request_branch_parser.set_defaults(command=self.request_branch)

  

      def register_do_fork(self):
@@ -646,15 +651,15 @@ 

      # Target functions go here

      def _format_update_clog(self, clog):

          ''' Format clog for the update template. '''

-         lines = [l for l in clog.split('\n') if l]

+         lines = [ln for ln in clog.split('\n') if ln]

          if len(lines) == 0:

              return "- Rebuilt.", ""

          elif len(lines) == 1:

              return lines[0], ""

          log = ["# Changelog:"]

          log.append('# - ' + lines[0])

-         for l in lines[1:]:

-             log.append('# ' + l)

+         for ln in lines[1:]:

+             log.append('# ' + ln)

          log.append('#')

          return lines[0], "\n".join(log)

  
@@ -930,8 +935,10 @@ 

              active_branch=active_branch,

              repo_name=self.cmd.repo_name,

              ns=self.cmd.ns,

-             no_git_branch=self.args.no_git_branch,

+             # 'without_playground' option also disables creating git branch

+             no_git_branch=self.args.without_playground or self.args.no_git_branch,

              no_auto_module=self.args.no_auto_module,

+             without_playground=self.args.without_playground,

              name=self.name,

              config=self.config,

          )
@@ -939,7 +946,7 @@ 

      @staticmethod

      def _request_branch(service_levels, all_releases, branch, active_branch,

                          repo_name, ns, no_git_branch, no_auto_module,

-                         name, config):

+                         without_playground, name, config):

          """ Implementation of `request_branch`.

  

          Submits a request for a new branch of a given dist-git repo.
@@ -960,6 +967,8 @@ 

          :param no_auto_module: A boolean flag.  If True, requests for

              non-standard branches should not automatically result in additional

              requests for matching modules.

+         :param without_playground: A boolean flag. If True, 'epelX-playground'

+             branch will not be requested together with epelX in SCM.

          :param name: A string representing which section of the config should be

              used.  Typically the value of `self.name`.

          :param config: A dict containing the configuration, loaded from file.
@@ -990,7 +999,8 @@ 

              # Check if the requested branch is an epel branch

              match = re.match(r'^epel(?P<epel_version>\d+)$', branch)

              if match:

-                 epel_playground = True

+                 # do not request playground branch when without_playground is active

+                 epel_playground = not without_playground

                  epel_version = int(match.groupdict()["epel_version"])

  

              if is_epel(branch):
@@ -1096,6 +1106,7 @@ 

                      ns='modules',

                      no_git_branch=no_git_branch,

                      no_auto_module=True,  # Avoid infinite recursion.

+                     without_playground=without_playground,

                      name=name,

                      config=config,

                  )
@@ -1241,8 +1252,8 @@ 

          server_url = self.config.get('{0}.pdc'.format(self.name), 'url')

          releases = get_release_branches(server_url)

  

-         def _join(l):

-             return ' '.join(l)

+         def _join(ln):

+             return ' '.join(ln)

  

          if self.args.show_epel_only:

              print(_join(releases['epel']))

file modified
+52
@@ -1002,6 +1002,58 @@ 

                             'fedora-scm-requests/issue/2']))

          self.assertEqual(output, expected_output)

  

+     @patch('requests.get')

+     @patch('requests.post')

+     @patch('fedpkg.cli.get_release_branches')

+     @patch('sys.stdout', new=StringIO())

+     def test_request_epel_branch_override_without_playground(

+         self, mock_grb, mock_request_post, mock_request_get

+     ):

+         """Tests request-epel-branch-override-without-playground

+ 

+         epel8 branch operation (with 'without_playground' argument) generates

+         only one request. It doesn't request for epel8-playground branch.

+         It won't create git branch either.

+         """

+         mock_grb.return_value = {'fedora': ['f25', 'f26', 'f27'],

+                                  'epel': ['el6', 'epel7', 'epel8']}

+         mock_rv = Mock()

+         mock_rv.ok = True

+         mock_rv.json.return_value = {'issue': {'id': 2}}

+         mock_request_post.return_value = mock_rv

+ 

+         mock_rv = Mock()

+         mock_rv.ok = True

+         mock_rv.json.return_value = {"arches": [], "packages": {}}

+         mock_request_get.return_value = mock_rv

+         # Checkout the epel7 branch

+         self.run_cmd(['git', 'checkout', 'epel8'], cwd=self.cloned_repo_path)

+ 

+         cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path,

+                    'request-branch', '--repo', 'sudoku', 'epel8',

+                    '--without-playground']

+         cli = self.get_cli(cli_cmd)

+         cli.request_branch()

+ 

+         expected_issue_content = {

+             'action': 'new_branch',

+             'repo': 'sudoku',

+             'namespace': 'rpms',

+             'branch': 'epel8',

+             'create_git_branch': False

+         }

+         self.assertEqual(len(mock_request_post.call_args_list), 1)

+ 

+         # Get the data that was submitted to Pagure

+         post_data = mock_request_post.call_args_list[0][1]['data']

+         actual_issue_content = json.loads(json.loads(

+             post_data)['issue_content'].strip('```'))

+         self.assertEqual(expected_issue_content, actual_issue_content)

+         output = sys.stdout.getvalue().strip()

+         expected_output = ('https://pagure.stg.example.com/releng/'

+                            'fedora-scm-requests/issue/2')

+         self.assertEqual(output, expected_output)

+ 

      @patch('requests.post')

      @patch('fedpkg.cli.get_release_branches')

      @patch('sys.stdout', new=StringIO())

When 'fedpkg request-branch' requests for an 'epel8' (or higher),
Fedora SCM will create also 'epel8-playground' branch and place
initial commit containing 'package.cfg' into 'epel8'. This allows
avoiding the creation of the extra 'epel8-playground' branch
and the commit. New argument '--without-playground' was added.

JIRA: RHELCMP-589
Resolves: rhbz#1746314

Signed-off-by: Ondrej Nosek onosek@redhat.com

rebased onto 7a2436c

3 years ago

Note that this sort of defeats the purpose of playground as it's setup now... but we are considering ways to redo it. cc @tdawson

Did you read the original purpose in BZ?
https://bugzilla.redhat.com/show_bug.cgi?id=1746314
Maybe this weakens the concept of the playground, but users who do not agree, find their way to do this anyway. The code change to do that is easy.

I do not have a strong opinion on this. For me, it is just another branch I will build for. But what I do not like too much is the extra commit with "package.cfg" which prevents me to maintain all branches as one code (the same code for all branches). It makes epel8 separate and I would be forced to maintain (new versions, apply patches) it separately.

we are considering ways to redo it.
Maybe I do not understand this statement.

Did you read the original purpose in BZ?
https://bugzilla.redhat.com/show_bug.cgi?id=1746314

Yes.

but this " But, if the package you are maintaining is stable and changes slowly, you do not need it." while true is missing that you may not need it, but everyone who depends on your package being there does depend on it.
If people just randomly don't provide packages there it makes it very hard for others to provide their packages. ;(

Maybe this weakens the concept of the playground, but users who do not agree, find their way to do this anyway. The code change to do that is easy.

Sure.

I do not have a strong opinion on this. For me, it is just another branch I will build for. But what I do not like too much is the extra commit with "package.cfg" which prevents me to maintain all branches as one code (the same code for all branches). It makes epel8 separate and I would be forced to maintain (new versions, apply patches) it separately.

we are considering ways to redo it.
Maybe I do not understand this statement.

I would like to change it so epel8-playground inherits from epel8 in koji. This would allow people who don't care to just not be bothered by it. People who want to opt in could then request that branch seperately. There would be no more package.cfg file in epel8.
I have had no time to work on this however.

This sounds reasonable. Would you, please, put some words into BZ to clarify your stance to the requestor?
Do these plans have any time schedule?

Closing for now - better epel8-playground strategy will be implemented in future.

Pull-Request has been closed by onosek

3 years ago