You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rerun.go 897B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package actions
  4. import (
  5. actions_model "code.gitea.io/gitea/models/actions"
  6. "code.gitea.io/gitea/modules/container"
  7. )
  8. // GetAllRerunJobs get all jobs that need to be rerun when job should be rerun
  9. func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob {
  10. rerunJobs := []*actions_model.ActionRunJob{job}
  11. rerunJobsIDSet := make(container.Set[string])
  12. rerunJobsIDSet.Add(job.JobID)
  13. for {
  14. found := false
  15. for _, j := range allJobs {
  16. if rerunJobsIDSet.Contains(j.JobID) {
  17. continue
  18. }
  19. for _, need := range j.Needs {
  20. if rerunJobsIDSet.Contains(need) {
  21. found = true
  22. rerunJobs = append(rerunJobs, j)
  23. rerunJobsIDSet.Add(j.JobID)
  24. break
  25. }
  26. }
  27. }
  28. if !found {
  29. break
  30. }
  31. }
  32. return rerunJobs
  33. }