@@ -53,10 +53,14 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
5353 if err != nil {
5454 return fmt .Errorf ("get action run: %w" , err )
5555 }
56+ var jobs , updatedJobs []* actions_model.ActionRunJob
5657 if err := db .WithTx (ctx , func (ctx context.Context ) error {
5758 // check jobs of the current run
58- if err := checkJobsOfRun (ctx , run ); err != nil {
59+ if js , ujs , err := checkJobsOfRun (ctx , run ); err != nil {
5960 return err
61+ } else {
62+ jobs = append (jobs , js ... )
63+ updatedJobs = append (updatedJobs , ujs ... )
6064 }
6165 // check run (workflow-level) concurrency
6266 concurrentRunIDs := make (container.Set [int64 ])
@@ -78,8 +82,11 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
7882 if concurrentRun .NeedApproval {
7983 continue
8084 }
81- if err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
85+ if js , ujs , err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
8286 return err
87+ } else {
88+ jobs = append (jobs , js ... )
89+ updatedJobs = append (updatedJobs , ujs ... )
8390 }
8491 updatedRun , err := actions_model .GetRunByID (ctx , concurrentRun .ID )
8592 if err != nil {
@@ -128,8 +135,11 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
128135 if concurrentRun .NeedApproval {
129136 continue
130137 }
131- if err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
138+ if js , ujs , err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
132139 return err
140+ } else {
141+ jobs = append (jobs , js ... )
142+ updatedJobs = append (updatedJobs , ujs ... )
133143 }
134144 updatedJob , err := actions_model .GetRunJobByID (ctx , concurrentJob .ID )
135145 if err != nil {
@@ -142,27 +152,29 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
142152 }
143153 }
144154 }
145-
146155 return nil
147156 }); err != nil {
148157 return err
149158 }
150-
159+ CreateCommitStatus (ctx , jobs ... )
160+ for _ , job := range updatedJobs {
161+ _ = job .LoadAttributes (ctx )
162+ notify_service .WorkflowJobStatusUpdate (ctx , job .Run .Repo , job .Run .TriggerUser , job , nil )
163+ }
151164 return nil
152165}
153166
154- func checkJobsOfRun (ctx context.Context , run * actions_model.ActionRun ) error {
155- jobs , err : = db .Find [actions_model.ActionRunJob ](ctx , actions_model.FindRunJobOptions {RunID : run .ID })
167+ func checkJobsOfRun (ctx context.Context , run * actions_model.ActionRun ) ( jobs , updatedJobs [] * actions_model. ActionRunJob , err error ) {
168+ jobs , err = db .Find [actions_model.ActionRunJob ](ctx , actions_model.FindRunJobOptions {RunID : run .ID })
156169 if err != nil {
157- return err
170+ return
158171 }
159- var updatedjobs []* actions_model.ActionRunJob
160172 vars , err := actions_model .GetVariablesOfRun (ctx , run )
161173 if err != nil {
162- return fmt . Errorf ( "get run %d variables: %w" , run . ID , err )
174+ return
163175 }
164176
165- if err : = db .WithTx (ctx , func (ctx context.Context ) error {
177+ if err = db .WithTx (ctx , func (ctx context.Context ) error {
166178 for _ , job := range jobs {
167179 job .Run = run
168180 }
@@ -176,19 +188,15 @@ func checkJobsOfRun(ctx context.Context, run *actions_model.ActionRun) error {
176188 } else if n != 1 {
177189 return fmt .Errorf ("no affected for updating blocked job %v" , job .ID )
178190 }
179- updatedjobs = append (updatedjobs , job )
191+ updatedJobs = append (updatedJobs , job )
180192 }
181193 }
182194 return nil
183195 }); err != nil {
184- return err
185- }
186- CreateCommitStatus (ctx , jobs ... )
187- for _ , job := range updatedjobs {
188- _ = job .LoadAttributes (ctx )
189- notify_service .WorkflowJobStatusUpdate (ctx , job .Run .Repo , job .Run .TriggerUser , job , nil )
196+ return
190197 }
191- return nil
198+
199+ return
192200}
193201
194202type jobStatusResolver struct {
0 commit comments