-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add workflow_run api + webhook #33964
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
base: main
Are you sure you want to change the base?
Conversation
Verification update of keda k8s autoscaler (current gitea 1.24-rc works only with modified garm). Uses these apis
I could change the existing keda github-runner e2e test to pass on my end by manually running gitea and setting up the test repository without changing non test content.
Maybe we could setup extended e2e test repositories to track external autoscaler compatibility |
This comment was marked as outdated.
This comment was marked as outdated.
…stopherHX/33964-1
…stopherHX/33964-1
…stopherHX/33964-1
Ready for review? |
My time to respond or make changes is limited in the next seven days, due to exams. Other than that, yes I think this is ready for review. |
ListOptions: utils.GetListOptions(ctx), | ||
} | ||
|
||
if event := ctx.Req.URL.Query().Get("event"); event != "" { |
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.
URL.Query
will do ParseQuery
again and agian.
Maybe we can just call FormString
, or use a parsed query parsedQuery := ctx.Req.URL.Query()
|
||
runID := ctx.PathParamInt64("run") | ||
|
||
shared.ListJobs(ctx, 0, repoID, runID) |
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.
Maybe ListJobs
has done enough check to ensure runID
belongs to repoID
, while is it possible to explicitly check it here, or add comment to ListJobs
to explain that no need extra check?
// Sync run status with db | ||
job.Run = nil | ||
if err := job.LoadAttributes(ctx); err != nil { | ||
ctx.HTTPError(http.StatusInternalServerError, err.Error()) |
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.
use ctx to report server internal error, then the err will also appear in logs
// Sync run status with db | ||
jobs[0].Run = nil | ||
if err := jobs[0].LoadAttributes(ctx); err != nil { | ||
return err | ||
} | ||
run := jobs[0].Run |
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.
Saw this code block many times. Maybe a common function:
func notifyWorkflowRunStatusUpdate(....) {
job.Run = nil
if err := job.LoadAttribute(); err != nil {
log.Error()
} else {
notify_service.WorkflowRunStatusUpdate(
}
}
|
||
status := convert.ToWorkflowRunAction(run.Status) | ||
|
||
gitRepo, err := gitrepo.OpenRepository(context.Background(), repo) |
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.
Use ctx
?
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.
No hurry, overall looks good. Thank you very much.
(Maybe will take a look again later)
Implements
/actions/runs
for global + user + org (Gitea only)/actions/jobs
for global + user + org + repository (Gitea only)Fixes
runs/<run>
part to align with apiRefactoring
TODO
Closes #23670
Closes #23796
Closes #24898
Replaces #28047 and is much more complete