-
Notifications
You must be signed in to change notification settings - Fork 374
check: Update the flutter_version check to follow upstream #2002
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
base: main
Are you sure you want to change the base?
check: Update the flutter_version check to follow upstream #2002
Conversation
|
Hmm CI is failing, could you take a look? |
5f5471e to
fd5eb30
Compare
|
Hmm looks like CI is failing again. |
See:
https://github.com/actions/checkout/blob/8e8c483db/action.yml#L74-L76
Without this change, the main branch is not fetched when the
current branch is non-main. We need this because soon we will run
the `flutter_version` suite in CI only when there are changes in
`pubspec.yaml` or `tools/check` files. For that, we need the `main`
branch to be able to calculate the file diff.
Otherwise the suite will fail when calling `git_base_commit` saying:
fatal: Not a valid object name refs/remotes/origin/main
Flutter's new versioning depends on the latest tag pushed upstream. And we are going to add the check for Flutter version string back soon. To avoid frequent CI failures that may be caused by a new tag being pushed upstream, run the flutter_version check in CI only when there are changes in the `pubspec.yaml` or `tools/check` files.
Since flutter/flutter@e45fd36aa the flutter tool now uses a combination of git commands, instead of using the result of `git describe` to generate the version string. So, we update the check to use the same commands here, and then do some transformations to match the string from the flutter tool: https://github.com/flutter/flutter/blob/9f383e099/packages/flutter_tools/lib/src/version.dart#L1162 Fixes: zulip#1851
fd5eb30 to
5389e66
Compare
|
@chrisbobbe This PR is ready for review now, PTAL. |
|
Thanks! I think it'll be more efficient if I just pass this to Greg for review, I hope that's OK. 🙂 |
gnprice
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rajveermalviya for taking care of this! Comments below.
| default_suites=( | ||
| analyze test | ||
| flutter_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should get added to extra_suites below, so that the --help output remains accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could make other changes to the API, too. Whatever we do, we should keep the documentation in --help accurate, though.
| - name: Run tools/check (all default suites) | ||
| run: TERM=dumb tools/check --all --verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… Also if you want "all default suites", rather than "all suites", that is spelled --all-files.
| # Omitted from this files check: | ||
| # tools/check | ||
| files_check pubspec.yaml \ | ||
| files_check pubspec.yaml tools/check \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Keep this "Omitted from …" comment, but just update it — that way it's explicit that we've thought this through and believe there are no files being omitted. E.g. like this:
# Omitted from this files check:
# (none known!)See the doc comment on files_check:
# Do, though, write down in a comment the known types of changes that could affect
# the outcome and are being left out. That's helpful when either revising which
# changes we choose to omit, or debugging inadvertent omissions, by separating
# the two from each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also, why does this start making this suite run when tools/check changes? See the files_check doc comment:
# In particular, omit pubspec.yaml, pubspec.lock, and tools/check itself,
# except where the suite is specifically aimed at those files.
The flutter_version suite is all about what appears in pubspec.yaml, which is why it's an exception in that respect. But I don't see how it's about tools/check, any more specifically than all the other suites are.
| if [ -z "${predicted_version}" ]; then | ||
| return 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the case where this condition would happen?
If predict_flutter_version returns prematurely, that should be propagated by the || return on the previous line, right? So I think we should only get here if predicted_version really is the string that predict_flutter_version predicted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick demo that confirms my expectation of the behavior of that || return:
$ ( f(){ local a; a=$( echo 3; false ) || return; echo continued; declare -p a; }; f )
$
The function didn't proceed past the || return, because the command inside the $( … ) returned failure.
Compare if I replace "false" by "true":
$ ( f(){ local a; a=$( echo 3; true ) || return; echo continued; declare -p a; }; f )
continued
declare -- a="3"
where the output shows the function proceeded past || return.
| ) || return | ||
| if [ -z "${latest_tag}" ]; then | ||
| echo >&2 "error: Failed to determine the latest tag" | ||
| return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here and a few more spots below: what's the scenario where these -z conditions are expected to happen?
| # If we find cases where it fails, we can study | ||
| # how the `flutter` tool actually decides the version name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, now you have in fact studied that, right? So this comment seems a bit out of place 🙂
|
|
||
| local flutter_tree flutter_git | ||
| flutter_tree=$(flutter_tree) | ||
| flutter_git=( git --git-dir="${flutter_tree}"/.git ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've mentioned to me how it'd be better to use -C instead of --git-dir here, and in other places it appears in our scripts.
(The difference doesn't matter for these particular Git commands; but if it did matter, then --git-dir would produce very confusing results, unless we had a very specific reason to use it instead of -C. So it's best to use the pattern that consistently has more natural results.)
That'd be good to do as a quick commit of its own either before or after, while we're still thinking of it.
| error: Flutter commit in pubspec.yaml seems to differ from version bound | ||
| Commit ${flutter_commit} | ||
| We therefore expect the Flutter version name to be: ${predicted_version} | ||
| But the Flutter version bound in pubspec.yaml is: ${flutter_version} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wording doesn't make a ton of sense to me. Why "therefore" — how does the commit ID explain why we expect that Flutter version name?
The old code this appears to be copied from said:
error: Flutter commit in pubspec.yaml seems to differ from version bound
Commit ${flutter_commit} was described as: ${commit_described}
We therefore expect the Flutter version name to be: ${predicted_version}
But the Flutter version bound in pubspec.yaml is: ${flutter_version}
so the commit_described value explains how we came to the particular predicted_version value.
That detail was there basically for debugging — if the test fails, it gives you a start on working out why. But that isn't critical. It's fine not to have any more information than this version does, since it's probably annoying to wire up more information to print here; we can always add more detail if we find we need it. We should just adapt the wording so it continues to make sense.
Stacked on top of #2009
Since flutter/flutter@e45fd36aa the flutter tool now uses a combination of git commands, instead of using the result of
git describeto generate the version string.So, we update the check to use the same commands here, and then do some transformations to match the string from the flutter tool:
https://github.com/flutter/flutter/blob/9f383e099/packages/flutter_tools/lib/src/version.dart#L1162
Fixes: #1851