Skip to content

Commit e5ac174

Browse files
committed
fix
1 parent 8f5948b commit e5ac174

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

routers/web/repo/actions/view.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,35 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
442442
job.Started = 0
443443
job.Stopped = 0
444444

445+
job.ConcurrencyGroup = ""
446+
job.ConcurrencyCancel = false
447+
job.IsConcurrencyEvaluated = false
448+
if err := job.LoadRun(ctx); err != nil {
449+
return err
450+
}
451+
vars, err := actions_model.GetVariablesOfRun(ctx, job.Run)
452+
if err != nil {
453+
return fmt.Errorf("get run %d variables: %w", job.Run.ID, err)
454+
}
455+
if job.RawConcurrencyGroup != "" && job.Status != actions_model.StatusBlocked {
456+
var err error
457+
job.ConcurrencyGroup, job.ConcurrencyCancel, err = actions_service.EvaluateJobConcurrency(job.Run, job, vars, nil)
458+
if err != nil {
459+
return fmt.Errorf("evaluate job concurrency: %w", err)
460+
}
461+
job.IsConcurrencyEvaluated = true
462+
blockByConcurrency, err := actions_model.ShouldBlockJobByConcurrency(ctx, job)
463+
if err != nil {
464+
return err
465+
}
466+
if blockByConcurrency {
467+
job.Status = actions_model.StatusBlocked
468+
}
469+
}
470+
445471
if err := db.WithTx(ctx, func(ctx context.Context) error {
446-
_, err := actions_model.UpdateRunJob(ctx, job, builder.Eq{"status": status}, "task_id", "status", "started", "stopped")
472+
updateCols := []string{"task_id", "status", "started", "stopped", "concurrency_group", "concurrency_cancel", "is_concurrency_evaluated"}
473+
_, err := actions_model.UpdateRunJob(ctx, job, builder.Eq{"status": status}, updateCols...)
447474
return err
448475
}); err != nil {
449476
return err

services/actions/concurrency.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
act_model "github.com/nektos/act/pkg/model"
1313
)
1414

15-
func evaluateJobConcurrency(run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
15+
func EvaluateJobConcurrency(run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
1616
rawConcurrency := &act_model.RawConcurrency{
1717
Group: actionRunJob.RawConcurrencyGroup,
1818
CancelInProgress: actionRunJob.RawConcurrencyCancel,

services/actions/job_emitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func checkConcurrencyForJobWithNeeds(ctx context.Context, actionRunJob *actions_
291291
jobResults[jobID] = jobResult
292292
}
293293

294-
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = evaluateJobConcurrency(actionRunJob.Run, actionRunJob, vars, jobResults)
294+
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = EvaluateJobConcurrency(actionRunJob.Run, actionRunJob, vars, jobResults)
295295
if err != nil {
296296
return false, fmt.Errorf("evaluate job concurrency: %w", err)
297297
}

services/actions/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar
9393
}
9494

9595
// check job concurrency
96-
if job.RawConcurrency != nil && len(job.RawConcurrency.Group) > 0 {
96+
if job.RawConcurrency != nil && job.RawConcurrency.Group != "" {
9797
runJob.RawConcurrencyGroup = job.RawConcurrency.Group
9898
runJob.RawConcurrencyCancel = job.RawConcurrency.CancelInProgress
9999
// we do not need to evaluate job concurrency if the job is blocked because it will be checked by job emitter
100100
if runJob.Status != actions_model.StatusBlocked {
101101
var err error
102-
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = evaluateJobConcurrency(run, runJob, vars, map[string]*jobparser.JobResult{})
102+
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = EvaluateJobConcurrency(run, runJob, vars, nil)
103103
if err != nil {
104104
return fmt.Errorf("evaluate job concurrency: %w", err)
105105
}

0 commit comments

Comments
 (0)