Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and automate bin/dotd. #13722

Merged
merged 16 commits into from Mar 10, 2017
Merged

Improve and automate bin/dotd. #13722

merged 16 commits into from Mar 10, 2017

Conversation

ashercodeorg
Copy link
Contributor

No description provided.

@ashercodeorg
Copy link
Contributor Author

ashercodeorg commented Mar 10, 2017

This PR is a large number of small commits. Feel welcome to review the whole set of changes at once, feel welcome (encouraged) to review commit by commit (mild effort was taken to keep them self-contained and small).

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

All improvements, just have some nits to list.

require_relative '../lib/cdo/github'
include CdoCli

LOG_FILE = "#{Dir.tmpdir}/dotd.log"
LOG_FILE = "#{Dir.tmpdir}/dotd.log".freeze
# TODO(asher): This is not a constant, so should not be NAMED as one.
Copy link
Contributor

Choose a reason for hiding this comment

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

This TODO seems worth addressing within this PR.

bin/dotd Outdated
name

welcome = " Hi #{@dotd_name}! Please follow along carefully, as options "\
"and codepaths are changing often."
Copy link
Contributor

Choose a reason for hiding this comment

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

It drives me crazy when dial-menu systems always say "Please listen carefully, as the menu options have changed" because they usually haven't. I understand the precaution here, but I'm not sure it's worth it - maybe just shorten to "Please follow along carefully."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Removed.

bin/dotd Outdated
"and codepaths are changing often."
puts ''
puts welcome
puts ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not heredoc for this block of text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

bin/dotd Outdated
# @param log_action [Boolean] Whether to log the action to LOGGER. Default is
# true.
# @block The block to run if the user responsds affirmatively.
def should_i(question, log_action: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Right now there's exactly one case where we don't want to log the action (resetting the DTT topic to true). But even that might be useful to see in a log. Maybe simpler and safer to just log every action, even those that seem trivial?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Done.

bin/dotd Outdated
exit(-1)
else
puts "Sorry, I didn't understand that.\n\n"
end
end
end

# Prompts the user to press enter, pausing until any key is pressed.
def press_enter_to_continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment true? I believe you have to press enter for gets to return, although you could certainly enter other text which would get ignored. Otherwise how does ask_for_name work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

bin/dotd Outdated
else
output_text = red "CURRENT DTT SUBTOPIC: #{DevelopersTopic.dtt_subtopic}"
end
puts output_text
Copy link
Contributor

Choose a reason for hiding this comment

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

A few recommendations:

  1. I would flip this around (see example below)
  2. "Subtopic" isn't a super well-known term on the team, maybe use something a little simpler.
  3. I'm not sure the screaming caps are needed, esp. with the red variant when DTT is no.

Proposal:

def print_dtt_subtopic
  msg = "The #developers room says DTT: #{DevelopersTopic.dtt_subtopic}"
  if DevelopersTopic.dtt?
    puts dim msg
  else
    puts red msg
  end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (with s/msg/message).

should_i "DTT" do
view_commits base: 'test', head: 'staging'
should_i "merge from staging to test" do
DevelopersTopic.set_dtt_subtopic "no (@#{@dotd_name} in progress)"
Copy link
Contributor

Choose a reason for hiding this comment

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

For a future PR, probably: Reading this I realize subtopic is mostly redundant since we'll always invoke this on the DevelopersTopic module: DevelopersTopic.set_dtt "no (...)" reads nicely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will follow up. And I'm regretting GitHub.html_url, I'll also change that to GitHub.url.

bin/dotd Outdated
wait_for "DTT (#{url}) to complete, re-run / investigate failures, and "\
"update infra#test topic to commit #{new_sha}"
# TODO(asher): Prompt for whether the DTT was green, update
# Slack#infra-test topic appropriately.
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO now or later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Later, I'd prefer to launch and iterate.

bin/dotd Outdated
base: 'staging', head: 'levelbuilder', title: 'DTS (Levelbuilder > Staging)'
)
new_sha = GitHub.sha 'staging'
new_sha_abbr = new_sha[0, 4] + '...' + new_sha[-4, 4]
Copy link
Contributor

Choose a reason for hiding this comment

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

The git/GitHub convention for abbreviating commit SHAs is new_sha[0, 7] as it's almost always unique - I think that'd be sufficient here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# @param head [String] The head branch of the comparison.
# @param title [String] The title of the candidate pull request.
# @raise [RuntimeError] If the environment is not development.
def self.open_pull_request_in_browser(base:, head:, title:)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This name isn't exactly true, since we're opening the compare page to help create a pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh, it has the caveat "in browser". For now, I'm going to punt.

@ashercodeorg
Copy link
Contributor Author

Though my changes were completely in line with your suggestions (with the exception of ignoring the naming of open_pull_request_in_browser, it may be worth taking another look (post-merge, I want to iterate and not have potential merge conflicts) as I've added String.unindent_with_indent to CdoCli.

@ashercodeorg ashercodeorg merged commit a4dbfe8 into staging Mar 10, 2017
@ashercodeorg ashercodeorg deleted the moreDotd branch March 10, 2017 20:54
@islemaster
Copy link
Contributor

Looks great!

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.

None yet

2 participants