From c4f635a09da552fa07e86a5b23330e1c1b9fd926 Mon Sep 17 00:00:00 2001 From: Jaime Wren Date: Tue, 19 Nov 2024 10:44:10 -0800 Subject: [PATCH] Add an argument only-version to the verify cli command (#7796) --- tool/plugin/lib/verify.dart | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tool/plugin/lib/verify.dart b/tool/plugin/lib/verify.dart index 64a51ce088..4c5a0d7f75 100644 --- a/tool/plugin/lib/verify.dart +++ b/tool/plugin/lib/verify.dart @@ -11,35 +11,55 @@ class VerifyCommand extends ProductCommand { @override final BuildCommandRunner runner; - VerifyCommand(this.runner) : super('verify'); + VerifyCommand(this.runner) : super('verify') { + argParser.addOption('only-version', + abbr: 'o', + help: 'Only verify the specified IntelliJ version; useful for sharding ' + 'builds on CI systems.'); + } @override String get description => - 'Execute the verifyPlugin and verifyPluginConfiguration Gradle tasks for each build spec.'; + 'Execute the verify Gradle tasks for each build spec.'; @override Future doit() async { + final argResults = this.argResults!; + + // Check to see if we should only be building a specific version. + // (this only-version logic was copied from the make command in plugin.dart) + final onlyVersion = argResults.option('only-version'); + + var buildSpecs = specs; + if (onlyVersion != null && onlyVersion.isNotEmpty) { + buildSpecs = specs.where((spec) => spec.version == onlyVersion).toList(); + if (buildSpecs.isEmpty) { + log("No spec found for version '$onlyVersion'"); + return 1; + } + } + // run './gradlew verifyPluginProjectConfiguration' // run './gradlew verifyPluginStructure' // run './gradlew verifyPluginSignature' // run './gradlew verifyPlugin' var result = 0; - for (var spec in specs) { + for (var spec in buildSpecs) { log('\nverifyPluginProjectConfiguration for $spec:'); - result = await runner - .runGradleCommand(['verifyPluginProjectConfiguration'], spec, '1', 'false'); + result = await runner.runGradleCommand( + ['verifyPluginProjectConfiguration'], spec, '1', 'false'); if (result != 0) { return result; } log('\nverifyPluginStructure for $spec:'); - result = - await runner.runGradleCommand(['verifyPluginStructure'], spec, '1', 'false'); + result = await runner + .runGradleCommand(['verifyPluginStructure'], spec, '1', 'false'); if (result != 0) { return result; } log('\nverifyPluginSignature for $spec:'); - result = - await runner.runGradleCommand(['verifyPluginSignature'], spec, '1', 'false'); + result = await runner + .runGradleCommand(['verifyPluginSignature'], spec, '1', 'false'); if (result != 0) { return result; } @@ -50,7 +70,8 @@ class VerifyCommand extends ProductCommand { return result; } } - log('\nSummary: verification of all ${specs + // TODO (jwren) improve logging by listing out the idea versions verified: + log('\nSummary: verification of all ${buildSpecs .length} build specifications was successful.'); return result; }