Skip to content

Commit 5881f2b

Browse files
stuartmorganfranciscojma86
authored andcommitted
Add Flutter tree min version check (#248)
* Add Flutter tree min version check To minimize confusion, and reduce unnecessary issue reports, add a check during builds that the Flutter tree being used is not older than the last known point where there was a compatibility break. Instead of a runtime error, or an unexplained build error, this will fail out during the engine update step with a clear message to use a newer version of Flutter. Currently, this will ensure that people who aren't on Flutter master will get an error message that's as clear as possible. * Update CI to use sufficiently new versions of Flutter
1 parent 3c37503 commit 5881f2b

File tree

5 files changed

+67
-3
lines changed

5 files changed

+67
-3
lines changed

.appveyor.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ image: Visual Studio 2017
1717
platform: x64
1818

1919
install:
20-
- ps: build\ci\install_flutter.ps1 $env:APPVEYOR_BUILD_FOLDER\..
20+
# None of the packaged channels are new enough for the current state
21+
# of FDE, so for now clone master instead.
22+
#- ps: build\ci\install_flutter.ps1 $env:APPVEYOR_BUILD_FOLDER\..
23+
- git clone -b master https://github.com/flutter/flutter.git %APPVEYOR_BUILD_FOLDER%\..\flutter
2124

2225
build_script:
2326
- msbuild "example\windows_fde\Example Embedder.sln"

build/ci/install_flutter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
set -e
1818

19-
readonly CHANNEL="stable"
20-
readonly VERSION="1.0.0"
19+
readonly CHANNEL="dev"
20+
readonly VERSION="1.1.8"
2121

2222
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
2323
readonly FLUTTER_OS="linux"

tools/dart_tools/bin/update_flutter_engine.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:path/path.dart' as path;
2323
import 'package:archive/archive.dart';
2424

2525
import '../lib/flutter_utils.dart';
26+
import '../lib/git_utils.dart';
2627

2728
/// The filename stored next to a downloaded engine library to indicate its
2829
/// version.
@@ -84,6 +85,9 @@ Future<void> main(List<String> arguments) async {
8485
'is present.\n'
8586
'Defaults to a "flutter" directory next to this repository.',
8687
defaultsTo: getDefaultFlutterRoot())
88+
..addFlag('skip_min_version_check',
89+
help: 'If set, skips the initial check that the Flutter tree whose '
90+
'engine version is being fetched is new enough for the framework.')
8791
..addOption(
8892
'hash',
8993
// Note: engine_override takes precedence over this flag so that
@@ -112,6 +116,22 @@ Future<void> main(List<String> arguments) async {
112116
final String flutterRoot = parsedArguments['flutter_root'];
113117
final outputRoot = path.canonicalize(path.absolute(parsedArguments.rest[0]));
114118

119+
// TODO: Consider making a setup script that should be run after any update,
120+
// which checks/fetches dependencies, and moving this check there. For now,
121+
// do it here since it's a hook that's run on every build.
122+
if (!parsedArguments['skip_min_version_check']) {
123+
bool containsRequiredCommit = await gitHeadContainsCommit(
124+
flutterRoot, lastKnownRequiredFlutterCommit);
125+
if (!containsRequiredCommit) {
126+
print('Flutter engine update aborted: Your Flutter tree is too '
127+
'old for use with this project. Please update to a newer version of '
128+
'Flutter, then try again.\n\n'
129+
'Note that this may require switching to Flutter master. See:\n'
130+
'https://github.com/flutter/flutter/wiki/Flutter-build-release-channels');
131+
exit(1);
132+
}
133+
}
134+
115135
final engineOverrideBuildType = await getEngineOverrideBuildType();
116136
if (engineOverrideBuildType == null) {
117137
final String targetHash =

tools/dart_tools/lib/flutter_utils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import 'dart:io';
1919

2020
import 'package:path/path.dart' as path;
2121

22+
/// The last Flutter hash that's known to be required; a branch that doesn't
23+
/// contain this commit will either fail to build, or fail to run.
24+
///
25+
/// This should be updated whenever a new dependency is introduced (e.g., a
26+
/// required embedder API addition or implementation fix).
27+
const String lastKnownRequiredFlutterCommit =
28+
'390ded9340e529b8475fefd1afdbe59c5b8d4081';
29+
2230
/// Returns the path to the root of this repository.
2331
///
2432
/// Relies on the known location of dart_tools/bin within the repo, and the fact

tools/dart_tools/lib/git_utils.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the 'License');
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an 'AS IS' BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Wrappers for git commands used by the tools.
16+
17+
import 'run_command.dart';
18+
19+
/// Returns true if the current
20+
Future<bool> gitHeadContainsCommit(
21+
String repositoryRoot, String commitHash) async {
22+
final exitCode = await runCommand(
23+
'git',
24+
[
25+
'merge-base',
26+
'--is-ancestor',
27+
commitHash,
28+
'HEAD',
29+
],
30+
workingDirectory: repositoryRoot,
31+
allowFail: true);
32+
return exitCode == 0;
33+
}

0 commit comments

Comments
 (0)