@@ -317,21 +317,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
317317 continue
318318 }
319319
320- blockedByJobConcurrency , err := actions_model .ShouldBlockJobByConcurrency (ctx , actionRunJob )
321- if err != nil {
322- log .Error ("ShouldBlockJobByConcurrency failed, this job will stay blocked: job: %d, err: %v" , id , err )
323- continue
324- }
325- if blockedByJobConcurrency {
326- continue
327- }
328-
329- if err := CancelJobsByJobConcurrency (ctx , r .jobMap [id ]); err != nil {
330- log .Error ("Cancel previous jobs for job %d: %v" , id , err )
331- }
332-
320+ newStatus := actions_model .StatusBlocked
333321 if allSucceed {
334- ret [ id ] = actions_model .StatusWaiting
322+ newStatus = actions_model .StatusWaiting
335323 } else {
336324 // Check if the job has an "if" condition
337325 hasIf := false
@@ -341,13 +329,31 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
341329 }
342330 if hasIf {
343331 // act_runner will check the "if" condition
344- ret [ id ] = actions_model .StatusWaiting
332+ newStatus = actions_model .StatusWaiting
345333 } else {
346334 // If the "if" condition is empty and not all dependent jobs completed successfully,
347335 // the job should be skipped.
348- ret [ id ] = actions_model .StatusSkipped
336+ newStatus = actions_model .StatusSkipped
349337 }
350338 }
339+
340+ if newStatus == actions_model .StatusWaiting {
341+ blockedByJobConcurrency , err := actions_model .ShouldBlockJobByConcurrency (ctx , actionRunJob )
342+ if err != nil {
343+ log .Error ("ShouldBlockJobByConcurrency failed, this job will stay blocked: job: %d, err: %v" , id , err )
344+ continue
345+ }
346+ if blockedByJobConcurrency {
347+ newStatus = actions_model .StatusBlocked
348+ }
349+ if err := CancelJobsByJobConcurrency (ctx , r .jobMap [id ]); err != nil {
350+ log .Error ("Cancel previous jobs for job %d: %v" , id , err )
351+ }
352+ }
353+
354+ if newStatus != actions_model .StatusBlocked {
355+ ret [id ] = newStatus
356+ }
351357 }
352358 }
353359 return ret
0 commit comments