Skip to content

Commit 074aa42

Browse files
committed
update ci script
1 parent a80fe32 commit 074aa42

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
flutter_version: [stable]
27+
flutter_version: [stable, beta, master]
2828
os: [ubuntu-latest, macos-latest, windows-latest]
2929
steps:
3030
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -34,8 +34,8 @@ jobs:
3434
java-version: '17'
3535
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
3636
with:
37-
channel: ${{ matrix.flutter_version }}
38-
- run: ./tool/flutter_ci_script_${{ matrix.flutter_version }}.sh
37+
channel: beta
38+
- run: ./tool/ci_script.exe
3939

4040
android-build:
4141
runs-on: ubuntu-latest

tool/ci_script.dart

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import 'dart:io';
2+
import 'package:path/path.dart' as path;
3+
import 'package:yaml/yaml.dart';
4+
5+
Future<void> main() async {
6+
final rootDir = Directory.current;
7+
final pubspecFile = File(path.join(rootDir.path, 'pubspec.yaml'));
8+
final pubspecContent = await pubspecFile.readAsString();
9+
final pubspecYaml = loadYaml(pubspecContent);
10+
11+
final workspace = pubspecYaml['workspace'] as YamlList?;
12+
if (workspace == null) {
13+
print('No workspace found in pubspec.yaml');
14+
exit(1);
15+
}
16+
17+
final packages = workspace.map((e) => e.toString()).toList();
18+
19+
for (final package in packages) {
20+
final packagePath = path.join(rootDir.path, package);
21+
print('== Testing \'$package\' ==');
22+
23+
await _runCommand('flutter', ['pub', 'get'], workingDirectory: packagePath);
24+
await _runCommand('dart', ['analyze', '--fatal-infos', '--fatal-warnings'],
25+
workingDirectory: packagePath);
26+
await _runCommand('dart', ['format', '--output', 'none', '.'],
27+
workingDirectory: packagePath);
28+
29+
if (await Directory(path.join(packagePath, 'test')).exists()) {
30+
final packagePubspecFile =
31+
File(path.join(packagePath, 'pubspec.yaml'));
32+
final packagePubspecContent = await packagePubspecFile.readAsString();
33+
if (packagePubspecContent.contains('flutter:')) {
34+
await _runCommand('flutter', ['test'], workingDirectory: packagePath);
35+
} else {
36+
await _runCommand('dart', ['test'], workingDirectory: packagePath);
37+
}
38+
}
39+
}
40+
}
41+
42+
Future<void> _runCommand(String executable, List<String> arguments,
43+
{required String workingDirectory}) async {
44+
final process = await Process.start(executable, arguments,
45+
workingDirectory: workingDirectory, mode: ProcessStartMode.inheritStdio);
46+
final exitCode = await process.exitCode;
47+
if (exitCode != 0) {
48+
print('Command "$executable ${arguments.join(' ')}" failed with exit code $exitCode in $workingDirectory');
49+
exit(exitCode);
50+
}
51+
}

tool/ci_script.exe

5.62 MB
Binary file not shown.

tool/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: release_cleaner
1+
name: repo_tool
22
description: A tool to automate release cleanup for the samples monorepo.
33
environment:
44
sdk: ^3.9.0-0

0 commit comments

Comments
 (0)