Skip to content

Conversation

@ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Aug 1, 2022

Closes go-vela/community#539

Now that we store the webhook_id in the hooks table, we're able to edit the webhook whenever a user updates their repo settings. With this functionality, we will consume far less webhook payloads from the SCM and users won't have to deal with error messages for events they do not want enabled.

A thing to note: I added an initialize webhook whenever a repo is enabled. This ensures that when a user adjusts settings right after enabling their repo, we have record of the webhook_id to edit.

Would love to hear thoughts!

@ecrupper ecrupper requested a review from a team as a code owner August 1, 2022 17:21
@ecrupper ecrupper self-assigned this Aug 1, 2022
@codecov
Copy link

codecov bot commented Aug 1, 2022

Codecov Report

Merging #679 (e6f3fa8) into main (b42e80f) will increase coverage by 0.10%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
+ Coverage   56.89%   56.99%   +0.10%     
==========================================
  Files         243      243              
  Lines       15939    15997      +58     
==========================================
+ Hits         9069     9118      +49     
- Misses       6468     6474       +6     
- Partials      402      405       +3     
Impacted Files Coverage Δ
scm/github/github.go 100.00% <ø> (ø)
scm/github/repo.go 76.36% <85.71%> (+1.36%) ⬆️

@cognifloyd
Copy link
Member

Nice! From the issue description, we really need this.

I don't understand what the issue with push vs tag is. If you have time, could you post a few links to where the code needs to be disambiguated? I can also go looking next time I have some time to look.

@ecrupper
Copy link
Contributor Author

ecrupper commented Aug 3, 2022

I don't understand what the issue with push vs tag is. If you have time, could you post a few links to where the code needs to be disambiguated? I can also go looking next time I have some time to look.

For sure! The way GitHub is set up, they send tag events as a sub-action of a push (Docs). We distinguish this in the code in scm/webhook.go. So if a user chose to unsubscribe to push events but not tag events, then we still need to handle all push events. I think a cleaner way would be to do some sort of if r.GetAllowPush() || r.GetAllowTag(), which I think I'll change now.

cognifloyd
cognifloyd previously approved these changes Aug 3, 2022
Copy link
Member

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the links. That makes more sense.

Maybe update the PR description for future reviewers since that question has been resolved. 😄

jbrockopp
jbrockopp previously approved these changes Sep 2, 2022
Copy link
Contributor

@jbrockopp jbrockopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@wass3r wass3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my testing against github.com this does not seem to work. when enabling a repo i get

Status 500 (unable to create initialization webhook for wass3r/vela-test: empty webhook repo_id provided)

we will need to set repo id or otherwise solve for this. the error comes from: https://github.com/go-vela/types/blob/ef95941428d9195503c3db067a9f27447b4dcc16/database/hook.go#L162

@ecrupper ecrupper dismissed stale reviews from jbrockopp and cognifloyd via 74e1f3b September 14, 2022 15:31
Copy link
Collaborator

@wass3r wass3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

little bit of whack-a-mole.. now getting this error:

Status 500 (unable to create initialization webhook for wass3r/vela-test: empty webhook source_id provided)

😭

@ecrupper
Copy link
Contributor Author

Sorry about that! All required hook fields have been set now. I also included some extra testing in the scm enable function

wass3r
wass3r previously approved these changes Sep 15, 2022
Copy link
Collaborator

@wass3r wass3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fixes. tested on github.com and works great. nice work.

too bad we can't force update existing hooks in github.

@ecrupper ecrupper dismissed stale reviews from plyr4, jbrockopp, and wass3r via bd10141 December 13, 2022 00:16
plyr4
plyr4 previously approved these changes Dec 13, 2022
Copy link
Contributor

@jbrockopp jbrockopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook created with all events enabled when repo is not enabled for all events

7 participants