|
9 | 9 |
|
10 | 10 | actions_model "code.gitea.io/gitea/models/actions" |
11 | 11 | "code.gitea.io/gitea/models/db" |
12 | | - "code.gitea.io/gitea/modules/log" |
13 | 12 | "code.gitea.io/gitea/modules/util" |
14 | 13 | notify_service "code.gitea.io/gitea/services/notify" |
15 | 14 |
|
@@ -53,29 +52,27 @@ func PrepareRunAndInsert(ctx context.Context, content []byte, run *actions_model |
53 | 52 | run.Title = jobs[0].RunName |
54 | 53 | } |
55 | 54 |
|
56 | | - if err := InsertRun(ctx, run, jobs, vars); err != nil { |
| 55 | + if err = InsertRun(ctx, run, jobs, vars); err != nil { |
57 | 56 | return fmt.Errorf("InsertRun: %w", err) |
58 | 57 | } |
59 | 58 |
|
60 | | - // FIXME PERF do we need this db round trip? |
| 59 | + // Load the newly inserted jobs with all fields from database (the job models in InsertRun are partial, so load again) |
61 | 60 | allJobs, err := db.Find[actions_model.ActionRunJob](ctx, actions_model.FindRunJobOptions{RunID: run.ID}) |
62 | 61 | if err != nil { |
63 | | - log.Error("FindRunJobs: %v", err) |
| 62 | + return fmt.Errorf("FindRunJob: %w", err) |
64 | 63 | } |
65 | 64 |
|
66 | 65 | // FIXME PERF skip this for schedule, dispatch etc. |
67 | | - CreateCommitStatus(ctx, allJobs...) |
68 | | - |
69 | | - err = run.LoadAttributes(ctx) |
70 | | - if err != nil { |
71 | | - log.Error("LoadAttributes: %v", err) |
| 66 | + const shouldCreateCommitStatus = true |
| 67 | + if shouldCreateCommitStatus { |
| 68 | + CreateCommitStatus(ctx, allJobs...) |
72 | 69 | } |
| 70 | + |
73 | 71 | notify_service.WorkflowRunStatusUpdate(ctx, run.Repo, run.TriggerUser, run) |
74 | 72 | for _, job := range allJobs { |
75 | 73 | notify_service.WorkflowJobStatusUpdate(ctx, run.Repo, run.TriggerUser, job, nil) |
76 | 74 | } |
77 | 75 |
|
78 | | - // Return nil if no errors occurred |
79 | 76 | return nil |
80 | 77 | } |
81 | 78 |
|
|
0 commit comments