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 new event commit status creation and webhook implementation #27151

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

lunny
Copy link
Member

@lunny lunny commented Sep 20, 2023

This PR introduces a new event which is similar as Github's. When a new commit status submitted, the event will be trigged. That means, now we can receive all feedback from CI/CD system in webhooks or other notify systems.

ref: https://docs.github.com/en/webhooks/webhook-events-and-payloads#status

Fix #20749

@lunny lunny added the type/enhancement An improvement of existing functionality label Sep 20, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 20, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 20, 2023
@anbraten
Copy link
Contributor

Looks like a nice idea to have a webhook event for this. However the original idea behind the issue was rather to get an internal notification (shown when clicking on the bell in the UI) for failed PR status reports. So a CI like gitea actions would send a PR status update and if that is a failed one it would create a new notification entry in the list.

@lunny
Copy link
Member Author

lunny commented Sep 21, 2023

Looks like a nice idea to have a webhook event for this. However the original idea behind the issue was rather to get an internal notification (shown when clicking on the bell in the UI) for failed PR status reports. So a CI like gitea actions would send a PR status update and if that is a failed one it would create a new notification entry in the list.

The UI notification could be another PR because it will need more work, maybe it can be based on #27058

@lunny lunny added this to the 1.22.0 milestone Sep 27, 2023
@denyskon denyskon added topic/webhooks giteabot/update-branch Hint for the bot that it should update a PR with the latest state on main labels Oct 22, 2023
@GiteaBot GiteaBot removed the giteabot/update-branch Hint for the bot that it should update a PR with the latest state on main label Oct 22, 2023
@denyskon denyskon self-requested a review October 22, 2023 16:25
@denyskon
Copy link
Member

@lunny Could you please explain this change? I don't understand which action is triggered by this method in the end......

@lunny
Copy link
Member Author

lunny commented Dec 11, 2023

@lunny Could you please explain this change? I don't understand which action is triggered by this method in the end......

This event is triggered by a new commit status submitted to Gitea. Currently only webhook notfier implement it so then when a commit status has been submitted, a webhook will be triggered.

@denyskon
Copy link
Member

@lunny I don't manage to trigger a webhook. Do I misunderstand you? I run a workflow on a repo, which succeeds or fails. I have a Telegram webhook which triggers on commit, but not on workflow success/failure

@lunny
Copy link
Member Author

lunny commented Dec 21, 2023

@lunny I don't manage to trigger a webhook. Do I misunderstand you? I run a workflow on a repo, which succeeds or fails. I have a Telegram webhook which triggers on commit, but not on workflow success/failure

There is no CI/CD success/failure message directly. But we can use commit status success/failure with context and commitid to know whether/which the task success/failure.

@denyskon
Copy link
Member

Yes, but do I have to activate it separately somewhere to also get commit status over webhook?
I only get the new commit message

@denyskon
Copy link
Member

Ping :) Would really like to be able to review this before 1.22. Do I misunderstand something, or does it currently not fully work?

CreatedAt time.Time `json:"created_at"`
Description string `json:"description"`
ID int64 `json:"id"`
// Name string `json:"name"`
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

Still, why is the Name commented out?

modules/structs/hook.go Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2024
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 8, 2024
@denyskon
Copy link
Member

denyskon commented Mar 8, 2024

@lunny I still am not able to trigger a webhook notification. What do I need to do to be able to test it?

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2024
@lunny
Copy link
Member Author

lunny commented Mar 8, 2024

@lunny I still am not able to trigger a webhook notification. What do I need to do to be able to test it?

Sorry, I think it's not finished when you tested it. I think it's ready now.

@lunny lunny modified the milestones: 1.22.0, 1.23.0 Mar 29, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label May 14, 2024
@denyskon
Copy link
Member

denyskon commented Jul 3, 2024

@lunny Still no success. If the feature is working as intended for you, could you please provide some instructions how to test it properly?

@denyskon denyskon added the giteabot/update-branch Hint for the bot that it should update a PR with the latest state on main label Jul 3, 2024
@GiteaBot GiteaBot removed the giteabot/update-branch Hint for the bot that it should update a PR with the latest state on main label Jul 3, 2024
UpdatedAt *time.Time `json:"updated_at"`
}

// JSONPayload FIXME
Copy link
Member

Choose a reason for hiding this comment

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

What needs to be fixed? It looks complete to me...

@lunny lunny modified the milestones: 1.23.0, 1.24.0 Oct 10, 2024
@lunny lunny marked this pull request as draft October 10, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files. topic/webhooks type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a notification on status update failures
6 participants