enhance(actions): add pending job status and align job statuses with GitHub (#39376)

This commit is contained in:
silverwind authored and GitHub committed 2026-09-27 18:30:42 +00:00
1 parent 0d09986790
commit 9e7b302bd3
45 files changed
+397 -189

No files matched your search

+5 -2
View File
@@ -622,7 +622,7 @@ func RefreshReusableCallerStatus(ctx context.Context, caller *ActionRunJob) erro
func AggregateJobStatus(jobs []*ActionRunJob) Status {
allSuccessOrSkipped := len(jobs) != 0
allSkipped := len(jobs) != 0
var hasFailure, hasCancelled, hasCancelling, hasWaiting, hasRunning, hasBlocked bool
var hasFailure, hasCancelled, hasCancelling, hasWaiting, hasRunning, hasBlocked, hasPending bool
for _, job := range jobs {
// A failed job with continue-on-error:true does not fail the workflow run.
// It counts as a "continued failure" and is treated like success for aggregation.
@@ -635,6 +635,7 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
hasWaiting = hasWaiting || job.Status == StatusWaiting
hasRunning = hasRunning || job.Status == StatusRunning
hasBlocked = hasBlocked || job.Status == StatusBlocked
hasPending = hasPending || job.Status == StatusPending
}
switch {
case allSkipped:
@@ -648,9 +649,11 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
case hasWaiting:
return StatusWaiting
case hasBlocked:
// Blocked is still a pending state, so it should outrank terminal
// Blocked is still an unfinished state, so it should outrank terminal
// statuses like cancelled/failure when no job is waiting or running.
return StatusBlocked
case hasPending:
return StatusRunning // a run with only pending jobs left is still in progress
case hasCancelled:
if hasFailure && hasFailFastMatrixFailure(jobs) {
return StatusFailure
+2
View File
@@ -76,6 +76,8 @@ func TestAggregateJobStatus(t *testing.T) {
{[]Status{StatusFailure, StatusWaiting}, StatusWaiting},
{[]Status{StatusFailure, StatusRunning}, StatusRunning},
{[]Status{StatusFailure, StatusBlocked}, StatusBlocked},
{[]Status{StatusFailure, StatusPending}, StatusRunning},
{[]Status{StatusBlocked, StatusPending}, StatusBlocked},
// skipped with other status
// "all skipped" is also considered as "mergeable" by "services/actions.toCommitStatus", the same as GitHub
+6
View File
@@ -23,6 +23,7 @@ const (
StatusRunning // 6, isn't a runnerv1.Result
StatusBlocked // 7, isn't a runnerv1.Result
StatusCancelling // 8, isn't a runnerv1.Result
StatusPending // 9, isn't a runnerv1.Result
)
var statusNames = map[Status]string{
@@ -35,6 +36,7 @@ var statusNames = map[Status]string{
StatusCancelling: "cancelling",
StatusSkipped: "skipped",
StatusBlocked: "blocked",
StatusPending: "pending",
}
// String returns the string name of the Status
@@ -93,6 +95,10 @@ func (s Status) IsCancelling() bool {
return s == StatusCancelling
}
func (s Status) IsPending() bool {
return s == StatusPending
}
// In returns whether s is one of the given statuses
func (s Status) In(statuses ...Status) bool {
return slices.Contains(statuses, s)