Skip to content

Commit 5932c14

Browse files
committed
fix ShouldBlockRunByConcurrency
1 parent 93af0ee commit 5932c14

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

models/actions/run.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,15 @@ func ShouldBlockRunByConcurrency(ctx context.Context, actionRun *ActionRun) (boo
373373
return false, nil
374374
}
375375

376-
concurrentRunsNum, err := db.Count[ActionRun](ctx, &FindRunOptions{
376+
concurrentRuns, err := db.Find[ActionRun](ctx, &FindRunOptions{
377377
RepoID: actionRun.RepoID,
378378
ConcurrencyGroup: actionRun.ConcurrencyGroup,
379379
Status: []Status{StatusWaiting, StatusRunning},
380380
})
381381
if err != nil {
382-
return false, fmt.Errorf("count running and waiting runs: %w", err)
382+
return false, fmt.Errorf("find running and waiting runs: %w", err)
383383
}
384+
previousRuns := slices.DeleteFunc(concurrentRuns, func(r *ActionRun) bool { return r.ID == actionRun.ID })
384385

385-
return concurrentRunsNum > 0, nil
386+
return len(previousRuns) > 0, nil
386387
}

0 commit comments

Comments
 (0)