From 3e8db31a5b5a7be731b19da4bd666b0ddc35bd31 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 29 Mar 2023 23:27:37 +0800 Subject: Refactor commit status for Actions jobs (#23786) Before: xnip_230329_163852 After: xnip_230329_163358 Highlights: - Treat `StatusSkipped` as `CommitStatusSuccess` instead of `CommitStatusFailure`, so it fixed #23599. - Use the bot user `gitea-actions` instead of the trigger as the creator of commit status. - New format ` / / ()` for the context of commit status to avoid conflicts. - Add descriptions for commit status. - Add the missing calls to `CreateCommitStatus`. - Refactor `CreateCommitStatus` to make it easier to use. --- routers/web/repo/actions/view.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'routers/web/repo/actions/view.go') diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 0fa255b7e6..b2b625ea23 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -16,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/base" context_module "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" @@ -264,10 +263,7 @@ func Rerun(ctx *context_module.Context) { return } - if err := actions_service.CreateCommitStatus(ctx, job); err != nil { - log.Error("Update commit status for job %v failed: %v", job.ID, err) - // go on - } + actions_service.CreateCommitStatus(ctx, job) ctx.JSON(http.StatusOK, struct{}{}) } @@ -308,12 +304,7 @@ func Cancel(ctx *context_module.Context) { return } - for _, job := range jobs { - if err := actions_service.CreateCommitStatus(ctx, job); err != nil { - log.Error("Update commit status for job %v failed: %v", job.ID, err) - // go on - } - } + actions_service.CreateCommitStatus(ctx, jobs...) ctx.JSON(http.StatusOK, struct{}{}) } @@ -349,6 +340,8 @@ func Approve(ctx *context_module.Context) { return } + actions_service.CreateCommitStatus(ctx, jobs...) + ctx.JSON(http.StatusOK, struct{}{}) } -- cgit v1.2.3