Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zettat123 committed Jan 15, 2025
1 parent 8f5948b commit e5ac174
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
29 changes: 28 additions & 1 deletion routers/web/repo/actions/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,35 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
job.Started = 0
job.Stopped = 0

job.ConcurrencyGroup = ""
job.ConcurrencyCancel = false
job.IsConcurrencyEvaluated = false
if err := job.LoadRun(ctx); err != nil {
return err
}
vars, err := actions_model.GetVariablesOfRun(ctx, job.Run)
if err != nil {
return fmt.Errorf("get run %d variables: %w", job.Run.ID, err)
}
if job.RawConcurrencyGroup != "" && job.Status != actions_model.StatusBlocked {
var err error
job.ConcurrencyGroup, job.ConcurrencyCancel, err = actions_service.EvaluateJobConcurrency(job.Run, job, vars, nil)
if err != nil {
return fmt.Errorf("evaluate job concurrency: %w", err)
}
job.IsConcurrencyEvaluated = true
blockByConcurrency, err := actions_model.ShouldBlockJobByConcurrency(ctx, job)
if err != nil {
return err
}
if blockByConcurrency {
job.Status = actions_model.StatusBlocked
}
}

if err := db.WithTx(ctx, func(ctx context.Context) error {
_, err := actions_model.UpdateRunJob(ctx, job, builder.Eq{"status": status}, "task_id", "status", "started", "stopped")
updateCols := []string{"task_id", "status", "started", "stopped", "concurrency_group", "concurrency_cancel", "is_concurrency_evaluated"}
_, err := actions_model.UpdateRunJob(ctx, job, builder.Eq{"status": status}, updateCols...)
return err
}); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion services/actions/concurrency.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
act_model "github.com/nektos/act/pkg/model"
)

func evaluateJobConcurrency(run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
func EvaluateJobConcurrency(run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
rawConcurrency := &act_model.RawConcurrency{

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / backend

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-pgsql

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-sqlite

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-mysql

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-mssql

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-unit

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

undefined: act_model.RawConcurrency

Check failure on line 16 in services/actions/concurrency.go

View workflow job for this annotation

GitHub Actions / lint-backend

undefined: act_model.RawConcurrency
Group: actionRunJob.RawConcurrencyGroup,
CancelInProgress: actionRunJob.RawConcurrencyCancel,
Expand Down
2 changes: 1 addition & 1 deletion services/actions/job_emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func checkConcurrencyForJobWithNeeds(ctx context.Context, actionRunJob *actions_
jobResults[jobID] = jobResult
}

actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = evaluateJobConcurrency(actionRunJob.Run, actionRunJob, vars, jobResults)
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = EvaluateJobConcurrency(actionRunJob.Run, actionRunJob, vars, jobResults)
if err != nil {
return false, fmt.Errorf("evaluate job concurrency: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions services/actions/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar
}

// check job concurrency
if job.RawConcurrency != nil && len(job.RawConcurrency.Group) > 0 {
if job.RawConcurrency != nil && job.RawConcurrency.Group != "" {

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-pgsql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-sqlite

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mysql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mssql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-unit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-e2e

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 96 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)
runJob.RawConcurrencyGroup = job.RawConcurrency.Group

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-pgsql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-sqlite

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mysql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mssql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-unit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-e2e

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 97 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)
runJob.RawConcurrencyCancel = job.RawConcurrency.CancelInProgress

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-pgsql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-sqlite

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mysql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-mssql

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-unit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / test-e2e

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)) (typecheck)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)) (typecheck)

Check failure on line 98 in services/actions/run.go

View workflow job for this annotation

GitHub Actions / lint-backend

job.RawConcurrency undefined (type *jobparser.Job has no field or method RawConcurrency)) (typecheck)
// we do not need to evaluate job concurrency if the job is blocked because it will be checked by job emitter
if runJob.Status != actions_model.StatusBlocked {
var err error
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = evaluateJobConcurrency(run, runJob, vars, map[string]*jobparser.JobResult{})
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = EvaluateJobConcurrency(run, runJob, vars, nil)
if err != nil {
return fmt.Errorf("evaluate job concurrency: %w", err)
}
Expand Down

0 comments on commit e5ac174

Please sign in to comment.