diff --git a/.ci.yaml b/.ci.yaml index 1937547874..e12dcbf99d 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -389,7 +389,9 @@ targets: - name: Linux packages_autoroller presubmit: false recipe: pub_autoroller/pub_autoroller - timeout: 30 + # This takes a while because we need to fetch network dependencies and run + # Gradle for every android app in the repo + timeout: 45 enabled_branches: # Don't run this on release branches - master diff --git a/dev/conductor/core/lib/src/git.dart b/dev/conductor/core/lib/src/git.dart index baa78860ae..2c4c4042dc 100644 --- a/dev/conductor/core/lib/src/git.dart +++ b/dev/conductor/core/lib/src/git.dart @@ -33,7 +33,7 @@ class Git { _reportFailureAndExit(args, workingDirectory, result, explanation); } - Future run( + Future run( List args, String explanation, { bool allowNonZeroExitCode = false, @@ -48,7 +48,7 @@ class Git { if (result.exitCode != 0 && !allowNonZeroExitCode) { _reportFailureAndExit(args, workingDirectory, result, explanation); } - return result.exitCode; + return result; } Future _run(List args, String workingDirectory) async { diff --git a/dev/conductor/core/lib/src/packages_autoroller.dart b/dev/conductor/core/lib/src/packages_autoroller.dart index c7535372f8..ca3f67f01e 100644 --- a/dev/conductor/core/lib/src/packages_autoroller.dart +++ b/dev/conductor/core/lib/src/packages_autoroller.dart @@ -140,7 +140,7 @@ This PR was generated by the automated } Future _regenerateGradleLockfiles(Directory repoRoot) async { - await framework.runDart([ + await framework.streamDart([ '${repoRoot.path}/dev/tools/bin/generate_gradle_lockfiles.dart', '--no-gradle-generation', '--no-exclusion', @@ -149,8 +149,10 @@ This PR was generated by the automated // If the git checkout is clean, we did not update any lockfiles and we do // not need an additional commit. case NoDiff(): + stdio.printTrace('No diff after calling generate_gradle_lockfiles.dart'); return; case OnlyLockfileChanges(): + stdio.printTrace('Committing Gradle lockfile changes...'); await framework.commit( 'Re-generate Gradle lockfiles', addFirst: true, diff --git a/dev/conductor/core/lib/src/repository.dart b/dev/conductor/core/lib/src/repository.dart index a9dcb1cb67..f2508ad534 100644 --- a/dev/conductor/core/lib/src/repository.dart +++ b/dev/conductor/core/lib/src/repository.dart @@ -380,7 +380,7 @@ abstract class Repository { /// Determines if one ref is an ancestor for another. Future isAncestor(String possibleAncestor, String possibleDescendant) async { - final int exitcode = await git.run( + final io.ProcessResult result = await git.run( [ 'merge-base', '--is-ancestor', @@ -391,18 +391,18 @@ abstract class Repository { allowNonZeroExitCode: true, workingDirectory: (await checkoutDirectory).path, ); - return exitcode == 0; + return result.exitCode == 0; } /// Determines if a given commit has a tag. Future isCommitTagged(String commit) async { - final int exitcode = await git.run( + final io.ProcessResult result = await git.run( ['describe', '--exact-match', '--tags', commit], 'verify $commit is already tagged', allowNonZeroExitCode: true, workingDirectory: (await checkoutDirectory).path, ); - return exitcode == 0; + return result.exitCode == 0; } /// Resets repository HEAD to [ref]. @@ -480,16 +480,27 @@ abstract class Repository { } authorArg = '--author="$author"'; } - await git.run( - [ - 'commit', - '--message', - message, - if (authorArg != null) authorArg, - ], + final List commitCmd = [ + 'commit', + '--message', + message, + if (authorArg != null) authorArg, + ]; + stdio.printTrace('Executing git $commitCmd...'); + final io.ProcessResult commitResult = await git.run( + commitCmd, 'commit changes', workingDirectory: (await checkoutDirectory).path, ); + final String stdout = commitResult.stdout as String; + if (stdout.isNotEmpty) { + stdio.printTrace(stdout); + } + final String stderr = commitResult.stderr as String; + if (stderr.isNotEmpty) { + stdio.printTrace(stderr); + } + return reverseParse('HEAD'); } @@ -608,19 +619,31 @@ class FrameworkRepository extends Repository { ]); } - Future runDart(List args) async { - return processManager.run([ - fileSystem.path.join((await checkoutDirectory).path, 'bin', 'dart'), - ...args, - ]); - } - Future runFlutter(List args) async { await _ensureToolReady(); - return processManager.run([ - fileSystem.path.join((await checkoutDirectory).path, 'bin', 'flutter'), - ...args, - ]); + final String workingDirectory = (await checkoutDirectory).path; + return processManager.run( + [ + fileSystem.path.join(workingDirectory, 'bin', 'flutter'), + ...args, + ], + workingDirectory: workingDirectory, + ); + } + + Future streamDart( + List args, { + String? workingDirectory, + }) async { + final String repoWorkingDirectory = (await checkoutDirectory).path; + + await _streamProcess( + [ + fileSystem.path.join(repoWorkingDirectory, 'bin', 'dart'), + ...args, + ], + workingDirectory: workingDirectory ?? repoWorkingDirectory, + ); } Future streamFlutter( @@ -628,11 +651,28 @@ class FrameworkRepository extends Repository { void Function(String)? stdoutCallback, void Function(String)? stderrCallback, }) async { - await _ensureToolReady(); - final io.Process process = await processManager.start([ - fileSystem.path.join((await checkoutDirectory).path, 'bin', 'flutter'), - ...args, - ]); + final String workingDirectory = (await checkoutDirectory).path; + + return _streamProcess( + [ + fileSystem.path.join(workingDirectory, 'bin', 'flutter'), + ...args, + ], + workingDirectory: workingDirectory, + ); + } + + Future _streamProcess( + List cmd, { + void Function(String)? stdoutCallback, + void Function(String)? stderrCallback, + String? workingDirectory, + }) async { + stdio.printTrace('Executing $cmd...'); + final io.Process process = await processManager.start( + cmd, + workingDirectory: workingDirectory, + ); process .stdout .transform(utf8.decoder) @@ -643,6 +683,15 @@ class FrameworkRepository extends Repository { .transform(utf8.decoder) .transform(const LineSplitter()) .listen(stderrCallback ?? stdio.printError); + final int exitCode = await process.exitCode; + if (exitCode != 0) { + throw io.ProcessException( + cmd.first, + cmd.sublist(1), + 'Process failed', + exitCode, + ); + } return process; } diff --git a/dev/conductor/core/lib/src/validate_checkout_post_gradle_regeneration.dart b/dev/conductor/core/lib/src/validate_checkout_post_gradle_regeneration.dart index 7c59d2b556..47a77f4956 100644 --- a/dev/conductor/core/lib/src/validate_checkout_post_gradle_regeneration.dart +++ b/dev/conductor/core/lib/src/validate_checkout_post_gradle_regeneration.dart @@ -13,7 +13,7 @@ sealed class CheckoutStatePostGradleRegeneration { return const NoDiff(); } - final List changes = gitStatusOutput.trim().split('\n'); + final List changes = gitStatusOutput.split('\n'); final List changedPaths = []; for (final String line in changes) { final RegExpMatch? match = pattern.firstMatch(line); diff --git a/dev/conductor/core/test/packages_autoroller_test.dart b/dev/conductor/core/test/packages_autoroller_test.dart index 0bd2d54f41..0379137122 100644 --- a/dev/conductor/core/test/packages_autoroller_test.dart +++ b/dev/conductor/core/test/packages_autoroller_test.dart @@ -293,10 +293,6 @@ void main() { '-b', 'packages-autoroller-branch-1', ]), - const FakeCommand(command: [ - '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter', - 'help', - ]), const FakeCommand(command: [ '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter', '--verbose', @@ -389,10 +385,6 @@ void main() { '-b', 'packages-autoroller-branch-1', ]), - const FakeCommand(command: [ - '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter', - 'help', - ]), const FakeCommand(command: [ '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter', '--verbose', diff --git a/packages/flutter_tools/lib/src/update_packages_pins.dart b/packages/flutter_tools/lib/src/update_packages_pins.dart index ddb842d6cf..c0556e7302 100644 --- a/packages/flutter_tools/lib/src/update_packages_pins.dart +++ b/packages/flutter_tools/lib/src/update_packages_pins.dart @@ -28,7 +28,6 @@ const Map kManuallyPinnedDependencies = { 'leak_tracker': '10.0.7', // https://github.com/flutter/devtools/issues/3951 'leak_tracker_testing': '3.0.1', // https://github.com/flutter/devtools/issues/3951 'leak_tracker_flutter_testing': '3.0.8', // https://github.com/flutter/devtools/issues/3951 - 'path_provider_android': '2.2.1', // https://github.com/flutter/flutter/issues/140796 }; /// These are packages that are explicitly excluded from appearing in the list