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

feat: update to Flutter to 3.29.2 and Dart to 3.7.2 #1217

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
flutter-version:
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
- "3.24.0"
- "3.29.3"
- "3.x"
test:
# E2E tests for the test command
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spdx_license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: 3.5.0
sdk: 3.7.2

- name: 📦 Install Dependencies
run: dart pub get
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: 3.5.0
sdk: 3.7.2

- name: 📦 Install Dependencies
run: dart pub get
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_optimizer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
build_hooks:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
with:
dart_sdk: 3.5.0
dart_sdk: 3.7.2
working_directory: bricks/test_optimizer/hooks

verify_bundle:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/very_good_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: subosito/[email protected]
with:
flutter-version: 3.24.0
flutter-version: 3.29.3

- name: Install Dependencies
run: flutter pub get
Expand Down
10 changes: 6 additions & 4 deletions bricks/test_optimizer/hooks/lib/pre_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ Future<void> run(HookContext context) async {

final identifierGenerator = DartIdentifierGenerator();
final testIdentifierTable = <Map<String, String>>[];
for (final entity
in testDir.listSync(recursive: true).where((entity) => entity.isTest)) {
final relativePath =
path.relative(entity.path, from: testDir.path).replaceAll(r'\', '/');
for (final entity in testDir
.listSync(recursive: true)
.where((entity) => entity.isTest)) {
final relativePath = path
.relative(entity.path, from: testDir.path)
.replaceAll(r'\', '/');
testIdentifierTable.add({
'path': relativePath,
'identifier': identifierGenerator.next(),
Expand Down
2 changes: 1 addition & 1 deletion bricks/test_optimizer/hooks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: hooks
publish_to: none

environment:
sdk: ^3.5.0
sdk: ^3.7.2

dependencies:
mason: ^0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ void main() {
ids.add(id);
}

expect(
ids.where((id) => _dartReservedKeywords.contains(id)),
isEmpty,
);
expect(ids.where((id) => _dartReservedKeywords.contains(id)), isEmpty);
expect(
ids.every((id) {
final idStart = id.codeUnitAt(0);
final isAlphabetic = (idStart >= 65 && idStart <= 90) ||
final isAlphabetic =
(idStart >= 65 && idStart <= 90) ||
(idStart >= 97 && idStart <= 122);
final isUnderscore = idStart == 95;
final isDollarSign = idStart == 36;
Expand Down
2 changes: 1 addition & 1 deletion e2e/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ^3.5.0
sdk: ^3.7.2

dev_dependencies:
mason: ^0.1.0
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/commands/test/async_main/fixture/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ^3.5.0
sdk: ^3.6.0

dev_dependencies:
test: ^1.24.3
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ^3.5.0
sdk: ^3.7.2

dev_dependencies:
test: ^1.24.3
18 changes: 8 additions & 10 deletions lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ part 'git_cli.dart';
const _asyncRunZoned = runZoned;

/// Type definition for [Process.run].
typedef RunProcess = Future<ProcessResult> Function(
String executable,
List<String> arguments, {
String? workingDirectory,
bool runInShell,
});
typedef RunProcess =
Future<ProcessResult> Function(
String executable,
List<String> arguments, {
String? workingDirectory,
bool runInShell,
});

/// This class facilitates overriding [Process.run].
/// It should be extended by another class in client code with overrides
Expand All @@ -47,10 +48,7 @@ abstract class ProcessOverrides {
}

/// Runs [body] in a fresh [Zone] using the provided overrides.
static R runZoned<R>(
R Function() body, {
RunProcess? runProcess,
}) {
static R runZoned<R>(R Function() body, {RunProcess? runProcess}) {
final overrides = _ProcessOverridesScope(runProcess);
return _asyncRunZoned(body, zoneValues: {_token: overrides});
}
Expand Down
17 changes: 8 additions & 9 deletions lib/src/cli/dart_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ part of 'cli.dart';
/// Dart CLI
class Dart {
/// Determine whether dart is installed.
static Future<bool> installed({
required Logger logger,
}) async {
static Future<bool> installed({required Logger logger}) async {
try {
await _Cmd.run('dart', ['--version'], logger: logger);
return true;
Expand Down Expand Up @@ -79,12 +77,13 @@ class Dart {
}

final processes = _Cmd.runWhere(
run: (entity) => _Cmd.run(
'dart',
['fix', '--apply'],
workingDirectory: entity.parent.path,
logger: logger,
),
run:
(entity) => _Cmd.run(
'dart',
['fix', '--apply'],
workingDirectory: entity.parent.path,
logger: logger,
),
where: (entity) => !ignore.excludes(entity) && _isPubspec(entity),
cwd: cwd,
);
Expand Down
115 changes: 52 additions & 63 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ class _CoverageMetrics {
String? excludeFromCoverage,
) {
final glob = excludeFromCoverage != null ? Glob(excludeFromCoverage) : null;
return records.fold<_CoverageMetrics>(
const _CoverageMetrics._(),
(current, record) {
final found = record.lines?.found ?? 0;
final hit = record.lines?.hit ?? 0;
if (glob != null && record.file != null) {
if (glob.matches(record.file!)) {
return current;
}
return records.fold<_CoverageMetrics>(const _CoverageMetrics._(), (
current,
record,
) {
final found = record.lines?.found ?? 0;
final hit = record.lines?.hit ?? 0;
if (glob != null && record.file != null) {
if (glob.matches(record.file!)) {
return current;
}
return _CoverageMetrics._(
totalFound: current.totalFound + found,
totalHits: current.totalHits + hit,
);
},
);
}
return _CoverageMetrics._(
totalFound: current.totalFound + found,
totalHits: current.totalHits + hit,
);
});
}

final int totalHits;
Expand All @@ -105,22 +105,21 @@ class _CoverageMetrics {

/// Type definition for the [flutterTest] command
/// from 'package:very_good_test_runner`.
typedef FlutterTestRunner = Stream<TestEvent> Function({
List<String>? arguments,
String? workingDirectory,
Map<String, String>? environment,
bool runInShell,
});
typedef FlutterTestRunner =
Stream<TestEvent> Function({
List<String>? arguments,
String? workingDirectory,
Map<String, String>? environment,
bool runInShell,
});

/// A method which returns a [Future<MasonGenerator>] given a [MasonBundle].
typedef GeneratorBuilder = Future<MasonGenerator> Function(MasonBundle);

/// Flutter CLI
class Flutter {
/// Determine whether flutter is installed.
static Future<bool> installed({
required Logger logger,
}) async {
static Future<bool> installed({required Logger logger}) async {
try {
await _Cmd.run('flutter', ['--version'], logger: logger);
return true;
Expand Down Expand Up @@ -210,14 +209,10 @@ class Flutter {
final path =
relativePath == '.' ? '.' : '.${p.context.separator}$relativePath';

stdout?.call(
'Running "flutter test" in $path ...\n',
);
stdout?.call('Running "flutter test" in $path ...\n');

if (!Directory(p.join(target.dir.absolute.path, 'test')).existsSync()) {
stdout?.call(
'No test folder found in $path\n',
);
stdout?.call('No test folder found in $path\n');
return ExitCode.success.code;
}

Expand Down Expand Up @@ -312,22 +307,20 @@ Future<void> _verifyGitDependencies(
final dependencies = pubspec.dependencies;
final devDependencies = pubspec.devDependencies;
final dependencyOverrides = pubspec.dependencyOverrides;
final gitDependencies = [
...dependencies.entries,
...devDependencies.entries,
...dependencyOverrides.entries,
]
.where((entry) => entry.value is GitDependency)
.map((entry) => entry.value)
.cast<GitDependency>()
.toList();
final gitDependencies =
[
...dependencies.entries,
...devDependencies.entries,
...dependencyOverrides.entries,
]
.where((entry) => entry.value is GitDependency)
.map((entry) => entry.value)
.cast<GitDependency>()
.toList();

await Future.wait(
gitDependencies.map(
(dependency) => Git.reachable(
dependency.url,
logger: logger,
),
(dependency) => Git.reachable(dependency.url, logger: logger),
),
);
}
Expand Down Expand Up @@ -376,7 +369,8 @@ Future<int> _flutterTest({
final groups = <int, TestGroup>{};
final tests = <int, Test>{};
final failedTestErrorMessages = <String, List<String>>{};
final sigintWatch = ProcessSignalOverrides.current?.sigintWatch ??
final sigintWatch =
ProcessSignalOverrides.current?.sigintWatch ??
ProcessSignal.sigint.watch();

var successCount = 0;
Expand All @@ -395,13 +389,11 @@ Future<int> _flutterTest({
final timerSubscription = Stream.periodic(
const Duration(seconds: 1),
(computationCount) => computationCount,
).listen(
(tick) {
if (completer.isCompleted) return;
final timeElapsed = Duration(seconds: tick).formatted();
stdout('$clearLine$timeElapsed ...');
},
);
).listen((tick) {
if (completer.isCompleted) return;
final timeElapsed = Duration(seconds: tick).formatted();
stdout('$clearLine$timeElapsed ...');
});

late final StreamSubscription<TestEvent> subscription;
late final StreamSubscription<ProcessSignal> sigintWatchSubscription;
Expand All @@ -415,10 +407,7 @@ Future<int> _flutterTest({

subscription = testRunner(
workingDirectory: cwd,
arguments: [
if (collectCoverage) '--coverage',
...?arguments,
],
arguments: [if (collectCoverage) '--coverage', ...?arguments],
runInShell: true,
).listen(
(event) {
Expand Down Expand Up @@ -506,17 +495,18 @@ Future<int> _flutterTest({
final timeElapsed = Duration(milliseconds: event.time).formatted();
final stats = computeStats();
final truncatedTestName = testName.toSingleLine().truncated(
_lineLength - (timeElapsed.length + stats.length + 2),
);
_lineLength - (timeElapsed.length + stats.length + 2),
);
stdout('''$clearLine$timeElapsed $stats: $truncatedTestName''');
}

if (event is DoneTestEvent) {
final timeElapsed = Duration(milliseconds: event.time).formatted();
final stats = computeStats();
final summary = event.success ?? false
? lightGreen.wrap('All tests passed!')!
: lightRed.wrap('Some tests failed.')!;
final summary =
event.success ?? false
? lightGreen.wrap('All tests passed!')!
: lightRed.wrap('Some tests failed.')!;

stdout('$clearLine${darkGray.wrap(timeElapsed)} $stats: $summary\n');

Expand Down Expand Up @@ -570,9 +560,8 @@ String? _topGroupName(Test test, Map<int, TestGroup> groups) => test.groupIDs
.map((groupID) => groups[groupID]?.name)
.firstWhereOrNull((groupName) => groupName?.isNotEmpty ?? false);

Future<void> _cleanupOptimizerFile(String cwd) async => File(
p.join(cwd, 'test', _testOptimizerFileName),
).delete().ignore();
Future<void> _cleanupOptimizerFile(String cwd) async =>
File(p.join(cwd, 'test', _testOptimizerFileName)).delete().ignore();

final int _lineLength = () {
try {
Expand Down
15 changes: 6 additions & 9 deletions lib/src/cli/git_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ Make sure the remote exists and you have the correct access rights.''';
/// Git CLI
class Git {
/// Determine whether the [remote] is reachable.
static Future<void> reachable(
Uri remote, {
required Logger logger,
}) async {
static Future<void> reachable(Uri remote, {required Logger logger}) async {
try {
await _Cmd.run(
'git',
['ls-remote', '$remote', '--exit-code'],
logger: logger,
);
await _Cmd.run('git', [
'ls-remote',
'$remote',
'--exit-code',
], logger: logger);
} catch (_) {
throw UnreachableGitDependency(remote: remote);
}
Expand Down
Loading
Loading