Skip to content

Commit 92697d3

Browse files
Improve tracing and fix packages_autoroller (flutter#154841)
Reverts flutter#154555 Re-lands of flutter#154441 and flutter#154369 New changes in this PR: 1. extend timeout of the `Linux packages_autoroller` shard (see step 14 in this example [LED build](https://ci.chromium.org/ui/p/flutter/builders/prod.shadow/Linux%20packages_autoroller/7/infra)) 2. use the managed framework repo as the working directory in the `framework.streamDart()` helper function--we were generating gradle lockfiles in the wrong directory A LED build with this code generated the following gradle lockfile update: flutter@d939981
1 parent 81d23d9 commit 92697d3

File tree

7 files changed

+85
-41
lines changed

7 files changed

+85
-41
lines changed

.ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ targets:
389389
- name: Linux packages_autoroller
390390
presubmit: false
391391
recipe: pub_autoroller/pub_autoroller
392-
timeout: 30
392+
# This takes a while because we need to fetch network dependencies and run
393+
# Gradle for every android app in the repo
394+
timeout: 45
393395
enabled_branches:
394396
# Don't run this on release branches
395397
- master

dev/conductor/core/lib/src/git.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Git {
3333
_reportFailureAndExit(args, workingDirectory, result, explanation);
3434
}
3535

36-
Future<int> run(
36+
Future<ProcessResult> run(
3737
List<String> args,
3838
String explanation, {
3939
bool allowNonZeroExitCode = false,
@@ -48,7 +48,7 @@ class Git {
4848
if (result.exitCode != 0 && !allowNonZeroExitCode) {
4949
_reportFailureAndExit(args, workingDirectory, result, explanation);
5050
}
51-
return result.exitCode;
51+
return result;
5252
}
5353

5454
Future<ProcessResult> _run(List<String> args, String workingDirectory) async {

dev/conductor/core/lib/src/packages_autoroller.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ This PR was generated by the automated
140140
}
141141

142142
Future<void> _regenerateGradleLockfiles(Directory repoRoot) async {
143-
await framework.runDart(<String>[
143+
await framework.streamDart(<String>[
144144
'${repoRoot.path}/dev/tools/bin/generate_gradle_lockfiles.dart',
145145
'--no-gradle-generation',
146146
'--no-exclusion',
@@ -149,8 +149,10 @@ This PR was generated by the automated
149149
// If the git checkout is clean, we did not update any lockfiles and we do
150150
// not need an additional commit.
151151
case NoDiff():
152+
stdio.printTrace('No diff after calling generate_gradle_lockfiles.dart');
152153
return;
153154
case OnlyLockfileChanges():
155+
stdio.printTrace('Committing Gradle lockfile changes...');
154156
await framework.commit(
155157
'Re-generate Gradle lockfiles',
156158
addFirst: true,

dev/conductor/core/lib/src/repository.dart

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ abstract class Repository {
380380

381381
/// Determines if one ref is an ancestor for another.
382382
Future<bool> isAncestor(String possibleAncestor, String possibleDescendant) async {
383-
final int exitcode = await git.run(
383+
final io.ProcessResult result = await git.run(
384384
<String>[
385385
'merge-base',
386386
'--is-ancestor',
@@ -391,18 +391,18 @@ abstract class Repository {
391391
allowNonZeroExitCode: true,
392392
workingDirectory: (await checkoutDirectory).path,
393393
);
394-
return exitcode == 0;
394+
return result.exitCode == 0;
395395
}
396396

397397
/// Determines if a given commit has a tag.
398398
Future<bool> isCommitTagged(String commit) async {
399-
final int exitcode = await git.run(
399+
final io.ProcessResult result = await git.run(
400400
<String>['describe', '--exact-match', '--tags', commit],
401401
'verify $commit is already tagged',
402402
allowNonZeroExitCode: true,
403403
workingDirectory: (await checkoutDirectory).path,
404404
);
405-
return exitcode == 0;
405+
return result.exitCode == 0;
406406
}
407407

408408
/// Resets repository HEAD to [ref].
@@ -480,16 +480,27 @@ abstract class Repository {
480480
}
481481
authorArg = '--author="$author"';
482482
}
483-
await git.run(
484-
<String>[
485-
'commit',
486-
'--message',
487-
message,
488-
if (authorArg != null) authorArg,
489-
],
483+
final List<String> commitCmd = <String>[
484+
'commit',
485+
'--message',
486+
message,
487+
if (authorArg != null) authorArg,
488+
];
489+
stdio.printTrace('Executing git $commitCmd...');
490+
final io.ProcessResult commitResult = await git.run(
491+
commitCmd,
490492
'commit changes',
491493
workingDirectory: (await checkoutDirectory).path,
492494
);
495+
final String stdout = commitResult.stdout as String;
496+
if (stdout.isNotEmpty) {
497+
stdio.printTrace(stdout);
498+
}
499+
final String stderr = commitResult.stderr as String;
500+
if (stderr.isNotEmpty) {
501+
stdio.printTrace(stderr);
502+
}
503+
493504
return reverseParse('HEAD');
494505
}
495506

@@ -608,31 +619,60 @@ class FrameworkRepository extends Repository {
608619
]);
609620
}
610621

611-
Future<io.ProcessResult> runDart(List<String> args) async {
612-
return processManager.run(<String>[
613-
fileSystem.path.join((await checkoutDirectory).path, 'bin', 'dart'),
614-
...args,
615-
]);
616-
}
617-
618622
Future<io.ProcessResult> runFlutter(List<String> args) async {
619623
await _ensureToolReady();
620-
return processManager.run(<String>[
621-
fileSystem.path.join((await checkoutDirectory).path, 'bin', 'flutter'),
622-
...args,
623-
]);
624+
final String workingDirectory = (await checkoutDirectory).path;
625+
return processManager.run(
626+
<String>[
627+
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
628+
...args,
629+
],
630+
workingDirectory: workingDirectory,
631+
);
632+
}
633+
634+
Future<void> streamDart(
635+
List<String> args, {
636+
String? workingDirectory,
637+
}) async {
638+
final String repoWorkingDirectory = (await checkoutDirectory).path;
639+
640+
await _streamProcess(
641+
<String>[
642+
fileSystem.path.join(repoWorkingDirectory, 'bin', 'dart'),
643+
...args,
644+
],
645+
workingDirectory: workingDirectory ?? repoWorkingDirectory,
646+
);
624647
}
625648

626649
Future<io.Process> streamFlutter(
627650
List<String> args, {
628651
void Function(String)? stdoutCallback,
629652
void Function(String)? stderrCallback,
630653
}) async {
631-
await _ensureToolReady();
632-
final io.Process process = await processManager.start(<String>[
633-
fileSystem.path.join((await checkoutDirectory).path, 'bin', 'flutter'),
634-
...args,
635-
]);
654+
final String workingDirectory = (await checkoutDirectory).path;
655+
656+
return _streamProcess(
657+
<String>[
658+
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
659+
...args,
660+
],
661+
workingDirectory: workingDirectory,
662+
);
663+
}
664+
665+
Future<io.Process> _streamProcess(
666+
List<String> cmd, {
667+
void Function(String)? stdoutCallback,
668+
void Function(String)? stderrCallback,
669+
String? workingDirectory,
670+
}) async {
671+
stdio.printTrace('Executing $cmd...');
672+
final io.Process process = await processManager.start(
673+
cmd,
674+
workingDirectory: workingDirectory,
675+
);
636676
process
637677
.stdout
638678
.transform(utf8.decoder)
@@ -643,6 +683,15 @@ class FrameworkRepository extends Repository {
643683
.transform(utf8.decoder)
644684
.transform(const LineSplitter())
645685
.listen(stderrCallback ?? stdio.printError);
686+
final int exitCode = await process.exitCode;
687+
if (exitCode != 0) {
688+
throw io.ProcessException(
689+
cmd.first,
690+
cmd.sublist(1),
691+
'Process failed',
692+
exitCode,
693+
);
694+
}
646695
return process;
647696
}
648697

dev/conductor/core/lib/src/validate_checkout_post_gradle_regeneration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ sealed class CheckoutStatePostGradleRegeneration {
1313
return const NoDiff();
1414
}
1515

16-
final List<String> changes = gitStatusOutput.trim().split('\n');
16+
final List<String> changes = gitStatusOutput.split('\n');
1717
final List<String> changedPaths = <String>[];
1818
for (final String line in changes) {
1919
final RegExpMatch? match = pattern.firstMatch(line);

dev/conductor/core/test/packages_autoroller_test.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ void main() {
293293
'-b',
294294
'packages-autoroller-branch-1',
295295
]),
296-
const FakeCommand(command: <String>[
297-
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
298-
'help',
299-
]),
300296
const FakeCommand(command: <String>[
301297
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
302298
'--verbose',
@@ -389,10 +385,6 @@ void main() {
389385
'-b',
390386
'packages-autoroller-branch-1',
391387
]),
392-
const FakeCommand(command: <String>[
393-
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
394-
'help',
395-
]),
396388
const FakeCommand(command: <String>[
397389
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
398390
'--verbose',

packages/flutter_tools/lib/src/update_packages_pins.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const Map<String, String> kManuallyPinnedDependencies = <String, String>{
2828
'leak_tracker': '10.0.7', // https://github.com/flutter/devtools/issues/3951
2929
'leak_tracker_testing': '3.0.1', // https://github.com/flutter/devtools/issues/3951
3030
'leak_tracker_flutter_testing': '3.0.8', // https://github.com/flutter/devtools/issues/3951
31-
'path_provider_android': '2.2.1', // https://github.com/flutter/flutter/issues/140796
3231
};
3332

3433
/// These are packages that are explicitly excluded from appearing in the list

0 commit comments

Comments
 (0)