Show cancelled checks (#7960)
This commit is contained in:
parent
073ec3426b
commit
decbbd2165
5 changed files with 92 additions and 17 deletions
|
|
@ -25,6 +25,7 @@ type checkCounts struct {
|
|||
Passed int
|
||||
Pending int
|
||||
Skipping int
|
||||
Canceled int
|
||||
}
|
||||
|
||||
func aggregateChecks(checkContexts []api.CheckContext, requiredChecks bool) (checks []check, counts checkCounts) {
|
||||
|
|
@ -70,9 +71,12 @@ func aggregateChecks(checkContexts []api.CheckContext, requiredChecks bool) (che
|
|||
case "SKIPPED", "NEUTRAL":
|
||||
item.Bucket = "skipping"
|
||||
counts.Skipping++
|
||||
case "ERROR", "FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED":
|
||||
case "ERROR", "FAILURE", "TIMED_OUT", "ACTION_REQUIRED":
|
||||
item.Bucket = "fail"
|
||||
counts.Failed++
|
||||
case "CANCELLED":
|
||||
item.Bucket = "cancel"
|
||||
counts.Canceled++
|
||||
default: // "EXPECTED", "REQUESTED", "WAITING", "QUEUED", "PENDING", "IN_PROGRESS", "STALE"
|
||||
item.Bucket = "pending"
|
||||
counts.Pending++
|
||||
|
|
|
|||
|
|
@ -167,9 +167,21 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/someFailing.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "Some checks were not successful\n1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n",
|
||||
wantOut: "Some checks were not successful\n0 cancelled, 1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
name: "some cancelled tty",
|
||||
tty: true,
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query PullRequestStatusChecks\b`),
|
||||
httpmock.FileResponse("./fixtures/someCancelled.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "Some checks were cancelled\n1 cancelled, 0 failing, 2 successful, 0 skipped, and 0 pending checks\n\n✓ cool tests 1m26s sweet link\n- sad tests 1m26s sweet link\n✓ awesome tests 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
name: "some pending tty",
|
||||
tty: true,
|
||||
|
|
@ -179,7 +191,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/somePending.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "Some checks are still pending\n0 failing, 2 successful, 0 skipped, and 1 pending checks\n\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n* slow tests 1m26s sweet link\n",
|
||||
wantOut: "Some checks are still pending\n1 cancelled, 0 failing, 2 successful, 0 skipped, and 1 pending checks\n\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n* slow tests 1m26s sweet link\n- sad tests 1m26s sweet link\n",
|
||||
wantErr: "PendingError",
|
||||
},
|
||||
{
|
||||
|
|
@ -191,7 +203,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/allPassing.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -204,7 +216,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/allPassing.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "\x1b[?1049hAll checks were successful\n0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n\x1b[?1049lAll checks were successful\n0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantOut: "\x1b[?1049hAll checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n\x1b[?1049lAll checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -218,7 +230,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/someFailing.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "\x1b[?1049h\x1b[0;0H\x1b[JRefreshing checks status every 0 seconds. Press Ctrl+C to quit.\n\nSome checks were not successful\n1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n\x1b[?1049lSome checks were not successful\n1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n",
|
||||
wantOut: "\x1b[?1049h\x1b[0;0H\x1b[JRefreshing checks status every 0 seconds. Press Ctrl+C to quit.\n\nSome checks were not successful\n0 cancelled, 1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n\x1b[?1049lSome checks were not successful\n0 cancelled, 1 failing, 1 successful, 0 skipped, and 1 pending checks\n\nX sad tests 1m26s sweet link\n✓ cool tests 1m26s sweet link\n* slow tests 1m26s sweet link\n",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
|
|
@ -230,7 +242,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/withStatuses.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "Some checks were not successful\n1 failing, 2 successful, 0 skipped, and 0 pending checks\n\nX a status sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantOut: "Some checks were not successful\n0 cancelled, 1 failing, 2 successful, 0 skipped, and 0 pending checks\n\nX a status sweet link\n✓ cool tests 1m26s sweet link\n✓ rad tests 1m26s sweet link\n",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
|
|
@ -274,7 +286,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/somePending.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "cool tests\tpass\t1m26s\tsweet link\t\nrad tests\tpass\t1m26s\tsweet link\t\nslow tests\tpending\t1m26s\tsweet link\t\n",
|
||||
wantOut: "cool tests\tpass\t1m26s\tsweet link\t\nrad tests\tpass\t1m26s\tsweet link\t\nslow tests\tpending\t1m26s\tsweet link\t\nsad tests\tfail\t1m26s\tsweet link\t\n",
|
||||
wantErr: "PendingError",
|
||||
},
|
||||
{
|
||||
|
|
@ -308,7 +320,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/someSkipping.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 1 successful, 2 skipped, and 0 pending checks\n\n✓ cool tests 1m26s sweet link\n- rad tests 1m26s sweet link\n- skip tests 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 1 successful, 2 skipped, and 0 pending checks\n\n✓ cool tests 1m26s sweet link\n- rad tests 1m26s sweet link\n- skip tests 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -332,7 +344,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/onlyRequired.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 1 successful, 0 skipped, and 0 pending checks\n\n✓ cool tests 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 1 successful, 0 skipped, and 0 pending checks\n\n✓ cool tests 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -381,7 +393,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/withDescriptions.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests awesome description 1m26s sweet link\n✓ cool tests cool description 1m26s sweet link\n✓ rad tests rad description 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n✓ awesome tests awesome description 1m26s sweet link\n✓ cool tests cool description 1m26s sweet link\n✓ rad tests rad description 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -404,7 +416,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/withEvents.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 2 successful, 0 skipped, and 0 pending checks\n\n✓ tests/cool tests (pull_request) cool description 1m26s sweet link\n✓ tests/cool tests (push) cool description 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 2 successful, 0 skipped, and 0 pending checks\n\n✓ tests/cool tests (pull_request) cool description 1m26s sweet link\n✓ tests/cool tests (push) cool description 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -417,7 +429,7 @@ func Test_checksRun(t *testing.T) {
|
|||
httpmock.FileResponse("./fixtures/withoutEvents.json"),
|
||||
)
|
||||
},
|
||||
wantOut: "All checks were successful\n0 failing, 1 successful, 0 skipped, and 0 pending checks\n\n✓ tests/cool tests cool description 1m26s sweet link\n",
|
||||
wantOut: "All checks were successful\n0 cancelled, 0 failing, 1 successful, 0 skipped, and 0 pending checks\n\n✓ tests/cool tests cool description 1m26s sweet link\n",
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
|
|
|
|||
45
pkg/cmd/pr/checks/fixtures/someCancelled.json
Normal file
45
pkg/cmd/pr/checks/fixtures/someCancelled.json
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"data": {
|
||||
"node": {
|
||||
"statusCheckRollup": {
|
||||
"nodes": [
|
||||
{
|
||||
"commit": {
|
||||
"oid": "abc",
|
||||
"statusCheckRollup": {
|
||||
"contexts": {
|
||||
"nodes": [
|
||||
{
|
||||
"conclusion": "SUCCESS",
|
||||
"status": "COMPLETED",
|
||||
"name": "cool tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
},
|
||||
{
|
||||
"conclusion": "CANCELLED",
|
||||
"status": "COMPLETED",
|
||||
"name": "sad tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
},
|
||||
{
|
||||
"conclusion": "SUCCESS",
|
||||
"status": "COMPLETED",
|
||||
"name": "awesome tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,14 @@
|
|||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
},
|
||||
{
|
||||
"conclusion": "CANCELLED",
|
||||
"status": "COMPLETED",
|
||||
"name": "sad tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) {
|
|||
case "pending":
|
||||
mark = "*"
|
||||
markColor = cs.Yellow
|
||||
case "skipping":
|
||||
case "skipping", "cancel":
|
||||
mark = "-"
|
||||
markColor = cs.Gray
|
||||
}
|
||||
|
|
@ -49,7 +49,11 @@ func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) {
|
|||
tp.AddField(o.Link)
|
||||
} else {
|
||||
tp.AddField(o.Name)
|
||||
tp.AddField(o.Bucket)
|
||||
if o.Bucket == "cancel" {
|
||||
tp.AddField("fail")
|
||||
} else {
|
||||
tp.AddField(o.Bucket)
|
||||
}
|
||||
if elapsed == "" {
|
||||
tp.AddField("0")
|
||||
} else {
|
||||
|
|
@ -69,12 +73,14 @@ func printSummary(io *iostreams.IOStreams, counts checkCounts) {
|
|||
summary = "Some checks were not successful"
|
||||
} else if counts.Pending > 0 {
|
||||
summary = "Some checks are still pending"
|
||||
} else if counts.Canceled > 0 {
|
||||
summary = "Some checks were cancelled"
|
||||
} else {
|
||||
summary = "All checks were successful"
|
||||
}
|
||||
|
||||
tallies := fmt.Sprintf("%d failing, %d successful, %d skipped, and %d pending checks",
|
||||
counts.Failed, counts.Passed, counts.Skipping, counts.Pending)
|
||||
tallies := fmt.Sprintf("%d cancelled, %d failing, %d successful, %d skipped, and %d pending checks",
|
||||
counts.Canceled, counts.Failed, counts.Passed, counts.Skipping, counts.Pending)
|
||||
|
||||
summary = fmt.Sprintf("%s\n%s", io.ColorScheme().Bold(summary), tallies)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue