Skip to content

Commit 84d6254

Browse files
committed
fix comment
1 parent 87d7f65 commit 84d6254

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

routers/web/repo/actions/view.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,13 @@ func Approve(ctx *context_module.Context) {
661661
if err != nil {
662662
return err
663663
}
664-
if len(job.Needs) == 0 && job.Status.IsBlocked() && !blockJobByConcurrency {
665-
if err := actions_service.CancelJobsByJobConcurrency(ctx, job); err != nil {
666-
return fmt.Errorf("cancel jobs: %w", err)
667-
}
664+
if !blockJobByConcurrency {
668665
job.Status = actions_model.StatusWaiting
666+
}
667+
if err := actions_service.CancelJobsByJobConcurrency(ctx, job); err != nil {
668+
return fmt.Errorf("cancel jobs: %w", err)
669+
}
670+
if job.Status == actions_model.StatusWaiting {
669671
n, err := actions_model.UpdateRunJob(ctx, job, nil, "status")
670672
if err != nil {
671673
return err

services/actions/job_emitter.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,9 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
317317
continue
318318
}
319319

320-
blockedByJobConcurrency, err := actions_model.ShouldBlockJobByConcurrency(ctx, actionRunJob)
321-
if err != nil {
322-
log.Error("ShouldBlockJobByConcurrency failed, this job will stay blocked: job: %d, err: %v", id, err)
323-
continue
324-
}
325-
if blockedByJobConcurrency {
326-
continue
327-
}
328-
329-
if err := CancelJobsByJobConcurrency(ctx, r.jobMap[id]); err != nil {
330-
log.Error("Cancel previous jobs for job %d: %v", id, err)
331-
}
332-
320+
newStatus := actions_model.StatusBlocked
333321
if allSucceed {
334-
ret[id] = actions_model.StatusWaiting
322+
newStatus = actions_model.StatusWaiting
335323
} else {
336324
// Check if the job has an "if" condition
337325
hasIf := false
@@ -341,13 +329,31 @@ func (r *jobStatusResolver) resolve(ctx context.Context) map[int64]actions_model
341329
}
342330
if hasIf {
343331
// act_runner will check the "if" condition
344-
ret[id] = actions_model.StatusWaiting
332+
newStatus = actions_model.StatusWaiting
345333
} else {
346334
// If the "if" condition is empty and not all dependent jobs completed successfully,
347335
// the job should be skipped.
348-
ret[id] = actions_model.StatusSkipped
336+
newStatus = actions_model.StatusSkipped
349337
}
350338
}
339+
340+
if newStatus == actions_model.StatusWaiting {
341+
blockedByJobConcurrency, err := actions_model.ShouldBlockJobByConcurrency(ctx, actionRunJob)
342+
if err != nil {
343+
log.Error("ShouldBlockJobByConcurrency failed, this job will stay blocked: job: %d, err: %v", id, err)
344+
continue
345+
}
346+
if blockedByJobConcurrency {
347+
newStatus = actions_model.StatusBlocked
348+
}
349+
if err := CancelJobsByJobConcurrency(ctx, r.jobMap[id]); err != nil {
350+
log.Error("Cancel previous jobs for job %d: %v", id, err)
351+
}
352+
}
353+
354+
if newStatus != actions_model.StatusBlocked {
355+
ret[id] = newStatus
356+
}
351357
}
352358
}
353359
return ret

0 commit comments

Comments
 (0)