|
|
|
@ -11,6 +11,7 @@ import (
|
|
|
|
|
|
|
|
|
|
func TestAggregateJobStatus(t *testing.T) {
|
|
|
|
|
testStatuses := func(expected Status, statuses []Status) {
|
|
|
|
|
t.Helper()
|
|
|
|
|
var jobs []*ActionRunJob
|
|
|
|
|
for _, v := range statuses {
|
|
|
|
|
jobs = append(jobs, &ActionRunJob{Status: v})
|
|
|
|
@ -29,6 +30,16 @@ func TestAggregateJobStatus(t *testing.T) {
|
|
|
|
|
statuses []Status
|
|
|
|
|
expected Status
|
|
|
|
|
}{
|
|
|
|
|
// unknown cases, maybe it shouldn't happen in real world
|
|
|
|
|
{[]Status{}, StatusUnknown},
|
|
|
|
|
{[]Status{StatusUnknown, StatusSuccess}, StatusUnknown},
|
|
|
|
|
{[]Status{StatusUnknown, StatusSkipped}, StatusUnknown},
|
|
|
|
|
{[]Status{StatusUnknown, StatusFailure}, StatusFailure},
|
|
|
|
|
{[]Status{StatusUnknown, StatusCancelled}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusUnknown, StatusWaiting}, StatusWaiting},
|
|
|
|
|
{[]Status{StatusUnknown, StatusRunning}, StatusRunning},
|
|
|
|
|
{[]Status{StatusUnknown, StatusBlocked}, StatusBlocked},
|
|
|
|
|
|
|
|
|
|
// success with other status
|
|
|
|
|
{[]Status{StatusSuccess}, StatusSuccess},
|
|
|
|
|
{[]Status{StatusSuccess, StatusSkipped}, StatusSuccess}, // skipped doesn't affect success
|
|
|
|
@ -38,18 +49,28 @@ func TestAggregateJobStatus(t *testing.T) {
|
|
|
|
|
{[]Status{StatusSuccess, StatusRunning}, StatusRunning},
|
|
|
|
|
{[]Status{StatusSuccess, StatusBlocked}, StatusBlocked},
|
|
|
|
|
|
|
|
|
|
// any cancelled, then cancelled
|
|
|
|
|
{[]Status{StatusCancelled}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusSuccess}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusSkipped}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusFailure}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusWaiting}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusRunning}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusCancelled, StatusBlocked}, StatusCancelled},
|
|
|
|
|
|
|
|
|
|
// failure with other status, fail fast
|
|
|
|
|
// Should "running" win? Maybe no: old code does make "running" win, but GitHub does fail fast.
|
|
|
|
|
{[]Status{StatusFailure}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusSuccess}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusSkipped}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusCancelled}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusCancelled}, StatusCancelled},
|
|
|
|
|
{[]Status{StatusFailure, StatusWaiting}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusRunning}, StatusFailure},
|
|
|
|
|
{[]Status{StatusFailure, StatusBlocked}, StatusFailure},
|
|
|
|
|
|
|
|
|
|
// skipped with other status
|
|
|
|
|
{[]Status{StatusSkipped}, StatusSuccess},
|
|
|
|
|
// TODO: need to clarify whether a PR with "skipped" job status is considered as "mergeable" or not.
|
|
|
|
|
{[]Status{StatusSkipped}, StatusSkipped},
|
|
|
|
|
{[]Status{StatusSkipped, StatusSuccess}, StatusSuccess},
|
|
|
|
|
{[]Status{StatusSkipped, StatusFailure}, StatusFailure},
|
|
|
|
|
{[]Status{StatusSkipped, StatusCancelled}, StatusCancelled},
|
|
|
|
|