1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
Files
samples/tool/ci_script.dart
Eric Windmill 2999d738b8 Dart 3.9 / Flutter 3.35 [first LLM release] (#2714)
I got carried away with Gemini and basically rewrote CI and the release
process for the new LLM reality. This work was largely completed by
Gemini.

- Bump all SDK versions to the current beta (3.9.0-0)
- Run `flutter channel beta`
- Wrote `ci_script.dart` to replace the bash scripts
- Converted repository to pub workspace #2499 
- Added llm.md and release.md
- Added redirect for deprecated Samples Index

## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [x] I have added sample code updates to the [changelog].
- [x] I updated/added relevant documentation (doc comments with `///`).
2025-08-14 12:26:24 -07:00

68 lines
2.0 KiB
Dart

import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
Future<void> 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);
}
// pub workspace, only run 'get' once
await _runCommand('flutter', ['pub', 'get'], workingDirectory: rootDir.path);
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('dart', [
'analyze',
'--fatal-infos',
'--fatal-warnings',
], workingDirectory: packagePath);
await _runCommand('dart', ['format', '.'], 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',
'--no-pub',
], workingDirectory: packagePath);
} else {
await _runCommand('dart', ['test'], workingDirectory: packagePath);
}
}
}
}
Future<void> _runCommand(
String executable,
List<String> arguments, {
String? workingDirectory,
}) async {
final process = await Process.start(
executable,
arguments,
workingDirectory: workingDirectory,
runInShell: true,
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);
}
}