From 82ee3ca4e816f9fb552c30ee9f488206c9297969 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 21 2018 11:21:35 +0000 Subject: Support building in the target branch if known, otherwise default to rawhide Fixes https://pagure.io/fedora-ci/simple-koji-ci/issue/5 Signed-off-by: Pierre-Yves Chibon --- diff --git a/fedmsg.d/simple-koji-ci-example.py b/fedmsg.d/simple-koji-ci-example.py index f72315f..28beef3 100644 --- a/fedmsg.d/simple-koji-ci-example.py +++ b/fedmsg.d/simple-koji-ci-example.py @@ -15,7 +15,14 @@ config = { 'git_url': 'https://src.fedoraproject.org/rpms/{package}.git', 'opts': {'scratch': True}, 'priority': 30, - 'target_tag': 'rawhide', + 'target_tags': { + 'master'; 'rawhide', + 'f27': 'f27', + 'f26': 'f25', + 'f25': 'f26', + 'epel7': 'epel7', + 'el6': 'el6', + } }, diff --git a/simple_koji_ci/buildsys.py b/simple_koji_ci/buildsys.py index 30244c5..c81d8b4 100644 --- a/simple_koji_ci/buildsys.py +++ b/simple_koji_ci/buildsys.py @@ -56,7 +56,7 @@ class Koji(object): self.git_url = config['git_url'] self.opts = config['opts'] self.priority = config['priority'] - self.target_tag = config['target_tag'] + self.target_tags = config['target_tags'] def session_maker(self): _log.info('Creating a new Koji session to %s', self.server) @@ -93,20 +93,21 @@ class Koji(object): session.uploadWrapper(source, serverdir) return "%s/%s" % (serverdir, os.path.basename(source)) - def scratch_build(self, session, name, source): + def scratch_build(self, session, name, source, branch): remote = self.upload_srpm(session, source) # Make double sure we're only doing scrach builds opts = self.opts opts['scratch'] = True + target = self.target_tags.get(branch, 'rawhide') _log.info('Intiating koji build for %r' % dict( - name=name, target=self.target_tag, source=remote, opts=opts)) + name=name, target=target, source=remote, opts=opts)) task_id = session.build( - remote, self.target_tag, opts, priority=self.priority) + remote, target, opts, priority=self.priority) _log.info('Scratch build created for {name}: {url}'.format( name=name, url=self.url_for(task_id))) return task_id - def handle(self, package, prid): + def handle(self, package, prid, branch_to): """ Main API entry point. Bumps the version on a package and requests a scratch build. @@ -164,7 +165,7 @@ class Koji(object): # Kick off scratch build session = self.session_maker() _log.debug("Kicking koji build for: %r (%r)" % (package, srpm)) - task_id = self.scratch_build(session, package, srpm) + task_id = self.scratch_build(session, package, srpm, branch_to) _log.debug("Task ID: %r" % task_id) return task_id diff --git a/simple_koji_ci/consumers.py b/simple_koji_ci/consumers.py index 7111943..a638029 100644 --- a/simple_koji_ci/consumers.py +++ b/simple_koji_ci/consumers.py @@ -175,11 +175,13 @@ class SimpleKojiCi(fedmsg.consumers.FedmsgConsumer): prid = msg['msg']['pullrequest']['id'] package = msg['msg']['pullrequest']['project']['name'] namespace = msg['msg']['pullrequest']['project']['namespace'] + branch_to = msg['msg']['pullrequest']['branch'] try: _log.info('Kicking a scratch build for ' + str(package)) # Kick off a scratch build.. - task_id = self.buildsys.handle(package, prid) + task_id = self.buildsys.handle( + package, prid, branch_to=branch_to) uid = uuid.uuid4().hex