Skip to content

Commit ffa0109

Browse files
committed
fix
1 parent 7aefe44 commit ffa0109

File tree

6 files changed

+11
-18
lines changed

6 files changed

+11
-18
lines changed

models/actions/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
369369
type ActionRunIndex db.ResourceIndex
370370

371371
func ShouldBlockRunByConcurrency(ctx context.Context, actionRun *ActionRun) (bool, error) {
372-
if actionRun.ConcurrencyGroup != "" || actionRun.ConcurrencyCancel {
372+
if actionRun.ConcurrencyGroup == "" || actionRun.ConcurrencyCancel {
373373
return false, nil
374374
}
375375

models/actions/run_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
193193
}
194194

195195
func ShouldBlockJobByConcurrency(ctx context.Context, job *ActionRunJob) (bool, error) {
196-
if job.RawConcurrencyGroup != "" {
196+
if job.RawConcurrencyGroup == "" {
197197
return false, nil
198198
}
199199
if !job.IsConcurrencyEvaluated {
@@ -202,7 +202,7 @@ func ShouldBlockJobByConcurrency(ctx context.Context, job *ActionRunJob) (bool,
202202
CancelInProgress: job.RawConcurrencyCancel,
203203
}
204204
}
205-
if job.ConcurrencyGroup != "" || job.ConcurrencyCancel {
205+
if job.ConcurrencyGroup == "" || job.ConcurrencyCancel {
206206
return false, nil
207207
}
208208

routers/web/repo/actions/view.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ func Run(ctx *context_module.Context) {
944944
ctx.ServerError("GetVariablesOfRun", err)
945945
return
946946
}
947-
wfConcurrencyGroup, wfConcurrencyCancel, err := actions_service.EvaluateWorkflowConcurrency(run, wfRawConcurrency, vars)
947+
wfConcurrencyGroup, wfConcurrencyCancel, err := actions_service.EvaluateWorkflowConcurrency(ctx, run, wfRawConcurrency, vars)
948948
if err != nil {
949949
ctx.ServerError("EvaluateWorkflowConcurrency", err)
950950
return
@@ -955,17 +955,6 @@ func Run(ctx *context_module.Context) {
955955
}
956956
}
957957

958-
// cancel running jobs of the same workflow
959-
if err := actions_model.CancelPreviousJobs(
960-
ctx,
961-
run.RepoID,
962-
run.Ref,
963-
run.WorkflowID,
964-
run.Event,
965-
); err != nil {
966-
log.Error("CancelRunningJobs: %v", err)
967-
}
968-
969958
// Insert the action run and its associated jobs into the database
970959
if err := actions_service.InsertRun(ctx, run, workflows); err != nil {
971960
ctx.ServerError("workflow", err)

services/actions/concurrency.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package actions
55

66
import (
7+
"context"
78
"fmt"
89

910
actions_model "code.gitea.io/gitea/models/actions"
@@ -14,7 +15,10 @@ import (
1415
act_model "github.com/nektos/act/pkg/model"
1516
)
1617

17-
func EvaluateWorkflowConcurrency(run *actions_model.ActionRun, rc *act_model.RawConcurrency, vars map[string]string) (string, bool, error) {
18+
func EvaluateWorkflowConcurrency(ctx context.Context, run *actions_model.ActionRun, rc *act_model.RawConcurrency, vars map[string]string) (string, bool, error) {
19+
if err := run.LoadAttributes(ctx); err != nil {
20+
return "", false, fmt.Errorf("run LoadAttributes: %w", err)
21+
}
1822
gitCtx := jobparser.ToGitContext(GenerateGiteaContext(run, nil))
1923
jobResults := map[string]*jobparser.JobResult{"": {}}
2024
inputs, err := getInputsFromRun(run)

services/actions/notifier_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func handleWorkflows(
338338
continue
339339
}
340340
if wfRawConcurrency != nil {
341-
wfConcurrencyGroup, wfConcurrencyCancel, err := EvaluateWorkflowConcurrency(run, wfRawConcurrency, vars)
341+
wfConcurrencyGroup, wfConcurrencyCancel, err := EvaluateWorkflowConcurrency(ctx, run, wfRawConcurrency, vars)
342342
if err != nil {
343343
log.Error("EvaluateWorkflowConcurrency: %v", err)
344344
continue

services/actions/schedule_tasks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule)
148148
return err
149149
}
150150
if wfRawConcurrency != nil {
151-
wfConcurrencyGroup, wfConcurrencyCancel, err := EvaluateWorkflowConcurrency(run, wfRawConcurrency, vars)
151+
wfConcurrencyGroup, wfConcurrencyCancel, err := EvaluateWorkflowConcurrency(ctx, run, wfRawConcurrency, vars)
152152
if err != nil {
153153
return err
154154
}

0 commit comments

Comments
 (0)