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

Skip to content

Conversation

@cdb
Copy link
Contributor

@cdb cdb commented Mar 3, 2022

This PR implements 2 new flags to the gh run rerun workflow, to support the upcoming work to allow running only the failed jobs from a GitHub Actions workflow run (--failed) and a specific job from a workflow (--job <job-id>).

The endpoints referenced here are NOT yet released publicly, so this PR should not be merged yet, but hopefully can merge shortly after we launch.

Our internal issue tracking this is https://github.com/github/cli/issues/110, let me know if I should create one in this repo as well.

Also first time contributing here so open to any and all feedback, thanks in advance!! 🙇

@cdb cdb requested a review from a team as a code owner March 3, 2022 19:56
@cdb cdb requested review from mislav and removed request for a team March 3, 2022 19:56
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Mar 3, 2022
@vilmibm vilmibm self-requested a review March 4, 2022 23:26
@vilmibm vilmibm self-assigned this Mar 4, 2022
Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

thanks for this!

i tested the argument processing stuff and it seems good 👍 I would like to QA this again once the feature flag is flipped and before we release on Tuesday.

@cdb
Copy link
Contributor Author

cdb commented Mar 10, 2022

@vilmibm - if you use it against github staff repos, you can QA it now as it is staff shipped, or I can flag in any additional repos, just message me

@vilmibm
Copy link
Contributor

vilmibm commented Mar 10, 2022

oh sick--can you add vilmibm/testing?

@cdb
Copy link
Contributor Author

cdb commented Mar 11, 2022

@vilmibm Done!

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! Housekeeping items remain

if err != nil {
return err
}
if opts.IO.CanPrompt() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize it was like this before the feature additions, but if we could make just a bit of housekeeping while we're here, I would suggest replacing these CanPrompt() guards with IsStdoutTTY(). The reason is that we're not checking for whether the command can prompt the user, but whether the output is going to a terminal and not, for example, as part of a script. These checks are often aligned but not always.

opts.RunID = ""
if opts.IO.CanPrompt() {
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s both run and job IDs specified; ignoring run ID\n", cs.WarningIcon())
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of ignoring a piece of input, should we error out in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I'll return cmdutil.FlagErrorf instead.

I took the pattern from

if opts.RunID != "" && opts.JobID != "" {
opts.RunID = ""
if opts.IO.CanPrompt() {
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s both run and job IDs specified; ignoring run ID\n", cs.WarningIcon())
}
- would you suggest I update it there as well? That might break a user's workflow if they've relied on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of backwards compatibility, let's not change where it was allowed before

if err != nil {
return err
}
if opts.IO.CanPrompt() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto CanPrompt → IsStdoutTTY

cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s both run and job IDs specified; ignoring run ID\n", cs.WarningIcon())
}
return cmdutil.FlagErrorf("specify only one of <run-id> or <job-id>")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: since <job-id> is not a placeholder anywhere, it can be confusing to see this. When we're referring to flags, we usually name them by their full usage: --job (in backticks)

@vilmibm vilmibm merged commit 1c26019 into cli:trunk Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants