Skip to content

Commit 2cab1be

Browse files
author
Jiangyi Liu
committed
feature: allow disabling auto cancellation of duplicate workflow runs
1 parent 8ad2a53 commit 2cab1be

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

models/actions/run.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
209209
// CancelPreviousJobs cancels all previous jobs of the same repository, reference, workflow, and event.
210210
// It's useful when a new run is triggered, and all previous runs needn't be continued anymore.
211211
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) ([]*ActionRunJob, error) {
212+
// Do not do cancellation if disabled in settings
213+
if !setting.Actions.EnableAutoCancellation {
214+
return nil, nil
215+
}
216+
212217
// Find all runs in the specified repository, reference, and workflow with non-final status
213218
runs, total, err := db.FindAndCount[ActionRun](ctx, FindRunOptions{
214219
RepoID: repoID,

modules/setting/actions.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ import (
1414
// Actions settings
1515
var (
1616
Actions = struct {
17-
Enabled bool
18-
LogStorage *Storage // how the created logs should be stored
19-
LogRetentionDays int64 `ini:"LOG_RETENTION_DAYS"`
20-
LogCompression logCompression `ini:"LOG_COMPRESSION"`
21-
ArtifactStorage *Storage // how the created artifacts should be stored
22-
ArtifactRetentionDays int64 `ini:"ARTIFACT_RETENTION_DAYS"`
23-
DefaultActionsURL defaultActionsURL `ini:"DEFAULT_ACTIONS_URL"`
24-
ZombieTaskTimeout time.Duration `ini:"ZOMBIE_TASK_TIMEOUT"`
25-
EndlessTaskTimeout time.Duration `ini:"ENDLESS_TASK_TIMEOUT"`
26-
AbandonedJobTimeout time.Duration `ini:"ABANDONED_JOB_TIMEOUT"`
27-
SkipWorkflowStrings []string `ini:"SKIP_WORKFLOW_STRINGS"`
17+
Enabled bool
18+
LogStorage *Storage // how the created logs should be stored
19+
LogRetentionDays int64 `ini:"LOG_RETENTION_DAYS"`
20+
LogCompression logCompression `ini:"LOG_COMPRESSION"`
21+
ArtifactStorage *Storage // how the created artifacts should be stored
22+
ArtifactRetentionDays int64 `ini:"ARTIFACT_RETENTION_DAYS"`
23+
DefaultActionsURL defaultActionsURL `ini:"DEFAULT_ACTIONS_URL"`
24+
ZombieTaskTimeout time.Duration `ini:"ZOMBIE_TASK_TIMEOUT"`
25+
EndlessTaskTimeout time.Duration `ini:"ENDLESS_TASK_TIMEOUT"`
26+
AbandonedJobTimeout time.Duration `ini:"ABANDONED_JOB_TIMEOUT"`
27+
SkipWorkflowStrings []string `ini:"SKIP_WORKFLOW_STRINGS"`
28+
EnableAutoCancellation bool `ini:"ENABLE_AUTO_CANCELLATION"`
2829
}{
29-
Enabled: true,
30-
DefaultActionsURL: defaultActionsURLGitHub,
31-
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
30+
Enabled: true,
31+
DefaultActionsURL: defaultActionsURLGitHub,
32+
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
33+
EnableAutoCancellation: true,
3234
}
3335
)
3436

0 commit comments

Comments
 (0)