-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
727cd1f
to
8814e9f
Compare
Any updates on this? |
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! |
@bencurio I revoked my access to your fork, since this is done now. Thanks for your workflow api work. |
* 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)
workflowID := ctx.PathParam("workflow_id") | ||
if len(workflowID) == 0 { | ||
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter")) | ||
return | ||
} |
There was a problem hiding this comment.
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 ........
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 | ||
} |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 .......
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 | ||
} |
There was a problem hiding this comment.
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 .........
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) |
There was a problem hiding this comment.
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
)" This reverts commit 523751d.
Thank you for continuing; unfortunately, I didn't have enough time to finish it at the end. |
@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. |
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. |
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))" . |
If it helps, this functionality has already been independently implemented in Forgejo: https://codeberg.org/forgejo/forgejo/commit/51735c415bb29e40b1b02c14bb4f9854e8e27b24 |
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. |
This comment has been minimized.
This comment has been minimized.
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]>
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! |
CI passes and it is ready for review |
ref: #31765