Skip to content

[flutter_conductor] update dev/tools with release tool#69791

Merged
fluttergithubbot merged 9 commits intoflutter:masterfrom
chris-forks:conductor-squash
Nov 6, 2020
Merged

[flutter_conductor] update dev/tools with release tool#69791
fluttergithubbot merged 9 commits intoflutter:masterfrom
chris-forks:conductor-squash

Conversation

@christopherfujino
Copy link
Contributor

NOTE: this is a squashed version of #65968 to fix a version issue. See that PR commit history.

Description

This is a re-write of the roll_dev.dart script as a full CLI tool complete with integration tests. At this point, the behavior should be exactly the same as roll_dev.dart. I am putting out a PR at this point so that the actual tool behavior improvements can be reviewed independent of this code re-organization.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Nov 4, 2020
@google-cla google-cla bot added the cla: yes label Nov 4, 2020
@christopherfujino christopherfujino added tool Affects the "flutter" command-line tool. See also t: labels. and removed cla: yes labels Nov 4, 2020
@google-cla google-cla bot added the cla: yes label Nov 4, 2020
@christopherfujino
Copy link
Contributor Author

@jonahwilliams sorry that this is such a big diff. the behavior should be identical to the roll_dev script. I generalized a lot of the components into classes, especially Repository so that we can finally run integration tests of the release (and upgrade) flow.

Once this lands, the next step will be supporting interactive mode, and supporting applying cherry picks to releases.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

Haven't read through the changes to the existing roll dev script yet

@@ -0,0 +1,20 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

uber-nit: constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the function stdoutToString here, is that cool?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

I just have an irrational fear of globals


/// Lazily-loaded directory for the repository checkout.
///
/// Cloning a repository is time-consuming, thus the actual repository is not
Copy link
Contributor

Choose a reason for hiding this comment

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

ensured to exist -> cloned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, if you pass useExistingCheckout = true, it will not necessarily clone every time. Later, when the conductor runs in interactive mode, subsequent commands will operate on the same local repo.

That having been said, I agree "ensured to exist" is confusing. I'll think of a better way to word it.

Copy link
Contributor

Choose a reason for hiding this comment

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

"cloned if it does not already exist"?

/// Cloning a repository is time-consuming, thus the actual repository is not
/// ensured to exist until this getter is called.
Directory get checkoutDirectory {
if (_checkoutDirectory == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you could un-nest this with an early return:

if (_checkoutDirectory != null) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think rubocop (ruby's linter) favors as few returns as possible, but I agree with your comment that as few indents as possible is favorable.

latest,
}

class Version {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class could benefit from some docs or links to the existing version format docs

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

factory Version.fromString(String versionString) {
assert(versionString != null);

final RegExp stablePattern = RegExp(r'^(\d+)\.(\d+)\.(\d+)$');
Copy link
Contributor

Choose a reason for hiding this comment

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

especially these

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

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

roll dev was the only existing functionality, correct?

final ProcessResult result = _run(args, workingDirectory);
if ((result.stderr as String).isEmpty && result.exitCode == 0)
return (result.stdout as String).trim();
_reportFailureAndExit(args, workingDirectory, result, explanation);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note, once this is opted into null safety you can give _reportFailureAndExit a return type of Never and then there will be no analyzer warning

@required String workingDirectory,
}) {
final ProcessResult result = _run(args, workingDirectory);
if ((result.stderr as String).isEmpty && result.exitCode == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

sometimes stderr is output without it implying a non-zero exit. Could be a diagnostic message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, as I should know (this was legacy code fwiw :P )

List<String> args,
String explanation, {
@required String workingDirectory,
}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere, I would separate the cast from the method invocation. maybe a little helper method like:

String decode(dynamic value) => (value as String).trim();

but with a better name 😭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that. Is your concern line numbers in the stack trace, or is there a higher level code quality concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

Its a bit awkward to read with the cast inline. Another approach would be to use toString() instead since that is defined on Object/dynamic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

implemented String stdoutToString(dynamic input)

@christopherfujino
Copy link
Contributor Author

roll dev was the only existing functionality, correct?

correct

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 7724376 into flutter:master Nov 6, 2020
@christopherfujino christopherfujino deleted the conductor-squash branch November 6, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants