Skip to content

Commit

Permalink
Fix SDK selection and upgrade Flutter SDK (dart-lang#7507)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Feb 26, 2024
1 parent b871f58 commit 503ef4f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Important changes to data models, configuration, and migrations between each
AppEngine version, listed here to ease deployment and troubleshooting.

## Next Release (replace with git tag when deployed)
* Bumped runtimeVersion to `2024.02.26`.
* Upgraded stable Flutter analysis SDK to `3.19.1`.
* Note: Analysis SDK directories with separate config homes.

## `20240223t113900-all`
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN XDG_CONFIG_HOME=/home/worker/config/dart-stable tool/setup-dart.sh /home/wor
RUN XDG_CONFIG_HOME=/home/worker/config/dart-preview tool/setup-dart.sh /home/worker/dart/preview 3.4.0-131.0.dev

# Setup Flutter SDK into /home/worker/flutter/{stable,preview}/
RUN XDG_CONFIG_HOME=/home/worker/config/flutter-stable tool/setup-flutter.sh /home/worker/flutter/stable 3.19.0
RUN XDG_CONFIG_HOME=/home/worker/config/flutter-stable tool/setup-flutter.sh /home/worker/flutter/stable 3.19.1
RUN XDG_CONFIG_HOME=/home/worker/config/flutter-preview tool/setup-flutter.sh /home/worker/flutter/preview 3.20.0-1.1.pre

# Setup webp
Expand Down
6 changes: 3 additions & 3 deletions app/lib/shared/versions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ final RegExp runtimeVersionPattern = RegExp(r'^\d{4}\.\d{2}\.\d{2}$');
/// when the version switch happens.
const _acceptedRuntimeVersions = <String>[
// The current [runtimeVersion].
'2024.02.21',
'2024.02.26',
// Fallback runtime versions.
'2024.02.21',
'2024.02.16',
'2024.02.13',
];

/// Sets the current runtime versions.
Expand Down Expand Up @@ -63,7 +63,7 @@ bool shouldGCVersion(String version) =>
// keep in-sync with SDK version in .mono_repo.yml and Dockerfile
final String runtimeSdkVersion = '3.3.0';
final String toolStableDartSdkVersion = '3.3.0';
final String toolStableFlutterSdkVersion = '3.19.0';
final String toolStableFlutterSdkVersion = '3.19.1';
final String toolPreviewDartSdkVersion = '3.4.0-131.0.dev';
final String toolPreviewFlutterSdkVersion = '3.20.0-1.1.pre';

Expand Down
16 changes: 7 additions & 9 deletions pkg/pub_worker/lib/src/bin/pana_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import 'package:collection/collection.dart';
import 'package:logging/logging.dart' show Logger, Level, LogRecord;
import 'package:pana/pana.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:pub_worker/src/bin/dartdoc_wrapper.dart';
import 'package:pub_worker/src/fetch_pubspec.dart';
import 'package:pub_worker/src/sdks.dart';
import 'package:pub_worker/src/utils.dart';

final _log = Logger('pana');

Expand Down Expand Up @@ -178,8 +178,12 @@ Future<(SdkConfig, SdkConfig)> _detectSdks(Pubspec pubspec) async {
flutterSdks.firstWhereOrNull((sdk) => !sdk.version.isPreRelease) ??
(flutterSdks.isNotEmpty ? flutterSdks.first : null);

final needsNewer = _needsNewer(dartSdk?.version, pubspec.dartSdkConstraint) ||
_needsNewer(flutterSdk?.version, pubspec.flutterSdkConstraint);
final needsNewer = needsNewerSdk(
sdkVersion: dartSdk?.version,
constraint: pubspec.dartSdkConstraint) ||
needsNewerSdk(
sdkVersion: flutterSdk?.version,
constraint: pubspec.flutterSdkConstraint);

String configKind = 'stable';
if (needsNewer) {
Expand All @@ -202,9 +206,3 @@ Future<(SdkConfig, SdkConfig)> _detectSdks(Pubspec pubspec) async {
),
);
}

bool _needsNewer(Version? version, VersionConstraint? constraint) {
return version != null &&
constraint != null &&
!constraint.intersect(version).isEmpty;
}
11 changes: 11 additions & 0 deletions pkg/pub_worker/lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:typed_data' show Uint8List, BytesBuilder;

import 'package:pub_semver/pub_semver.dart';

/// Convert chunked [stream] to [Uint8List].
Future<Uint8List> streamToBuffer(Stream<List<int>> stream) async {
final b = BytesBuilder();
Expand All @@ -16,3 +18,12 @@ String stripTrailingSlashes(String u) {
}
return u;
}

bool needsNewerSdk({
required Version? sdkVersion,
required VersionConstraint? constraint,
}) {
return sdkVersion != null &&
constraint != null &&
constraint.intersect(sdkVersion).isEmpty;
}
4 changes: 4 additions & 0 deletions pkg/pub_worker/test/dockerized_end2end_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ void main() {
.contains("Issue tracker URL doesn't exist.")) {
expectedDrop += 10;
}
if (failingReportSections
.contains("is deprecated and shouldn't be used")) {
expectedDrop += 10;
}
expect(
report.grantedPoints,
greaterThanOrEqualTo(report.maxPoints - expectedDrop),
Expand Down
33 changes: 33 additions & 0 deletions pkg/pub_worker/test/utils_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:pub_semver/pub_semver.dart';
import 'package:pub_worker/src/utils.dart';
import 'package:test/test.dart';

Expand All @@ -18,4 +19,36 @@ void main() {
expect(stripTrailingSlashes('test/'), 'test');
expect(stripTrailingSlashes('test//'), 'test');
});

test('needs newer SDK', () {
expect(
needsNewerSdk(sdkVersion: null, constraint: null),
false,
);

expect(
needsNewerSdk(
sdkVersion: null, constraint: VersionConstraint.parse('^3.0.0')),
false,
);

expect(
needsNewerSdk(sdkVersion: Version.parse('3.0.0'), constraint: null),
false,
);

expect(
needsNewerSdk(
sdkVersion: Version.parse('3.0.0'),
constraint: VersionConstraint.parse('^3.0.0')),
false,
);

expect(
needsNewerSdk(
sdkVersion: Version.parse('3.0.0'),
constraint: VersionConstraint.parse('^3.0.1')),
true,
);
});
}

0 comments on commit 503ef4f

Please sign in to comment.