Skip to content

Commit

Permalink
🔨 Add SDK satisfaction check
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Nov 2, 2023
1 parent 690c553 commit 755974c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
6 changes: 4 additions & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ scripts:
melos run test:flutter --no-select
test:dart:
exec: dart test --chain-stack-traces --platform=vm,chrome,firefox
exec: dart run $MELOS_ROOT_PATH/scripts/sdk_satisfaction.dart && dart test --chain-stack-traces --platform=vm,chrome,firefox || exit 0
packageFilters:
flutter: false
dirExists: 'test'

test:flutter:
exec: flutter test
exec: dart run $MELOS_ROOT_PATH/scripts/sdk_satisfaction.dart && flutter test || exit 0
packageFilters:
flutter: true
dirExists: 'test'
4 changes: 2 additions & 2 deletions plugins/native_dio_adapter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository: https://github.com/cfug/dio/blob/main/plugins/native_dio_adapter
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
sdk: '>=3.1.0 <4.0.0'
flutter: '>=3.13.0'

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ environment:
dev_dependencies:
lints: any
melos: ^3.1.0
pub_semver: ^2.1.0
22 changes: 22 additions & 0 deletions scripts/sdk_satisfaction.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'dart:io';

import 'package:pub_semver/pub_semver.dart';

void main() async {
final current = RegExp(r'\d.\d.\d')
.firstMatch(Process.runSync('dart', ['--version']).stdout as String)!
.group(0)!;
final min = RegExp('sdk: [\'"]>=(\\d*.\\d*.\\d*)')
.firstMatch(File('pubspec.yaml').readAsStringSync())!
.group(1)!;
stdout.writeln('${Directory.current.path}: [$current <=> $min]');
if (Version.parse(current) >= Version.parse(min)) {
exit(0);
} else {
stdout.writeln(
'Skip test for [${Platform.environment['MELOS_PACKAGE_NAME']}] '
'due to not satisfied SDK constraint.',
);
exit(1);
}
}

0 comments on commit 755974c

Please sign in to comment.