server icon indicating copy to clipboard operation
server copied to clipboard

enhance(scm/repo): mirror allowed events with sent events

Open ecrupper opened this issue 3 years ago • 4 comments

Closes https://github.com/go-vela/community/issues/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 avatar Aug 01 '22 17:08 ecrupper

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%) :arrow_up:

codecov[bot] avatar Aug 01 '22 17:08 codecov[bot]

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.

cognifloyd avatar Aug 02 '22 04:08 cognifloyd

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.

ecrupper avatar Aug 03 '22 02:08 ecrupper

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

ecrupper avatar Sep 15 '22 13:09 ecrupper