From 91e22dfa96bc1ff05ead70311b9d148953b964b9 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 14 Mar 2024 08:00:32 -0700 Subject: [PATCH] Fix github docs for pull_request_review.state The schema validation for these values is correct (if a little generous) but the docs had some incorrect example values. Update them to match the schema. Also, add comments to the schema validation indicating the source of these somewhat mysterious values. Change-Id: Idf26848a8c121d311590d07e003b53b8e867affd --- doc/source/drivers/github.rst | 4 ++-- zuul/driver/github/githubtrigger.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/source/drivers/github.rst b/doc/source/drivers/github.rst index 8ebd9459be..b7a331882e 100644 --- a/doc/source/drivers/github.rst +++ b/doc/source/drivers/github.rst @@ -412,8 +412,8 @@ the following options. This is only used for ``pull_request_review`` events. It accepts a list of strings each of which is matched to the review - state, which can be one of ``approved``, ``comment``, or - ``request_changes``. + state, which can be one of ``approved``, ``comment``, + ``changes_requested``, ``dismissed``, or ``pending``. .. attr:: status diff --git a/zuul/driver/github/githubtrigger.py b/zuul/driver/github/githubtrigger.py index e115691d3c..12fa5c7f27 100644 --- a/zuul/driver/github/githubtrigger.py +++ b/zuul/driver/github/githubtrigger.py @@ -181,6 +181,17 @@ def getNewSchema(): 'branch': scalar_or_list(vs.Any(ZUUL_REGEX, str)), }) + # The docs for this are at: + # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=dismissed#pull_request_review + # They specify "dismissed, approved, changes_requested" + # But we have also experimentally seen "commented" + # The graphql docs are at: + # https://docs.github.com/en/enterprise-server@3.12/graphql/reference/enums#pullrequestreviewstate + # And they additionally specify "commented" and "pending". + # It's unclear whether "pending" can show up in the webhook (it + # may only appear in a graphql query of a user's own unsaved + # reviews) but since we've seen the extra "commented" value, let's + # be generous and accept "pending" as well. pull_request_review_schema = pull_request_review_base_schema.extend({ 'action': scalar_or_list(vs.Any('submitted', 'dismissed')), 'state': scalar_or_list(vs.Any(