Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix and update version checks #3792

Merged
merged 6 commits into from
Apr 8, 2021

Conversation

stuartmorgan
Copy link
Contributor

Currently our version update checks aren't actually working; the script doesn't work correctly if no explicit --base-sha is passed, but that's always how CI is calling it.

Fixes flutter/flutter#79823 (and version checks in general)

This makes a number of changes:

  • Fixes it to work without --base-sha
  • Adds tests that it works in that mode
    • And tightens existing tests to require ToolExit, not just any error, to reduce false-positive test success
  • Adds verbose logging of the checks being done, to make it easier to debug this kind of issue in the future
  • Tightens the exception handling for missing previous versions to just the line that's expected to fail in that case
  • Only allows missing versions when "publish_to: none" is set
    • Adds that everywhere it's missing
    • Standardize the format in the repo to "none" (instead of also having "'none'").
  • Allows the use of NEXT in CHANGELOG as a way of gathering changes that are worth noting, but not
    doing a publish cycle for. (Replaces the plan of using -dev versions, since that's actually harder to implement,
    and more confusing.)
    • Ensures that we don't forget to clean up NEXT entries when bumping versions

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan
Copy link
Contributor Author

I imagine that now that this works, we'll run into things we need to relax or tweak over time, but getting it actually working is a good first step to getting it working the way we want :)

}
final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
if (pubspec.publishTo == 'none') {
print(' Found "publish_to: none"; skipping.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the indentation intended? I imagine you wanted the output look more organized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is instead of doing the ---------- between each section like the CHANGELOG check; it's more compact, and I think it's more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use an indentation variable to make it clearer and ensure consistency.

} on io.ProcessException {
print('Unable to find pubspec in master for $pubspecPath.'
' Safe to ignore if the project is new.');
print(' Unable to find pubspec in master. '
Copy link
Contributor

Choose a reason for hiding this comment

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

Now looking at this code again. I think we should handle it in getPackageVersion. Then getPackageVersion would just return null if a version is not available. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that makes way more sense; the type of exception here is entirely dependent on the implementation details of that method, which is odd. Fixed.

script/tool/lib/src/common.dart Show resolved Hide resolved

// Skip validation for the special NEXT version that's used to accumulate
// changes that don't warrant publishing on their own.
if (versionString == 'NEXT') {
Copy link
Contributor

Choose a reason for hiding this comment

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

We also need to make sure that the version in pubspec equals to the next version after NEXT in CHANGELOG.

This is to prevent someone updated the version in pubspec but forgot to change the "NEXT"

Copy link
Contributor

Choose a reason for hiding this comment

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

If we only cares about presubmit, which looks like so in the current code (base-sha not configurable), we can easily do

if (versionString == 'NEXT' && pubspecVersion not changed) 

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 call, added validation for that and added a test.

// CHANGELOG. That means the next version entry in the CHANGELOG pass the
// normal validation.
while (iterator.moveNext()) {
if (iterator.current.trim().startsWith('## ')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

some of our CHANGELOG.md files do no follow the standard format, see: https://github.com/flutter/plugins/blob/master/packages/url_launcher/url_launcher_web/CHANGELOG.md

This would fail. :(

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'm fine with a model where trying to use NEXT won't work until the format has been fixed to follow our standard format.

We can also do a one-time sweep if that becomes annoying.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Looks good to me, but there's a small typo that slipped through?

Co-authored-by: David Iglesias <[email protected]>
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

format CI check is taking issue, a pass of dartfmt -w . should fix it!

@stuartmorgan stuartmorgan merged commit 89ccc0e into flutter:master Apr 8, 2021
@stuartmorgan stuartmorgan deleted the version-check-additions branch April 8, 2021 20:22
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 8, 2021
fluttergithubbot pushed a commit to flutter/flutter that referenced this pull request Apr 8, 2021
bhaveshptl pushed a commit to bhaveshptl/plugins that referenced this pull request Apr 23, 2021
* master: (397 commits)
  [in_app_purchase] Implementation of platform interface (flutter#3781)
  [google_sign_in] Add todo WRT correctly setting X-Goog-AuthUser header (flutter#3819)
  [tools] fix version check command not working for new packages (flutter#3818)
  [camera] android-rework part 1: Base classes to support Android Camera features (flutter#3795)
  fix MD (flutter#3815)
  Path provider windows crash fix (flutter#3814)
  [local_auth] docs update (flutter#3103)
  Update PULL_REQUEST_TEMPLATE.md (flutter#3801)
  [quick_actions] handle cold start on iOS correctly (flutter#3811)
  Replace path_provider_linux widget tests with simple unit tests (flutter#3812)
  [sensors] format dart code based on the new dart formatter (flutter#3809)
  [google_sign_in] Fix "pick account" on iOS (flutter#3805)
  [image_picker_platform_interface] Added pickMultiImage (flutter#3782)
  [in_app_purchase] Added currency code and numerical price to product detail model. (flutter#3794)
  [local_auth] Fix iOS crash when no localizedReason (flutter#3780)
  Fix and update version checks (flutter#3792)
  [in_app_purchase] Configured example app to use StoreKit Testing on iOS 14 (flutter#3772)
  [local_auth] Unnecessary reassignment in example removed (flutter#2983)
  [flutter_webview] Fix `allowsInlineMediaPlayback` ignored on iOS (flutter#3791)
  Switch script/tools over to the new analysis options (flutter#3777)
  ...
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
Currently our version update checks aren't actually working; the script doesn't work correctly if no explicit --base-sha is passed, but that's always how CI is calling it.

Fixes flutter/flutter#79823 (and version checks in general)

This makes a number of changes:
- Fixes it to work without --base-sha
- Adds tests that it works in that mode
  - And tightens existing tests to require ToolExit, not just any error, to reduce false-positive test success
- Adds verbose logging of the checks being done, to make it easier to debug this kind of issue in the future
- Tightens the exception handling for missing previous versions to just the line that's expected to fail in that case
- Only allows missing versions when "publish_to: none" is set
  - Adds that everywhere it's missing
  - Standardize the format in the repo to "none" (instead of also having "'none'").
- Allows the use of NEXT in CHANGELOG as a way of gathering changes that are worth noting, but not
  doing a publish cycle for. (Replaces the plan of using -dev versions, since that's actually harder to implement,
  and more confusing.)
  - Ensures that we don't forget to clean up NEXT entries when bumping versions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.