Skip to content

Commit 0ed98a5

Browse files
committed
fix nil ptr
1 parent b231cf3 commit 0ed98a5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

services/actions/concurrency.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func PrepareConcurrencyForRunAndJobs(ctx context.Context, wfContent []byte, run
7070
// because it will be checked by job emitter
7171
if runJob.Status != actions_model.StatusBlocked && len(needs) == 0 {
7272
var err error
73-
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = evaluateJobConcurrency(ctx, runJob, vars, map[string]*jobparser.JobResult{})
73+
runJob.ConcurrencyGroup, runJob.ConcurrencyCancel, err = evaluateJobConcurrency(run, runJob, vars, map[string]*jobparser.JobResult{})
7474
if err != nil {
7575
return nil, fmt.Errorf("evaluate job concurrency: %w", err)
7676
}
@@ -83,12 +83,7 @@ func PrepareConcurrencyForRunAndJobs(ctx context.Context, wfContent []byte, run
8383
return runJobs, nil
8484
}
8585

86-
func evaluateJobConcurrency(ctx context.Context, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
87-
if err := actionRunJob.LoadRun(ctx); err != nil {
88-
return "", false, err
89-
}
90-
run := actionRunJob.Run
91-
86+
func evaluateJobConcurrency(run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string, jobResults map[string]*jobparser.JobResult) (string, bool, error) {
9287
rawConcurrency := &act_model.RawConcurrency{
9388
Group: actionRunJob.RawConcurrencyGroup,
9489
CancelInProgress: actionRunJob.RawConcurrencyCancel,
@@ -102,7 +97,11 @@ func evaluateJobConcurrency(ctx context.Context, actionRunJob *actions_model.Act
10297
}
10398
actJob := actWorkflow.GetJob(actionRunJob.JobID)
10499

105-
concurrencyGroup, concurrencyCancel := jobparser.EvaluateJobConcurrency(rawConcurrency, actJob, gitCtx, vars, jobResults)
100+
if len(jobResults) == 0 {
101+
jobResults = map[string]*jobparser.JobResult{actionRunJob.JobID: {}}
102+
}
103+
104+
concurrencyGroup, concurrencyCancel := jobparser.EvaluateJobConcurrency(rawConcurrency, actionRunJob.JobID, actJob, gitCtx, vars, jobResults)
106105

107106
return concurrencyGroup, concurrencyCancel, nil
108107
}

services/actions/job_emitter.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ func checkJobConcurrency(ctx context.Context, actionRunJob *actions_model.Action
227227
if len(actionRunJob.RawConcurrencyGroup) == 0 {
228228
return false, nil
229229
}
230+
if err := actionRunJob.LoadRun(ctx); err != nil {
231+
return false, err
232+
}
230233

231234
if len(actionRunJob.ConcurrencyGroup) == 0 {
232235
// empty concurrency group means the raw concurrency has not been evaluated
@@ -247,7 +250,7 @@ func checkJobConcurrency(ctx context.Context, actionRunJob *actions_model.Action
247250
jobResults[jobID] = jobResult
248251
}
249252

250-
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = evaluateJobConcurrency(ctx, actionRunJob, vars, jobResults)
253+
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = evaluateJobConcurrency(actionRunJob.Run, actionRunJob, vars, jobResults)
251254
if err != nil {
252255
return false, fmt.Errorf("evaluate job concurrency: %w", err)
253256
}

0 commit comments

Comments
 (0)