Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zettat123 committed Jan 2, 2025
1 parent 80784e0 commit 461c7c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions models/actions/run_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func ShouldBlockJobByConcurrency(ctx context.Context, job *ActionRunJob) (bool,
return false, nil
}
if !job.IsConcurrencyEvaluated {
return false, fmt.Errorf("the raw concurrency group has not been evaluated")
return false, ErrUnevaluatedConcurrency{}
}
if len(job.ConcurrencyGroup) == 0 || job.ConcurrencyCancel {
return false, nil
Expand Down Expand Up @@ -225,7 +225,7 @@ func ShouldBlockJobByConcurrency(ctx context.Context, job *ActionRunJob) (bool,
func CancelPreviousJobsByConcurrency(ctx context.Context, job *ActionRunJob) error {
if len(job.RawConcurrencyGroup) > 0 {
if !job.IsConcurrencyEvaluated {
return fmt.Errorf("the raw concurrency group has not been evaluated")
return ErrUnevaluatedConcurrency{}
}
if len(job.ConcurrencyGroup) > 0 && job.ConcurrencyCancel {
// cancel previous jobs in the same concurrency group
Expand Down Expand Up @@ -274,3 +274,15 @@ func CancelPreviousJobsByConcurrency(ctx context.Context, job *ActionRunJob) err

return nil
}

type ErrUnevaluatedConcurrency struct {
}

func IsErrUnevaluatedConcurrency(err error) bool {
_, ok := err.(ErrUnevaluatedConcurrency)
return ok
}

func (err ErrUnevaluatedConcurrency) Error() string {
return "the raw concurrency group has not been evaluated"
}
3 changes: 3 additions & 0 deletions routers/web/repo/actions/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ func Approve(ctx *context_module.Context) {
for _, job := range jobs {
blockJobByConcurrency, err := actions_model.ShouldBlockJobByConcurrency(ctx, job)
if err != nil {
if actions_model.IsErrUnevaluatedConcurrency(err) {
continue
}
return err
}
if len(job.Needs) == 0 && job.Status.IsBlocked() && !blockJobByConcurrency {
Expand Down

0 comments on commit 461c7c1

Please sign in to comment.