-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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! |
* uses all endpoints added here * checks if disabled workflows cannot dispatch * remove node_id * fix path field * test that the URL field of the workflow result is usable * additional test for non default branch workflow * return 200 when no workflows found, with an empty list
Could you please reevaluate this now/later? This now uses the exact same logic for UI and api to trigger workflow_dispatch Also non default branch workflows are now read instead of using always the workflow of the default branch (changed in 1.24.0/nightly) Summary
Please let me know If you have some suggestions or ideas to improve this, until then I have currently no open points on my TODO list for this change |
Just tested and it is fixed now - both manual and API execute all the jobs from the workflow. |
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.
I guess I'm now able to approve towards the lgtm bot, but didn't I changed way too much here
@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. |
ref: #31765