Merge pull request #4090 from bchadwic/pr-checks
Revised pending and skipped symbols for pr checks / run commands
This commit is contained in:
commit
425bc64859
7 changed files with 74 additions and 21 deletions
|
|
@ -103,6 +103,7 @@ func checksRun(opts *ChecksOptions) error {
|
|||
|
||||
passing := 0
|
||||
failing := 0
|
||||
skipping := 0
|
||||
pending := 0
|
||||
|
||||
type output struct {
|
||||
|
|
@ -131,15 +132,20 @@ func checksRun(opts *ChecksOptions) error {
|
|||
}
|
||||
}
|
||||
switch state {
|
||||
case "SUCCESS", "NEUTRAL", "SKIPPED":
|
||||
case "SUCCESS":
|
||||
passing++
|
||||
case "SKIPPED", "NEUTRAL":
|
||||
mark = "-"
|
||||
markColor = cs.Gray
|
||||
skipping++
|
||||
bucket = "skipping"
|
||||
case "ERROR", "FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED":
|
||||
mark = "X"
|
||||
markColor = cs.Red
|
||||
failing++
|
||||
bucket = "fail"
|
||||
default: // "EXPECTED", "REQUESTED", "WAITING", "QUEUED", "PENDING", "IN_PROGRESS", "STALE"
|
||||
mark = "-"
|
||||
mark = "*"
|
||||
markColor = cs.Yellow
|
||||
pending++
|
||||
bucket = "pending"
|
||||
|
|
@ -209,7 +215,7 @@ func checksRun(opts *ChecksOptions) error {
|
|||
}
|
||||
|
||||
summary := ""
|
||||
if failing+passing+pending > 0 {
|
||||
if failing+passing+skipping+pending > 0 {
|
||||
if failing > 0 {
|
||||
summary = "Some checks were not successful"
|
||||
} else if pending > 0 {
|
||||
|
|
@ -218,9 +224,8 @@ func checksRun(opts *ChecksOptions) error {
|
|||
summary = "All checks were successful"
|
||||
}
|
||||
|
||||
tallies := fmt.Sprintf(
|
||||
"%d failing, %d successful, and %d pending checks",
|
||||
failing, passing, pending)
|
||||
tallies := fmt.Sprintf("%d failing, %d successful, %d skipped, and %d pending checks",
|
||||
failing, passing, skipping, pending)
|
||||
|
||||
summary = fmt.Sprintf("%s\n%s", cs.Bold(summary), tallies)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,25 +90,25 @@ func Test_checksRun(t *testing.T) {
|
|||
{
|
||||
name: "some failing",
|
||||
fixture: "./fixtures/someFailing.json",
|
||||
wantOut: "Some checks were not successful\n1 failing, 1 successful, 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\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",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
name: "some pending",
|
||||
fixture: "./fixtures/somePending.json",
|
||||
wantOut: "Some checks are still pending\n0 failing, 2 successful, 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\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",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
name: "all passing",
|
||||
fixture: "./fixtures/allPassing.json",
|
||||
wantOut: "All checks were successful\n0 failing, 3 successful, 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 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: "",
|
||||
},
|
||||
{
|
||||
name: "with statuses",
|
||||
fixture: "./fixtures/withStatuses.json",
|
||||
wantOut: "Some checks were not successful\n1 failing, 2 successful, 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\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",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
|
|
@ -146,6 +146,12 @@ func Test_checksRun(t *testing.T) {
|
|||
wantOut: "a status\tfail\t0\tsweet link\ncool tests\tpass\t1m26s\tsweet link\nrad tests\tpass\t1m26s\tsweet link\n",
|
||||
wantErr: "SilentError",
|
||||
},
|
||||
{
|
||||
name: "some skipped",
|
||||
fixture: "./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",
|
||||
wantErr: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
42
pkg/cmd/pr/checks/fixtures/someSkipping.json
Normal file
42
pkg/cmd/pr/checks/fixtures/someSkipping.json
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"number": 123,
|
||||
"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": "SKIPPED",
|
||||
"status": "COMPLETED",
|
||||
"name": "rad tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
},
|
||||
{
|
||||
"conclusion": "SKIPPED",
|
||||
"status": "COMPLETED",
|
||||
"name": "skip tests",
|
||||
"completedAt": "2020-08-27T19:00:12Z",
|
||||
"startedAt": "2020-08-27T18:58:46Z",
|
||||
"detailsUrl": "sweet link"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -304,13 +304,13 @@ func Symbol(cs *iostreams.ColorScheme, status Status, conclusion Conclusion) (st
|
|||
case Success:
|
||||
return cs.SuccessIconWithColor(noColor), cs.Green
|
||||
case Skipped, Cancelled, Neutral:
|
||||
return cs.SuccessIconWithColor(noColor), cs.Gray
|
||||
return "-", cs.Gray
|
||||
default:
|
||||
return cs.FailureIconWithColor(noColor), cs.Red
|
||||
}
|
||||
}
|
||||
|
||||
return "-", cs.Yellow
|
||||
return "*", cs.Yellow
|
||||
}
|
||||
|
||||
func PullRequestForRun(client *api.Client, repo ghrepo.Interface, run Run) (int, error) {
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ func TestWatchRun(t *testing.T) {
|
|||
askStubs: func(as *prompt.AskStubber) {
|
||||
as.StubOne(1)
|
||||
},
|
||||
wantOut: "\x1b[2J\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n- trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n✓ trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\n✓ Run more runs (2) completed with 'success'\n",
|
||||
wantOut: "\x1b[2J\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n* trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n✓ trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\n✓ Run more runs (2) completed with 'success'\n",
|
||||
},
|
||||
{
|
||||
name: "interval respected, windows",
|
||||
|
|
@ -249,7 +249,7 @@ func TestWatchRun(t *testing.T) {
|
|||
askStubs: func(as *prompt.AskStubber) {
|
||||
as.StubOne(1)
|
||||
},
|
||||
wantOut: "\x1b[2J\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n- trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n✓ trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n",
|
||||
wantOut: "\x1b[2J\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n* trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n✓ trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n",
|
||||
},
|
||||
{
|
||||
name: "exit status respected",
|
||||
|
|
@ -264,7 +264,7 @@ func TestWatchRun(t *testing.T) {
|
|||
askStubs: func(as *prompt.AskStubber) {
|
||||
as.StubOne(1)
|
||||
},
|
||||
wantOut: "\x1b[2J\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n- trunk more runs · 2\nTriggered via push about 59 minutes ago\n\n\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\nX trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\nX sad job in 4m34s (ID 20)\n ✓ barf the quux\n X quux the barf\n\nANNOTATIONS\nX the job is sad\nsad job: blaze.py#420\n\n\nX Run more runs (2) completed with 'failure'\n",
|
||||
wantOut: "\x1b[2J\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n* trunk more runs · 2\nTriggered via push about 59 minutes ago\n\n\x1b[0;0H\x1b[JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\nX trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\nX sad job in 4m34s (ID 20)\n ✓ barf the quux\n X quux the barf\n\nANNOTATIONS\nX the job is sad\nsad job: blaze.py#420\n\n\nX Run more runs (2) completed with 'failure'\n",
|
||||
wantErr: true,
|
||||
errMsg: "SilentError",
|
||||
},
|
||||
|
|
@ -280,7 +280,7 @@ func TestWatchRun(t *testing.T) {
|
|||
askStubs: func(as *prompt.AskStubber) {
|
||||
as.StubOne(1)
|
||||
},
|
||||
wantOut: "\x1b[2J\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n- trunk more runs · 2\nTriggered via push about 59 minutes ago\n\n\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\nX trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\nX sad job in 4m34s (ID 20)\n ✓ barf the quux\n X quux the barf\n\nANNOTATIONS\nX the job is sad\nsad job: blaze.py#420\n\n",
|
||||
wantOut: "\x1b[2J\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\n* trunk more runs · 2\nTriggered via push about 59 minutes ago\n\n\x1b[2JRefreshing run status every 0 seconds. Press Ctrl+C to quit.\n\nX trunk more runs · 2\nTriggered via push about 59 minutes ago\n\nJOBS\nX sad job in 4m34s (ID 20)\n ✓ barf the quux\n X quux the barf\n\nANNOTATIONS\nX the job is sad\nsad job: blaze.py#420\n\n",
|
||||
wantErr: true,
|
||||
errMsg: "SilentError",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -177,9 +177,9 @@ func TestViewRun(t *testing.T) {
|
|||
Total runs 10
|
||||
Recent runs
|
||||
X cool commit timed out trunk push 1
|
||||
- cool commit in progress trunk push 2
|
||||
* cool commit in progress trunk push 2
|
||||
✓ cool commit successful trunk push 3
|
||||
✓ cool commit cancelled trunk push 4
|
||||
- cool commit cancelled trunk push 4
|
||||
|
||||
To see more runs for this workflow, try: gh run list --workflow flow.yml
|
||||
To see the YAML for this workflow, try: gh workflow view flow.yml --yaml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue