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

Add tests for webhook and fix some webhook bugs (#33396) #33442

Merged
merged 6 commits into from
Feb 2, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Jan 30, 2025

This PR created a mock webhook server in the tests and added integration tests for generic webhooks.
It also fixes bugs in package webhooks and pull request comment webhooks.

This also corrected an error on the package webhook. The previous implementation uses a User struct as an organization, now it has been corrected but it will not be consistent with the previous implementation, some fields which not belong to the organization have been removed.

Backport #33396
Backport part of #33337

@lunny lunny added this to the 1.23.2 milestone Jan 30, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 30, 2025
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 30, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Jan 30, 2025
lunny added 4 commits January 30, 2025 11:16
This PR created a mock webhook server in the tests and added integration
tests for generic webhooks.
It also fixes bugs in package webhooks and pull request comment
webhooks.
@lunny lunny force-pushed the lunny/add_webhook_test2 branch from df2d467 to 6369446 Compare January 30, 2025 19:17
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 1, 2025
@@ -480,7 +424,7 @@ type PackagePayload struct {
Action HookPackageAction `json:"action"`
Repository *Repository `json:"repository"`
Package *Package `json:"package"`
Organization *User `json:"organization"`
Organization *Organization `json:"organization"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking change?

Copy link
Member Author

@lunny lunny Feb 2, 2025

Choose a reason for hiding this comment

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

I prefer to consider it a bug of the previous implementation, not a feature change. So it's not a break change although it will make something break because the previous implementation is wrong. Compare the two structs,
User have many fields which should not belong to Organization, i.e.

    // Is the user an administrator
	IsAdmin bool `json:"is_admin"`
	// swagger:strfmt date-time
	LastLogin time.Time `json:"last_login,omitempty"`
    // Is user active
	IsActive bool `json:"active"`
	// Is user login prohibited
	ProhibitLogin bool `json:"prohibit_login"`
...

But I'm OK if you prefer to add a breaking label and description.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yes, most useful fields are there

Copy link
Contributor

Choose a reason for hiding this comment

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

But to backport, we need to mention that the struct has changed, to avoid wasting users' time

Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Not quite understand the details, just approve.

@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 Feb 2, 2025
@lunny lunny added pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Feb 2, 2025
@lunny lunny merged commit 23971a7 into go-gitea:release/v1.23 Feb 2, 2025
26 checks passed
@lunny lunny deleted the lunny/add_webhook_test2 branch February 2, 2025 06:44
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/bug type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants