From f1c58bd4ef9315d49466a956889f1e5c72b1f179 Mon Sep 17 00:00:00 2001 From: Easton Crupper <65553218+ecrupper@users.noreply.github.com> Date: Tue, 7 Nov 2023 17:34:18 -0500 Subject: [PATCH] fix(scm): process reopened action for pull request event (#1002) * fix(scm): process reopened action for pull request event * compile tests --- .../starlark/testdata/build/large/want.yml | 32 +++++++++---------- go.mod | 2 +- go.sum | 4 +-- scm/github/webhook.go | 5 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/compiler/template/starlark/testdata/build/large/want.yml b/compiler/template/starlark/testdata/build/large/want.yml index a9aaca543..a1604b551 100644 --- a/compiler/template/starlark/testdata/build/large/want.yml +++ b/compiler/template/starlark/testdata/build/large/want.yml @@ -56,7 +56,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -112,7 +112,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -168,7 +168,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -224,7 +224,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -280,7 +280,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -336,7 +336,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -392,7 +392,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -448,7 +448,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -504,7 +504,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -560,7 +560,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -616,7 +616,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -672,7 +672,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -728,7 +728,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -784,7 +784,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -840,7 +840,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: @@ -896,7 +896,7 @@ stages: steps: - ruleset: if: - event: ['pull_request:opened', 'pull_request:synchronize'] + event: ['pull_request:opened', 'pull_request:synchronize', 'pull_request:reopened'] matcher: filepath operator: and secrets: diff --git a/go.mod b/go.mod index c2e863180..c73c48d87 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/drone/envsubst v1.0.3 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/assert/v2 v2.2.0 - github.com/go-vela/types v0.22.0-rc1 + github.com/go-vela/types v0.22.0-rc1.0.20231107155504-ba41348d0fa9 github.com/golang-jwt/jwt/v5 v5.0.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v56 v56.0.0 diff --git a/go.sum b/go.sum index 6de1b87f2..1464d5926 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,8 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-vela/types v0.22.0-rc1 h1:LfYw8jiWW0KCPyIple2y9L75a5Lae454FfEe0JssLi0= -github.com/go-vela/types v0.22.0-rc1/go.mod h1:ljNY36D6YkpObBbNF7Xslv3oxN4mGuQAwWhnnK/V06I= +github.com/go-vela/types v0.22.0-rc1.0.20231107155504-ba41348d0fa9 h1:9ime2uWyIe2xhMWINOPs6SCj7Rk6vSAOZ/VZ+STgwpw= +github.com/go-vela/types v0.22.0-rc1.0.20231107155504-ba41348d0fa9/go.mod h1:ljNY36D6YkpObBbNF7Xslv3oxN4mGuQAwWhnnK/V06I= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/scm/github/webhook.go b/scm/github/webhook.go index e2583cccb..9e243df29 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -223,9 +223,10 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven return &types.Webhook{Hook: h}, nil } - // skip if the pull request action is not opened, synchronize + // skip if the pull request action is not opened, synchronize, or reopened if !strings.EqualFold(payload.GetAction(), "opened") && - !strings.EqualFold(payload.GetAction(), "synchronize") { + !strings.EqualFold(payload.GetAction(), "synchronize") && + !strings.EqualFold(payload.GetAction(), "reopened") { return &types.Webhook{Hook: h}, nil }