diff --git a/models/actions/run_job.go b/models/actions/run_job.go index 30a24368ea..17a056efda 100644 --- a/models/actions/run_job.go +++ b/models/actions/run_job.go @@ -21,21 +21,23 @@ import ( // ActionRunJob represents a job of a run type ActionRunJob struct { ID int64 - RunID int64 `xorm:"index index(idx_action_run_job_run_id_job_id)"` + RunID int64 `xorm:"index index(idx_run_id_job_id)"` Run *ActionRun `xorm:"-"` RepoID int64 `xorm:"index(repo_concurrency)"` Repo *repo_model.Repository `xorm:"-"` OwnerID int64 `xorm:"index"` CommitSHA string `xorm:"index"` IsForkPullRequest bool - Name string `xorm:"VARCHAR(255)"` - Attempt int64 + + // ...existing code... + Name string `xorm:"VARCHAR(255)"` + Attempt int64 // WorkflowPayload is act/jobparser.SingleWorkflow for act/jobparser.Parse // it should contain exactly one job with global workflow fields for this model WorkflowPayload []byte - JobID string `xorm:"VARCHAR(255) index(idx_action_run_job_run_id_job_id)"` // job id in workflow, not job's id + JobID string `xorm:"VARCHAR(255) index(idx_run_id_job_id)"` // job id in workflow, not job's id Needs []string `xorm:"JSON TEXT"` RunsOn []string `xorm:"JSON TEXT"` TaskID int64 // the latest task of the job diff --git a/models/actions/task.go b/models/actions/task.go index 1f4a522512..55df47fd7f 100644 --- a/models/actions/task.go +++ b/models/actions/task.go @@ -264,8 +264,8 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask continue } - // max-parallel is enforced at insertion time (InsertRun) and by - // jobStatusResolver, so a Waiting job is guaranteed a free slot. + // max-parallel is enforced at insertion time (InsertRun) and by + // jobStatusResolver, so a Waiting job is guaranteed a free slot. job = v break diff --git a/services/actions/job_emitter.go b/services/actions/job_emitter.go index 3d41771c57..b3cdc6d3ad 100644 --- a/services/actions/job_emitter.go +++ b/services/actions/job_emitter.go @@ -352,9 +352,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model } } - // Enforce max-parallel: count occupied slots from the current snapshot - // plus within-pass promotions. - if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 { + // Enforce max-parallel: count occupied slots from the current snapshot + // plus within-pass promotions. + if newStatus == actions_model.StatusWaiting && actionRunJob.MaxParallel > 0 { occupiedSlots := 0 for otherID, otherStatus := range r.statuses { otherJob := r.jobMap[otherID] @@ -363,9 +363,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model occupiedSlots++ } } - if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel { - continue // no free slot; leave blocked - } + if occupiedSlots+promotedWaitingByJobID[actionRunJob.JobID] >= actionRunJob.MaxParallel { + continue // no free slot; leave blocked + } promotedWaitingByJobID[actionRunJob.JobID]++ } diff --git a/services/actions/run.go b/services/actions/run.go index ace9ceb08f..8fbf6f1133 100644 --- a/services/actions/run.go +++ b/services/actions/run.go @@ -106,8 +106,8 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar runJobs := make([]*actions_model.ActionRunJob, 0, len(jobs)) var hasWaitingJobs bool - // waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel. - waitingCountByJobID := make(map[string]int) + // waitingCountByJobID limits initial Waiting slots per JobID to MaxParallel. + waitingCountByJobID := make(map[string]int) for _, v := range jobs { id, job := v.Job() @@ -173,9 +173,9 @@ func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobpar } } - // Enforce max-parallel: excess jobs start as Blocked and are promoted - // by jobStatusResolver when a slot opens. - if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 { + // Enforce max-parallel: excess jobs start as Blocked and are promoted + // by jobStatusResolver when a slot opens. + if runJob.Status == actions_model.StatusWaiting && runJob.MaxParallel > 0 { if waitingCountByJobID[id] >= runJob.MaxParallel { runJob.Status = actions_model.StatusBlocked } else {