Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Granular webhook events #9626

Merged
merged 29 commits into from
Mar 6, 2020
Merged

Granular webhook events #9626

merged 29 commits into from
Mar 6, 2020

Conversation

jolheiser
Copy link
Member

@jolheiser jolheiser commented Jan 7, 2020

This PR splits out webhook events to give users more control over when to notify via webhooks.

Screenshot from 2020-01-06 20-35-43

jolheiser and others added 11 commits December 17, 2019 20:56
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
@codecov-io
Copy link

codecov-io commented Jan 7, 2020

Codecov Report

Merging #9626 into master will decrease coverage by 0.04%.
The diff coverage is 27.89%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #9626      +/-   ##
=========================================
- Coverage   43.65%   43.6%   -0.05%     
=========================================
  Files         587     588       +1     
  Lines       82254   82474     +220     
=========================================
+ Hits        35905   35963      +58     
- Misses      41889   42048     +159     
- Partials     4460    4463       +3
Impacted Files Coverage Δ
models/migrations/migrations.go 4.16% <ø> (ø) ⬆️
modules/structs/hook.go 6.66% <ø> (ø) ⬆️
modules/auth/repo_form.go 44.44% <ø> (ø) ⬆️
models/migrations/v130.go 0% <0%> (ø)
modules/webhook/discord.go 1.92% <0%> (ø) ⬆️
modules/webhook/dingtalk.go 6.36% <0%> (ø) ⬆️
modules/webhook/telegram.go 3.97% <0%> (ø) ⬆️
routers/api/v1/utils/hook.go 0% <0%> (ø) ⬆️
modules/webhook/msteams.go 0% <0%> (ø) ⬆️
modules/webhook/slack.go 27.31% <0%> (ø) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80db442...0c37fca. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 7, 2020
@jolheiser jolheiser changed the title [WIP] Granular webhook events Granular webhook events Jan 8, 2020
@lunny lunny added type/bug type/enhancement An improvement of existing functionality topic/ui Change the appearance of the Gitea UI labels Jan 8, 2020
@lunny lunny added this to the 1.12.0 milestone Jan 8, 2020
@lunny
Copy link
Member

lunny commented Jan 8, 2020

Maybe the bug could be backport to v1.11

@lunny lunny added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Jan 8, 2020
@jolheiser
Copy link
Member Author

I will extract the bug and make a new PR for it.
As well, why is this breaking? The migration should update any existing webhooks so that they still fire the equivalent events.

@lunny
Copy link
Member

lunny commented Jan 8, 2020

@jolheiser for the CI or any other server will receive the webhook. The types changed, it may affect them. So I think it's a break.

@jolheiser
Copy link
Member Author

Aha, okay that makes sense.

@lafriks
Copy link
Member

lafriks commented Jan 8, 2020

Maybe also split branch/tag creation/deletion?

@lafriks
Copy link
Member

lafriks commented Jan 8, 2020

Also it could be better to not make it breaking change by just sending hook type as it is currently so for example: models.HookEventIssueLabel would actually send issues

@jolheiser
Copy link
Member Author

@lafriks
Branch/tag can be done, however the way it's currently set up would need some involved refactoring that might be better in another PR to avoid this growing even more.
Since it would be equally breaking, I'm willing to do it in 1.12 as well so it's just one overall breaking change.

Regarding hook types, they are just string types, so having multiple be the same would not work. The workaround I have found so far is to convert them back into generic types when the final payload is created, but I'm not sure I really like that implementation since it's just another place to check in the future to make sure webhooks don't break.

Or did you have some thoughts on the matter? There's a good chance I'm over thinking it. 😅

@lafriks
Copy link
Member

lafriks commented Jan 9, 2020

Yes, tag/branch event splitting can be done in other PR, I was just thinking this could be added here if it is easy to add.

Most probably hook types can be changed to enum and than have function that would return hook type string to send based on that enum

@jolheiser
Copy link
Member Author

Yes, tag/branch event splitting can be done in other PR, I was just thinking this could be added here if it is easy to add.

Sounds good, I'll see what the effort looks like after splitting into enums.

Most probably hook types can be changed to enum and than have function that would return hook type string to send based on that enum

That's a great idea. I think that should be doable, will give it a try.

Side-note, this PR can have the kind/bug label removed since the Telegram PR review was moved to a separate PR.

@lunny lunny removed the type/bug label Jan 10, 2020
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
models/migrations/v128.go Outdated Show resolved Hide resolved
Signed-off-by: jolheiser <john.olheiser@gmail.com>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 2, 2020
@jolheiser
Copy link
Member Author

I know this has lgtm/done now, but it would be nice to get one more review since a lot has changed since the first approval.

@jolheiser jolheiser requested review from 6543 and lafriks March 2, 2020 02:36
@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label Mar 2, 2020
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

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

the api should be cleanded if v2 ... but for now ok

@lafriks
Copy link
Member

lafriks commented Mar 5, 2020

please resolve conflicts

@lafriks lafriks merged commit 3f1c084 into go-gitea:master Mar 6, 2020
@jolheiser jolheiser deleted the granular_webhook branch March 6, 2020 05:11
@jolheiser
Copy link
Member Author

🙌

@mooror
Copy link

mooror commented Aug 3, 2020

Really nice addition @jolheiser, nicely done

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/ui Change the appearance of the Gitea UI type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants