diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3699bb41..decacb4f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: [stable] + flutter_version: [stable, beta, master] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -34,8 +34,8 @@ jobs: java-version: '17' - uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 with: - channel: ${{ matrix.flutter_version }} - - run: ./tool/flutter_ci_script_${{ matrix.flutter_version }}.sh + channel: beta + - run: ./tool/ci_script.exe android-build: runs-on: ubuntu-latest diff --git a/tool/ci_script.dart b/tool/ci_script.dart new file mode 100644 index 000000000..008198abd --- /dev/null +++ b/tool/ci_script.dart @@ -0,0 +1,51 @@ +import 'dart:io'; +import 'package:path/path.dart' as path; +import 'package:yaml/yaml.dart'; + +Future main() async { + final rootDir = Directory.current; + final pubspecFile = File(path.join(rootDir.path, 'pubspec.yaml')); + final pubspecContent = await pubspecFile.readAsString(); + final pubspecYaml = loadYaml(pubspecContent); + + final workspace = pubspecYaml['workspace'] as YamlList?; + if (workspace == null) { + print('No workspace found in pubspec.yaml'); + exit(1); + } + + final packages = workspace.map((e) => e.toString()).toList(); + + for (final package in packages) { + final packagePath = path.join(rootDir.path, package); + print('== Testing \'$package\' =='); + + await _runCommand('flutter', ['pub', 'get'], workingDirectory: packagePath); + await _runCommand('dart', ['analyze', '--fatal-infos', '--fatal-warnings'], + workingDirectory: packagePath); + await _runCommand('dart', ['format', '--output', 'none', '.'], + workingDirectory: packagePath); + + if (await Directory(path.join(packagePath, 'test')).exists()) { + final packagePubspecFile = + File(path.join(packagePath, 'pubspec.yaml')); + final packagePubspecContent = await packagePubspecFile.readAsString(); + if (packagePubspecContent.contains('flutter:')) { + await _runCommand('flutter', ['test'], workingDirectory: packagePath); + } else { + await _runCommand('dart', ['test'], workingDirectory: packagePath); + } + } + } +} + +Future _runCommand(String executable, List arguments, + {required String workingDirectory}) async { + final process = await Process.start(executable, arguments, + workingDirectory: workingDirectory, mode: ProcessStartMode.inheritStdio); + final exitCode = await process.exitCode; + if (exitCode != 0) { + print('Command "$executable ${arguments.join(' ')}" failed with exit code $exitCode in $workingDirectory'); + exit(exitCode); + } +} \ No newline at end of file diff --git a/tool/ci_script.exe b/tool/ci_script.exe new file mode 100755 index 000000000..e01eec57d Binary files /dev/null and b/tool/ci_script.exe differ diff --git a/tool/pubspec.yaml b/tool/pubspec.yaml index 8e97992b6..8b53821fd 100644 --- a/tool/pubspec.yaml +++ b/tool/pubspec.yaml @@ -1,4 +1,4 @@ -name: release_cleaner +name: repo_tool description: A tool to automate release cleanup for the samples monorepo. environment: sdk: ^3.9.0-0