Recover releases from independently retried CI packaging #15

Merged
lingjhf merged 2 commits from codex/release-artifact-recovery into main 2026-10-11 20:52:08 +00:00
2 changed files with 72 additions and 12 deletions
Showing only changes of commit 8dada4726c - Show all commits

No files matched your search

+66 -11
View File
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
@@ -14,20 +15,20 @@ const _generatedFiles = [
]; ];
void main() { void main() {
test('workspace generated code is up to date', () async { test(
'workspace generated code is up to date',
() async {
await _expectNoUntrackedGeneratedFiles(); await _expectNoUntrackedGeneratedFiles();
final before = await _generatedContents(); final before = await _generatedContents();
final dart = flutterTestDartExecutable(); final dart = flutterTestDartExecutable();
final elapsed = Stopwatch()..start();
for (final directory in _generatorRoots()) { for (final directory in _generatorRoots()) {
final result = await Process.run(dart, [ await _generate(
'run', dart,
'build_runner', directory,
'build', const Duration(minutes: 5) -
], workingDirectory: directory); const Duration(seconds: 10) -
expect( elapsed.elapsed,
result.exitCode,
0,
reason: '$directory\n${result.stdout}\n${result.stderr}',
); );
} }
expect( expect(
@@ -36,7 +37,61 @@ void main() {
reason: 'Generated files changed. Run dart run build_runner build and review the output.', reason: 'Generated files changed. Run dart run build_runner build and review the output.',
); );
await _expectNoUntrackedGeneratedFiles(); await _expectNoUntrackedGeneratedFiles();
}, timeout: const Timeout(Duration(minutes: 5))); },
timeout: const Timeout(Duration(minutes: 5)),
tags: ['codegen'],
);
}
Future<void> _generate(
String dart,
String directory,
Duration remaining,
) async {
if (remaining <= Duration.zero) {
throw TimeoutException('Generated-code verification budget exhausted');
}
final elapsed = Stopwatch()..start();
stdout.writeln(
'Generating $directory; remaining budget: ${remaining.inSeconds}s',
);
final process = await Process.start(dart, [
'run',
'build_runner',
'build',
], workingDirectory: directory);
final output = StringBuffer();
Future<void> read(Stream<List<int>> stream) async {
await for (final line
in stream.transform(utf8.decoder).transform(const LineSplitter())) {
output.writeln(line);
stdout.writeln('[$directory] $line');
}
}
final streams = Future.wait([read(process.stdout), read(process.stderr)]);
var exited = false;
try {
final exitCode = await process.exitCode.timeout(remaining);
exited = true;
await streams;
expect(exitCode, 0, reason: '$directory\n$output');
} finally {
if (!exited) {
// Flutter's outer test timeout cannot terminate Process.run children.
// End the generator before leaving the test, including on Windows.
if (Platform.isWindows) {
await Process.run('taskkill', ['/PID', '${process.pid}', '/T', '/F']);
} else {
process.kill(ProcessSignal.sigkill);
}
await process.exitCode;
await streams;
}
stdout.writeln(
'Generation $directory ended after ${elapsed.elapsed.inMilliseconds}ms',
);
}
} }
Future<void> _expectNoUntrackedGeneratedFiles() async { Future<void> _expectNoUntrackedGeneratedFiles() async {
+6 -1
View File
@@ -45,7 +45,12 @@ def check_analyze():
def check_flutter(): def check_flutter():
package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test') package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test')
for path in (ROOT / 'packages').glob(pattern)) for path in (ROOT / 'packages').glob(pattern))
run(tool_command('flutter', ['test', '--reporter', 'expanded', 'test', *package_tests])) run(tool_command('flutter', ['test', '--reporter', 'expanded', '--exclude-tags', 'codegen',
'test', *package_tests]))
# build_runner compiles generators and performs repository-wide file I/O.
# Keep this gate serial with widget tests to avoid competing with their isolates.
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--tags', 'codegen',
'test/generated_code_test.dart']))
def main(): def main():