diff --git a/services/actions/job_emitter.go b/services/actions/job_emitter.go index 593e17517a..0a9c297033 100644 --- a/services/actions/job_emitter.go +++ b/services/actions/job_emitter.go @@ -192,7 +192,7 @@ func (r *jobStatusResolver) resolve() map[int64]actions_model.Status { if status != actions_model.StatusBlocked { continue } - allDone, allSucceed := true, true + allDone, allSucceed, allSucceedOrSkip := true, true, true for _, need := range r.needs[id] { needStatus := r.statuses[need] if !needStatus.IsDone() { @@ -201,13 +201,16 @@ func (r *jobStatusResolver) resolve() map[int64]actions_model.Status { if needStatus.In(actions_model.StatusFailure, actions_model.StatusCancelled, actions_model.StatusSkipped) { allSucceed = false } + if needStatus.In(actions_model.StatusFailure, actions_model.StatusCancelled) { + allSucceedOrSkip = false + } } if allDone { if isWorkflowCallOuterJob, _ := r.jobMap[id].IsWorkflowCallOuterJob(); isWorkflowCallOuterJob { // If the dependent job was a workflow call outer job, then options aren't waiting/skipped, but rather // success/failure. checkJobsOfRun will do additional work in these cases to "finish" the workflow call // job as well. - if allSucceed { + if allSucceedOrSkip { isIncompleteMatrix, _, _ := r.jobMap[id].HasIncompleteMatrix() isIncompleteWith, _, _, _ := r.jobMap[id].HasIncompleteWith() if isIncompleteMatrix || isIncompleteWith { diff --git a/services/actions/job_emitter_test.go b/services/actions/job_emitter_test.go index 44e9163102..a7e3b7467b 100644 --- a/services/actions/job_emitter_test.go +++ b/services/actions/job_emitter_test.go @@ -146,6 +146,27 @@ jobs: ` name: test on: push +jobs: + job2: + if: false + uses: ./.forgejo/workflows/reusable.yml +__metadata: + workflow_call_id: b5a9f46f1f2513d7777fde50b169d323a6519e349cc175484c947ac315a209ed +`)}, + }, + want: map[int64]actions_model.Status{ + 3: actions_model.StatusSuccess, + }, + }, + { + name: "unblocked workflow call outer job with success and skip", + jobs: actions_model.ActionJobList{ + {ID: 1, JobID: "job1.innerjob1", Status: actions_model.StatusSuccess, Needs: []string{}}, + {ID: 2, JobID: "job1.innerjob2", Status: actions_model.StatusSkipped, Needs: []string{}}, + {ID: 3, JobID: "job1", Status: actions_model.StatusBlocked, Needs: []string{"job1.innerjob1", "job1.innerjob2"}, WorkflowPayload: []byte( + ` +name: test +on: push jobs: job2: if: false @@ -219,6 +240,27 @@ __metadata: ` name: test on: push +jobs: + job2: + if: false + uses: ./.forgejo/workflows/reusable.yml +__metadata: + workflow_call_id: b5a9f46f1f2513d7777fde50b169d323a6519e349cc175484c947ac315a209ed +`)}, + }, + want: map[int64]actions_model.Status{ + 3: actions_model.StatusFailure, + }, + }, + { + name: "unblocked workflow call outer job with internal failure", + jobs: actions_model.ActionJobList{ + {ID: 1, JobID: "job1.innerjob1", Status: actions_model.StatusSkipped, Needs: []string{}}, + {ID: 2, JobID: "job1.innerjob2", Status: actions_model.StatusFailure, Needs: []string{}}, + {ID: 3, JobID: "job1", Status: actions_model.StatusBlocked, Needs: []string{"job1.innerjob1", "job1.innerjob2"}, WorkflowPayload: []byte( + ` +name: test +on: push jobs: job2: if: false