precompile generate_gradle_lockfile script BEFORE updating pub dependencies (#160059)
Avoid situations like https://github.com/flutter/flutter/issues/160055
This commit is contained in:
parent
82ecbb5cbd
commit
29a6c648ca
@ -85,6 +85,7 @@ This PR was generated by the automated
|
|||||||
final String orgName;
|
final String orgName;
|
||||||
|
|
||||||
Future<void> roll() async {
|
Future<void> roll() async {
|
||||||
|
final Directory tempDir = framework.fileSystem.systemTempDirectory.createTempSync();
|
||||||
try {
|
try {
|
||||||
await authLogin();
|
await authLogin();
|
||||||
final bool openPrAlready = await hasOpenPrs();
|
final bool openPrAlready = await hasOpenPrs();
|
||||||
@ -92,18 +93,26 @@ This PR was generated by the automated
|
|||||||
// Don't open multiple roll PRs.
|
// Don't open multiple roll PRs.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final Directory frameworkDir = await framework.checkoutDirectory;
|
||||||
|
final String regenerateBinary = await _prebuildRegenerateGradleLockfilesBinary(frameworkDir, tempDir);
|
||||||
final bool didUpdate = await updatePackages();
|
final bool didUpdate = await updatePackages();
|
||||||
if (!didUpdate) {
|
if (!didUpdate) {
|
||||||
log('Packages are already at latest.');
|
log('Packages are already at latest.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await _regenerateGradleLockfiles(await framework.checkoutDirectory);
|
await _regenerateGradleLockfiles(frameworkDir, regenerateBinary);
|
||||||
await pushBranch();
|
await pushBranch();
|
||||||
await createPr(repository: await framework.checkoutDirectory);
|
await createPr(repository: await framework.checkoutDirectory);
|
||||||
await authLogout();
|
await authLogout();
|
||||||
} on Exception catch (exception) {
|
} on Exception catch (exception) {
|
||||||
final String message = _redactToken(exception.toString());
|
final String message = _redactToken(exception.toString());
|
||||||
throw Exception('${exception.runtimeType}: $message');
|
throw Exception('${exception.runtimeType}: $message');
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
tempDir.deleteSync(recursive: true);
|
||||||
|
} on FileSystemException {
|
||||||
|
// Ignore failures
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,12 +148,58 @@ This PR was generated by the automated
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _regenerateGradleLockfiles(Directory repoRoot) async {
|
Future<String> _prebuildRegenerateGradleLockfilesBinary(Directory repoRoot, Directory tempDir) async {
|
||||||
|
final String entrypoint = '${repoRoot.path}/dev/tools/bin/generate_gradle_lockfiles.dart';
|
||||||
|
final File target = tempDir.childFile('generate_gradle_lockfiles');
|
||||||
|
await framework.streamDart(
|
||||||
|
<String>['pub', 'get'],
|
||||||
|
workingDirectory: '${repoRoot.path}/dev/tools',
|
||||||
|
);
|
||||||
await framework.streamDart(<String>[
|
await framework.streamDart(<String>[
|
||||||
'${repoRoot.path}/dev/tools/bin/generate_gradle_lockfiles.dart',
|
'compile',
|
||||||
|
'exe',
|
||||||
|
entrypoint,
|
||||||
|
'-o',
|
||||||
|
target.path,
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
target.existsSync(),
|
||||||
|
'expected ${target.path} to exist after compilation, but it did not.',
|
||||||
|
);
|
||||||
|
|
||||||
|
processManager.runSync(<String>['chmod', '+x', target.path]);
|
||||||
|
|
||||||
|
return target.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _regenerateGradleLockfiles(Directory repoRoot, String regenerateBinary) async {
|
||||||
|
final List<String> cmd = <String>[
|
||||||
|
regenerateBinary,
|
||||||
'--no-gradle-generation',
|
'--no-gradle-generation',
|
||||||
'--no-exclusion',
|
'--no-exclusion',
|
||||||
]);
|
];
|
||||||
|
final io.Process regenerateProcess = await processManager.start(cmd);
|
||||||
|
regenerateProcess
|
||||||
|
.stdout
|
||||||
|
.transform(utf8.decoder)
|
||||||
|
.transform(const LineSplitter())
|
||||||
|
.listen((String line) => stdio.printTrace('[stdout] $line'));
|
||||||
|
regenerateProcess
|
||||||
|
.stderr
|
||||||
|
.transform(utf8.decoder)
|
||||||
|
.transform(const LineSplitter())
|
||||||
|
.listen((String line) => stdio.printTrace('[stderr] $line'));
|
||||||
|
|
||||||
|
final int exitCode = await regenerateProcess.exitCode;
|
||||||
|
if (exitCode != 0) {
|
||||||
|
throw io.ProcessException(
|
||||||
|
cmd.first,
|
||||||
|
cmd.sublist(1),
|
||||||
|
'Process failed',
|
||||||
|
exitCode,
|
||||||
|
);
|
||||||
|
}
|
||||||
switch (CheckoutStatePostGradleRegeneration(await framework.gitStatus(), framework.fileSystem.path)) {
|
switch (CheckoutStatePostGradleRegeneration(await framework.gitStatus(), framework.fileSystem.path)) {
|
||||||
// If the git checkout is clean, we did not update any lockfiles and we do
|
// If the git checkout is clean, we did not update any lockfiles and we do
|
||||||
// not need an additional commit.
|
// not need an additional commit.
|
||||||
|
@ -671,16 +671,23 @@ class FrameworkRepository extends Repository {
|
|||||||
cmd,
|
cmd,
|
||||||
workingDirectory: workingDirectory,
|
workingDirectory: workingDirectory,
|
||||||
);
|
);
|
||||||
process
|
final StreamSubscription<String> stdoutSub = process
|
||||||
.stdout
|
.stdout
|
||||||
.transform(utf8.decoder)
|
.transform(utf8.decoder)
|
||||||
.transform(const LineSplitter())
|
.transform(const LineSplitter())
|
||||||
.listen(stdoutCallback ?? stdio.printTrace);
|
.listen(stdoutCallback ?? stdio.printTrace);
|
||||||
process
|
final StreamSubscription<String> stderrSub = process
|
||||||
.stderr
|
.stderr
|
||||||
.transform(utf8.decoder)
|
.transform(utf8.decoder)
|
||||||
.transform(const LineSplitter())
|
.transform(const LineSplitter())
|
||||||
.listen(stderrCallback ?? stdio.printError);
|
.listen(stderrCallback ?? stdio.printError);
|
||||||
|
await Future.wait<void>(<Future<void>>[
|
||||||
|
stdoutSub.asFuture<void>(),
|
||||||
|
stderrSub.asFuture<void>(),
|
||||||
|
]);
|
||||||
|
unawaited(stdoutSub.cancel());
|
||||||
|
unawaited(stderrSub.cancel());
|
||||||
|
|
||||||
final int exitCode = await process.exitCode;
|
final int exitCode = await process.exitCode;
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
throw io.ProcessException(
|
throw io.ProcessException(
|
||||||
|
@ -281,6 +281,27 @@ void main() {
|
|||||||
'rev-parse',
|
'rev-parse',
|
||||||
'HEAD',
|
'HEAD',
|
||||||
], stdout: 'deadbeef'),
|
], stdout: 'deadbeef'),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||||
|
'pub',
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
workingDirectory: '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||||
|
),
|
||||||
|
FakeCommand(command: const <String>[
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||||
|
'compile',
|
||||||
|
'exe',
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||||
|
'-o',
|
||||||
|
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||||
|
], onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync()),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'chmod',
|
||||||
|
'+x',
|
||||||
|
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||||
|
]),
|
||||||
const FakeCommand(command: <String>[
|
const FakeCommand(command: <String>[
|
||||||
'git',
|
'git',
|
||||||
'ls-remote',
|
'ls-remote',
|
||||||
@ -373,6 +394,27 @@ void main() {
|
|||||||
'rev-parse',
|
'rev-parse',
|
||||||
'HEAD',
|
'HEAD',
|
||||||
], stdout: 'deadbeef'),
|
], stdout: 'deadbeef'),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||||
|
'pub',
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
workingDirectory: '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||||
|
),
|
||||||
|
FakeCommand(command: const <String>[
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||||
|
'compile',
|
||||||
|
'exe',
|
||||||
|
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||||
|
'-o',
|
||||||
|
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||||
|
], onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync()),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'chmod',
|
||||||
|
'+x',
|
||||||
|
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||||
|
]),
|
||||||
const FakeCommand(command: <String>[
|
const FakeCommand(command: <String>[
|
||||||
'git',
|
'git',
|
||||||
'ls-remote',
|
'ls-remote',
|
||||||
@ -427,8 +469,7 @@ void main() {
|
|||||||
'HEAD',
|
'HEAD',
|
||||||
], stdout: '000deadbeef'),
|
], stdout: '000deadbeef'),
|
||||||
const FakeCommand(command: <String>[
|
const FakeCommand(command: <String>[
|
||||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
|
||||||
'--no-gradle-generation',
|
'--no-gradle-generation',
|
||||||
'--no-exclusion',
|
'--no-exclusion',
|
||||||
]),
|
]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user