@@ -46,6 +46,7 @@ type ActionRun struct {
4646 TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow
4747 Status Status `xorm:"index"`
4848 Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
49+ ConcurrencyGroup string
4950 // Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0
5051 Started timeutil.TimeStamp
5152 Stopped timeutil.TimeStamp
@@ -195,13 +196,20 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
195196// It's useful when a new run is triggered, and all previous runs needn't be continued anymore.
196197func CancelPreviousJobs (ctx context.Context , repoID int64 , ref , workflowID string , event webhook_module.HookEventType ) error {
197198 // 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 {
199200 RepoID : repoID ,
200201 Ref : ref ,
201202 WorkflowID : workflowID ,
202203 TriggerEvent : event ,
203204 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 )
205213 if err != nil {
206214 return err
207215 }
@@ -262,7 +270,7 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
262270
263271// InsertRun inserts a run
264272// 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 {
266274 ctx , committer , err := db .TxContext (ctx )
267275 if err != nil {
268276 return err
0 commit comments