Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Aug 21, 2020

This PR adds a basic first version of gh pr checks. It accepts no flags and its only positional argument is a PR selector; otherwise, the current PR is used.

Considerations:

  • the unicode bullet originally used in the mockups caused formatting glitches; it was not printed as a full width character. I wasn't able to find a suitable replacement and used . for now. switched to - as per ampinsk's suggestion
  • I added the detail of the check URL; this makes it very quick to debug a failing check but might be too much visual clutter
  • A common usecase is likely going to be watching these checks. Right now running this command with watch (watch gh pr checks) means that the output is formatted for machines and not people. I'd like a workaround for this; either a --watch parameter we provide ourselves, a --color parameter that overrides the tty detection, or something else.

TTY output

image

non TTY output

image

Ref. #1525

@vilmibm vilmibm marked this pull request as ready for review August 25, 2020 16:33
@vilmibm vilmibm requested review from ampinsk and mislav August 25, 2020 16:40
@vilmibm vilmibm changed the title WIP pr checks gh pr checks Aug 25, 2020
@ampinsk
Copy link
Contributor

ampinsk commented Aug 25, 2020

the unicode bullet originally used in the mockups caused formatting glitches; it was not printed as a full width character. I wasn't able to find a suitable replacement and used . for now.

Let's use - for this!

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I have some questions for whether they were planned to be rolled up in the same PR:

  • In pr status, we display the summary of both Checks and Statuses, since the PR Merge Box in the web interface displays the summary of both. This change set only seems to aggregate Checks; was support for Statuses planned as part of the same iteration?

  • Should we attempt to order the list of Checks the same way the web interface does? I'm guessing the rough algorithm is: first failing, then pending, and alphabetical order for anything in-between.

  • When a repository (like ours) has both push and pull_request actions, each resulting run is rendered twice. For example, I see build (ubuntu-latest) reported twice, but there is no indicator which one is push and which one is pull_request like in the web interface. Do we have enough information from the API to disambiguate this?

Ref. #1529

@vilmibm
Copy link
Contributor Author

vilmibm commented Aug 26, 2020

wow TIL that statuses and checks are two different things. That clarifies some things. 🤦 🤦 🤦 🤦 🤦

I'll work on including those, changing the ordering, and exposing the push/pullrequest thing (if it's possible thru the api)

A basic first pass on gh pr checks that shows all check runs for a given
PR's latest commit.
@vilmibm
Copy link
Contributor Author

vilmibm commented Aug 28, 2020

okay, this is ready for re-review @mislav .

I:

  • sort by status then lexicographically (failed, pending, success)
  • included statuses by switching to the rollup API
  • determined that there wasn't a way to pull the push vs. pull_request event type out of the API

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work; thank you! A few notes, but all things that can potentially be addressed as follow-up, so nothing blocking. 🚀

nodes {
commit {
oid
statusCheckRollup {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My slight concern with expanding the PullRequestByNumber is that the Checks+Statuses data is unnecessarily fetched every time a user does any operation on a pull request, such as gh pr view 123 --web. However, I do understand that this approach is the most feasible to implement, since any other course of action would require us to either duplicate the logic of shared.PRFromArgs() to fetch extra fields, or to come up with a shippable solution to #1081. I'm only bringing this up as a note that this is a good candidate to revisit in a few weeks 👍

tp.AddField(o.mark, nil, nil)
tp.AddField(o.name, nil, nil)
tp.AddField(o.elapsed, nil, nil)
tp.AddField(o.link, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is tricky! We render the URL in this column, but the way I designed TablePrinter is to automatically truncate long columns in narrow terminals. That means that the URL column will be the first one put up on the chopping block, and URLs become completely useless after they are truncated.

A good followup candidate would be to add a feature to TablePrinter to mark some columns as exempt from elastic resizing/truncation.

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 2, 2020

this is merge-able but going to wait to merge since there is already a ton going into the next release.

@tierninho
Copy link
Contributor

It accepts no flags

gh pr checks -R tierninho/blah
argument required when using the --repo flag

Was the -R flag supposed to be excluded as well as the error message might confuse the user.

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 2, 2020

@tierninho you found a bug D: I'll fix that; -R should work here.

@mislav
Copy link
Contributor

mislav commented Sep 3, 2020

@vilmibm I'm thinking that the current -R error is in order: #1585

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 3, 2020

ahhh right, thanks for the reminder.

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 3, 2020

@tierninho I merged in trunk to get the fix for that -R problem.

@tierninho
Copy link
Contributor

If checks are at a repo level, should we prevent this cmd as it implies branches can be queried?

gh pr checks sdsdf
no open pull requests found for branch "sdsdf"

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 4, 2020

it's at the pr level. the R flag is for looking up a PR via argument in another repo.

@vilmibm vilmibm merged commit ab2c38e into trunk Sep 8, 2020
@mislav mislav deleted the checks branch September 9, 2020 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants