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

Feature: Support workflow event dispatch via API #32059

Merged
merged 19 commits into from
Feb 9, 2025
Merged

Conversation

bencurio
Copy link
Contributor

@bencurio bencurio commented Sep 17, 2024

ref: #31765

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 17, 2024
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 17, 2024
@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 Sep 17, 2024
@bencurio bencurio force-pushed the main branch 2 times, most recently from 727cd1f to 8814e9f Compare September 17, 2024 16:00
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 20, 2024
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 2, 2024
@bencurio bencurio marked this pull request as ready for review October 2, 2024 10:18
@bencurio bencurio changed the title [WIP] Feature: Support workflow event dispatch via API Feature: Support workflow event dispatch via API Oct 2, 2024
routers/api/v1/api.go Outdated Show resolved Hide resolved
services/actions/workflow.go Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 12, 2024
@lunny lunny added this to the 1.23.0 milestone Oct 21, 2024
routers/api/v1/api.go Outdated Show resolved Hide resolved
routers/api/v1/api.go Outdated Show resolved Hide resolved
@lunny lunny modified the milestones: 1.23.0, 1.24.0 Nov 6, 2024
@KodingDev
Copy link

Any updates on this?

@bencurio
Copy link
Contributor Author

bencurio commented Dec 4, 2024

I'm sorry, but due to my current workload, I don't have the capacity to handle the PR at the moment. However, if the code review is completed in full, I can address all the corrections at once. Thank you.

@lunny
Copy link
Member

lunny commented Dec 4, 2024

I'm sorry, but due to my current workload, I don't have the capacity to handle the PR at the moment. However, if the code review is completed in full, I can address all the corrections at once. Thank you.

would you mind maintainers send commits to your branch?

@bencurio
Copy link
Contributor Author

bencurio commented Dec 4, 2024

I'm sorry, but due to my current workload, I don't have the capacity to handle the PR at the moment. However, if the code review is completed in full, I can address all the corrections at once. Thank you.

would you mind maintainers send commits to your branch?

I don't mind, feel free to send commits to my branch. Editing is enabled. Thank you!

@GiteaBot GiteaBot added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Feb 8, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 9, 2025
@lunny lunny merged commit 523751d into go-gitea:main Feb 9, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 9, 2025
@ChristopherHX
Copy link
Contributor

@bencurio I revoked my access to your fork, since this is done now. Thanks for your workflow api work.

zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 10, 2025
* giteaofficial/main:
  Feature: Support workflow event dispatch via API (go-gitea#32059)
  Remove "class-name" from svg icon (go-gitea#33540)
  Add "No data available" display when list is empty (go-gitea#33517)
  Add a option "--user-type bot" to admin user create, improve role display (go-gitea#27885)
Comment on lines +726 to +730
workflowID := ctx.PathParam("workflow_id")
if len(workflowID) == 0 {
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter"))
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

That's impossible to happen, dead code ........

Comment on lines +819 to +823
if terr, ok := err.(*actions_service.TranslateableError); ok {
msg := ctx.Locale.TrString(terr.Translation, terr.Args...)
ctx.Error(terr.GetCode(), msg, fmt.Errorf("%s", msg))
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't use locale in API.

IIRC the locale context is not properly prepared, and we never used that in code

// Checkboxes (and radio buttons) are on/off switches that may be toggled by the user.
// A switch is "on" when the control element's checked attribute is set.
// When a form is submitted, only "on" checkbox controls can become successful.
(*inputs)[name] = strconv.FormatBool(value == "on")
Copy link
Contributor

Choose a reason for hiding this comment

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

There is ctx.FormBool to handle this case, no need to comment the "on" behavior everywhere .......

Comment on lines +29 to +44
type TranslateableError struct {
Translation string
Args []any
Code int
}

func (t TranslateableError) Error() string {
return t.Translation
}

func (t TranslateableError) GetCode() int {
if t.Code == 0 {
return http.StatusInternalServerError
}
return t.Code
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not invent a new error system at the moment .........

@wxiaoguang
Copy link
Contributor

Could we revert this change and propose a new and clear PR?


URL := fmt.Sprintf("%s/actions/workflows/%s", ctx.Repo.Repository.APIURL(), entry.Name())
HTMLURL := fmt.Sprintf("%s/src/branch/%s/%s/%s", ctx.Repo.Repository.HTMLURL(ctx), defaultBranch, folder, entry.Name())
badgeURL := fmt.Sprintf("%s/actions/workflows/%s/badge.svg?branch=%s", ctx.Repo.Repository.HTMLURL(ctx), entry.Name(), ctx.Repo.Repository.DefaultBranch)
Copy link
Contributor

Choose a reason for hiding this comment

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

It forgets to escape ......

It would cause problems if there are special chars in names

wxiaoguang added a commit to wxiaoguang/gitea that referenced this pull request Feb 10, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 10, 2025

Could we revert this change and propose a new and clear PR?

-> Revert "Feature: Support workflow event dispatch via API (#32059)" #33541

@bencurio
Copy link
Contributor Author

@bencurio I revoked my access to your fork, since this is done now. Thanks for your workflow api work.

Thank you for continuing; unfortunately, I didn't have enough time to finish it at the end.

@bencurio
Copy link
Contributor Author

bencurio commented Feb 10, 2025

@wxiaoguang A more collaborative tone can be achieved by explaining the reasoning behind concerns. Focusing on the issues and suggesting alternatives helps maintain a respectful and constructive dialogue, which is essential for effective collaboration.

@wxiaoguang
Copy link
Contributor

@wxiaoguang A more collaborative tone can be achieved by explaining the reasoning behind concerns. Focusing on the issues and suggesting alternatives helps maintain a respectful and constructive dialogue, which is essential for effective collaboration.

I think I have explained some details for each review comment.

If there is still anything unclear, please point out and I will try to explain more.

Since I am not a native speaker, so I am not sure which "tone" could be more "collaborative": https://github.com/go-gitea/gitea/blob/main/CODE_OF_CONDUCT.md: Remember that people have varying communication styles and that not everyone is using their native language. (Meaning and tone can be lost in translation.)


And TBH I reviewed quite a lot of PRs (https://github.com/go-gitea/gitea/pulls?q=is%3Apr+is%3Aclosed+reviewed-by%3Awxiaoguang), usually I would assume that the readers could have some background knowledges about the problem, otherwise I need to type a lot of words again and again. And yes, if there is something unclear, I'd be happy to explain.

@bencurio
Copy link
Contributor Author

I'm not a native speaker either; in fact, I'm asking ChatGPT to translate this. Nevertheless, I'm taking the trouble to avoid offending anyone by using an appropriate style. This was also translated by ChatGPT. As far as I'm concerned, I've finished this PR because I still don't have any more time to continue, but I'm happy to hand over the repo to someone else if needed.

@wxiaoguang
Copy link
Contributor

To be clear, I am not saying this PR is wrong. Instead, it is awesome and thank you everyone for the work.

The problem is: some designs and approaches introduced by this PR are not suitable (well, how to find a proper word to not offend people?) and need to improve, so I think we need to "propose a new and clear PR (#32059 (comment))" .

@bencurio
Copy link
Contributor Author

If it helps, this functionality has already been independently implemented in Forgejo: https://codeberg.org/forgejo/forgejo/commit/51735c415bb29e40b1b02c14bb4f9854e8e27b24

@wxiaoguang
Copy link
Contributor

Yup, many features are independently implemented in Gitea and Forgejo.

You could compare them, I believe the Gitea's solutions are better in most cases. For example: Sync fork, Wiki public access, markup rendering, including the workflow dispatch.

@wxiaoguang

This comment has been minimized.

wxiaoguang pushed a commit to wxiaoguang/gitea that referenced this pull request Feb 10, 2025
ref: go-gitea#31765

---------

Signed-off-by: Bence Santha <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: Christopher Homberger <[email protected]>
@wxiaoguang
Copy link
Contributor

I opened a new PR: Feature: Support workflow event dispatch via API #33545

Will try to make some changes and please help to review then, thank you very much!

@wxiaoguang
Copy link
Contributor

I opened a new PR: Feature: Support workflow event dispatch via API #33545

CI passes and it is ready for review

@go-gitea go-gitea locked and limited conversation to collaborators Feb 10, 2025
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. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants