@@ -46,6 +46,7 @@ type ActionRun struct {
46
46
TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow
47
47
Status Status `xorm:"index"`
48
48
Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
49
+ ConcurrencyGroup string
49
50
// Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0
50
51
Started timeutil.TimeStamp
51
52
Stopped timeutil.TimeStamp
@@ -195,13 +196,20 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
195
196
// It's useful when a new run is triggered, and all previous runs needn't be continued anymore.
196
197
func CancelPreviousJobs (ctx context.Context , repoID int64 , ref , workflowID string , event webhook_module.HookEventType ) error {
197
198
// Find all runs in the specified repository, reference, and workflow with non-final status
198
- runs , total , err := db . FindAndCount [ ActionRun ]( ctx , FindRunOptions {
199
+ opts := & FindRunOptions {
199
200
RepoID : repoID ,
200
201
Ref : ref ,
201
202
WorkflowID : workflowID ,
202
203
TriggerEvent : event ,
203
204
Status : []Status {StatusRunning , StatusWaiting , StatusBlocked },
204
- })
205
+ }
206
+ return CancelPreviousJobsWithOpts (ctx , opts )
207
+ }
208
+
209
+ // CancelPreviousJobs cancels all previous jobs with opts
210
+ func CancelPreviousJobsWithOpts (ctx context.Context , opts * FindRunOptions ) error {
211
+ // Find all runs by opts
212
+ runs , total , err := db .FindAndCount [ActionRun ](ctx , opts )
205
213
if err != nil {
206
214
return err
207
215
}
@@ -262,7 +270,7 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
262
270
263
271
// InsertRun inserts a run
264
272
// The title will be cut off at 255 characters if it's longer than 255 characters.
265
- func InsertRun (ctx context.Context , run * ActionRun , jobs []* jobparser.SingleWorkflow ) error {
273
+ func InsertRun (ctx context.Context , run * ActionRun , jobs []* jobparser.SingleWorkflow , blockedByConcurrency bool ) error {
266
274
ctx , committer , err := db .TxContext (ctx )
267
275
if err != nil {
268
276
return err
0 commit comments