#14 Re-trigger the scratch build on pull-request notifications
Merged 6 years ago by pingou. Opened 6 years ago by pingou.

file modified
+57 -2
@@ -83,7 +83,8 @@ 

          'org.fedoraproject.prod.pagure.pull-request.new',

  

          # Updates to an existing pull-request

-         #'org.fedoraproject.prod.pagure.pull-request.comment.added',

+         'org.fedoraproject.stg.pagure.pull-request.comment.added',

+         'org.fedoraproject.prod.pagure.pull-request.comment.added',

  

          # Anyways, we also listen for koji scratch builds to circle back:

          'org.fedoraproject.stg.buildsys.task.state.change',
@@ -192,7 +193,7 @@ 

                  prid=prid,

                  name=package,

                  namespace=namespace,

-                 uid=uid

+                 uid=uid,

                  commit=commit,

              )

  
@@ -209,6 +210,60 @@ 

  

          except Exception as e:

              _log.exception(e)

+ 

+     def handle_pagure_pr_update(self, msg):

+         """

+         Message handler for new pull-request opened in pagure.

+ 

+         Topic: ``org.fedoraproject.pagure.pull-request.comment.added``

+ 

+         """

+         _log.info("Handling pagure msg %r" % msg.get('msg_id', None))

+ 

+         prid = msg['msg']['pullrequest']['id']

+         package = msg['msg']['pullrequest']['project']['name']

+         namespace = msg['msg']['pullrequest']['project']['namespace']

+         branch_to = msg['msg']['pullrequest']['branch']

+         commit = msg['msg']['pullrequest'].get('commit_stop')

+         commit_label = ' for %s' % commit[:8] if commit else ''

+ 

+         if msg['msg']['pullrequest']['status'] != 'Open':

+             _log.info('Pull-request not open, discarding')

+             return

+ 

+         if not msg['msg']['pullrequest']['comments']:

+             _log.info('This is most odd, we\'re not seeing comments')

+             return

+ 

+         last_comment = msg['msg']['pullrequest']['comments'][-1]

+ 

+         if not last_comment or last_comment['notification'] is False:

+             _log.info('Comment was not a notification, discarding')

+             return

+ 

+         try:

+             _log.info('Re-Kicking a scratch build for ' + str(package))

+             # Kick off a scratch build..

+             task_id = self.buildsys.handle(

+                 package, prid, branch_to=branch_to)

+ 

+             uid = uuid.uuid4().hex

+ 

+             # Map that koji task_id to the pull-request we want to flag

+             self.scratch_builds[task_id] = dict(

+                 prid=prid,

+                 name=package,

+                 namespace=namespace,

+                 uid=uid,

+                 commit=commit,

+             )

+ 

+             # Flag the PR that the build is in progress

+             koji_url = self.buildsys.url_for(task_id)

+             data = {

+                 'username': 'simple-koji-ci',

+                 'status': 'pending',

+                 'comment': 'New build in progress%s' % commit_label,

                  'url': koji_url,

              }

  

no initial comment

rebased onto 81d356d

6 years ago

Pull-Request has been merged by pingou

6 years ago
Metadata