From 8106a12e3d3ee2d783c5631b8387a4ab00ae3805 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 4 May 2026 09:55:02 -0700 Subject: [PATCH 1/5] fix(dev): repo compliance skip --- dev/src/Command/RepoComplianceCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/Command/RepoComplianceCommand.php b/dev/src/Command/RepoComplianceCommand.php index c75e3977207..0f64e0f96d6 100644 --- a/dev/src/Command/RepoComplianceCommand.php +++ b/dev/src/Command/RepoComplianceCommand.php @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $emoji = fn ($check) => match ($check) { 'skipped' => '⚪', false => '❌', true => '✅', null => '❓'}; foreach ($components as $i => $component) { $isNewComponent = $component->getPackageVersion() === '0.0.0' - || $component->getPackageVersion() === '0.1.0' && $format == 'ci'; + || ($component->getPackageVersion() === '0.1.0' && $format == 'ci'); do { $refreshDetails = false; From a9145095904364aa52317ed81d868d844f488f61 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 4 May 2026 09:56:32 -0700 Subject: [PATCH 2/5] fix new package version number --- dev/src/Command/RepoComplianceCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/Command/RepoComplianceCommand.php b/dev/src/Command/RepoComplianceCommand.php index 0f64e0f96d6..cfc2b24e319 100644 --- a/dev/src/Command/RepoComplianceCommand.php +++ b/dev/src/Command/RepoComplianceCommand.php @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $emoji = fn ($check) => match ($check) { 'skipped' => '⚪', false => '❌', true => '✅', null => '❓'}; foreach ($components as $i => $component) { $isNewComponent = $component->getPackageVersion() === '0.0.0' - || ($component->getPackageVersion() === '0.1.0' && $format == 'ci'); + || ($component->getPackageVersion() === '0.0.1' && $format == 'ci'); do { $refreshDetails = false; From ae4c111d4dcb06a2b3f21972ffeef2d233e98fb2 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 4 May 2026 10:03:22 -0700 Subject: [PATCH 3/5] Revert "fix new package version number" This reverts commit a9145095904364aa52317ed81d868d844f488f61. --- dev/src/Command/RepoComplianceCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/Command/RepoComplianceCommand.php b/dev/src/Command/RepoComplianceCommand.php index cfc2b24e319..0f64e0f96d6 100644 --- a/dev/src/Command/RepoComplianceCommand.php +++ b/dev/src/Command/RepoComplianceCommand.php @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $emoji = fn ($check) => match ($check) { 'skipped' => '⚪', false => '❌', true => '✅', null => '❓'}; foreach ($components as $i => $component) { $isNewComponent = $component->getPackageVersion() === '0.0.0' - || ($component->getPackageVersion() === '0.0.1' && $format == 'ci'); + || ($component->getPackageVersion() === '0.1.0' && $format == 'ci'); do { $refreshDetails = false; From c8e4498a7b6833a06dadfa498ca977b2350658b9 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 4 May 2026 10:25:17 -0700 Subject: [PATCH 4/5] make more readable --- dev/src/Command/RepoComplianceCommand.php | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/dev/src/Command/RepoComplianceCommand.php b/dev/src/Command/RepoComplianceCommand.php index 0f64e0f96d6..fe7259bfe1c 100644 --- a/dev/src/Command/RepoComplianceCommand.php +++ b/dev/src/Command/RepoComplianceCommand.php @@ -46,8 +46,13 @@ protected function configure() { $this->setName('repo:compliance') ->setDescription('ensure all github repositories meet compliance') - ->addOption('component', 'c', InputOption::VALUE_REQUIRED, 'If specified, display repo info for this component only', '') - ->addOption('token', 't', InputOption::VALUE_REQUIRED, 'Github token to use for authentication', '') + ->addOption( + 'component', + 'c', + InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, + 'If specified, display repo info for this component only' + ) + ->addOption('token', 't', InputOption::VALUE_REQUIRED, 'Github token to use for authentication') ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'can be "ci" or "table"', 'table') ->addOption('packagist-token', 'p', InputOption::VALUE_REQUIRED, 'Packagist token for the webhook') ; @@ -77,11 +82,12 @@ protected function execute(InputInterface $input, OutputInterface $output) ]; (clone $table)->setHeaders($headers)->render(); - $componentName = $input->getOption('component'); - $components = $componentName ? [new Component($componentName)] : Component::getComponents(); + $components = $input->getOption('component') + ? array_map(fn ($c) => new Component($c), $input->getOption('component')) + : Component::getComponents(); - $isCompliant = true; $emoji = fn ($check) => match ($check) { 'skipped' => '⚪', false => '❌', true => '✅', null => '❓'}; + $failed = []; foreach ($components as $i => $component) { $isNewComponent = $component->getPackageVersion() === '0.0.0' || ($component->getPackageVersion() === '0.1.0' && $format == 'ci'); @@ -89,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output) do { $refreshDetails = false; if (!$details = $this->getRepoDetails($component)) { - $isCompliant = $settingsCheck = $packagistCheck = $webhookCheck = $teamCheck = false; + $settingsCheck = $packagistCheck = $webhookCheck = $teamCheck = false; $details = array_fill(0, count($headers) - 1, '**REPO NOT FOUND**'); $details[0] = str_replace('googleapis/', '', $component->getRepoName()); continue; @@ -122,14 +128,26 @@ protected function execute(InputInterface $input, OutputInterface $output) sprintf('%s Github teams permissions are configured correctly', $emoji($teamCheck)), '', ]); - $isCompliant &= $settingsCheck && $webhookCheck && $packagistCheck && $teamCheck; if ($format == 'ci') { unset($details['repo_config'], $details['packagist_config'], $details['teams']); } - (clone $table)->addRow($details)->render(); + $componentTable = (clone $table); + $componentTable->addRow($details)->render(); + + if (!($settingsCheck && $webhookCheck && $packagistCheck && $teamCheck)) { + $failed[] = $componentTable; + } + } + + if (count($failed) > 0) { + $output->writeln('ERROR: ' . count($failed) . ' components failed the repo compliance check:'); + foreach ($failed as $table) { + $table->render(); + } + return Command::FAILURE; } - return $isCompliant ? Command::SUCCESS : Command::FAILURE; + return Command::SUCCESS; } private function checkSettingsCompliance(array $details) From ae017e4dca9c991453b59e1a4163d65aa993a7d5 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 4 May 2026 12:50:10 -0700 Subject: [PATCH 5/5] do not fail if webhook already exists --- dev/src/Command/RepoSplitCommand.php | 2 -- dev/src/GitHub.php | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/src/Command/RepoSplitCommand.php b/dev/src/Command/RepoSplitCommand.php index 461b85cf337..bea548652ac 100644 --- a/dev/src/Command/RepoSplitCommand.php +++ b/dev/src/Command/RepoSplitCommand.php @@ -23,13 +23,11 @@ use Google\Cloud\Dev\ReleaseNotes; use Google\Cloud\Dev\RunShell; use Google\Cloud\Dev\Split; -use Google\Cloud\Dev\SplitInstall; use GuzzleHttp\BodySummarizer; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/dev/src/GitHub.php b/dev/src/GitHub.php index 356eab756cf..efde3bc3743 100644 --- a/dev/src/GitHub.php +++ b/dev/src/GitHub.php @@ -407,6 +407,9 @@ public function addWebhook( return $res->getStatusCode() === 201; } catch (\Exception $e) { + if (422 === $e->getCode()) { + return true; // webhook already exists! + } $this->logException($e); return false; }