Remove translation of check run action in github driver

Drivers should pass event data unmodified so trigger documentation can
refer directly to upstream api documentation like GitHub. This is
handled incorrectly for the check_run action 'rerequested' which had
been simplified to 'requested'. Fix this by removing the translation
and add a temporary compatibility layer to prepare future removal.

Change-Id: I2a75c92d1aeacf261b517a328d91ea02f6013762
This commit is contained in:
Tobias Henkel 2021-05-11 21:41:40 +02:00
parent fd028206de
commit 21ce3f9ad7
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
4 changed files with 21 additions and 3 deletions

View File

@ -19,6 +19,8 @@
# When using the checks API to report results, failed runs # When using the checks API to report results, failed runs
# will have a "re-run" button which emits this event. # will have a "re-run" button which emits this event.
- event: check_run - event: check_run
action: rerequested
check: .*/check:.*
start: start:
github: github:
check: 'in_progress' check: 'in_progress'

View File

@ -0,0 +1,8 @@
---
deprecations:
- |
Zuul now correctly handles the ``rerequested`` action on check run trigger
definitions (:value:`pipeline.trigger.<github source>.event.check_run`)
literally. This has been ``requested`` which doesn't match the GitHub api.
The value ``requested`` is now deprecated and will be removed in a later
release.

View File

@ -575,9 +575,6 @@ class GithubEventProcessor(object):
event = self._pull_request_to_event(pr_body) event = self._pull_request_to_event(pr_body)
event.type = "check_run" event.type = "check_run"
# Simplify rerequested action to requested
if action == "rerequested":
action = "requested"
event.action = action event.action = action
check_run_tuple = "%s:%s:%s" % _check_as_tuple(check_run) check_run_tuple = "%s:%s:%s" % _check_as_tuple(check_run)

View File

@ -23,6 +23,17 @@ class GithubTrigger(BaseTrigger):
name = 'github' name = 'github'
log = logging.getLogger("zuul.trigger.GithubTrigger") log = logging.getLogger("zuul.trigger.GithubTrigger")
def __init__(self, driver, connection, config=None):
# This is a compatibility layer to map the action 'requested' back
# to the original action 'rerequested'.
# TODO: Remove after zuul 5.0
for item in config:
if item.get('action') == 'requested':
item['action'] = 'rerequested'
super().__init__(driver, connection, config=config)
def getEventFilters(self, connection_name, trigger_config): def getEventFilters(self, connection_name, trigger_config):
efilters = [] efilters = []
for trigger in to_list(trigger_config): for trigger in to_list(trigger_config):