@@ -46,8 +46,13 @@ protected function configure()
4646 {
4747 $ this ->setName ('repo:compliance ' )
4848 ->setDescription ('ensure all github repositories meet compliance ' )
49- ->addOption ('component ' , 'c ' , InputOption::VALUE_REQUIRED , 'If specified, display repo info for this component only ' , '' )
50- ->addOption ('token ' , 't ' , InputOption::VALUE_REQUIRED , 'Github token to use for authentication ' , '' )
49+ ->addOption (
50+ 'component ' ,
51+ 'c ' ,
52+ InputOption::VALUE_REQUIRED |InputOption::VALUE_IS_ARRAY ,
53+ 'If specified, display repo info for this component only '
54+ )
55+ ->addOption ('token ' , 't ' , InputOption::VALUE_REQUIRED , 'Github token to use for authentication ' )
5156 ->addOption ('format ' , 'f ' , InputOption::VALUE_REQUIRED , 'can be "ci" or "table" ' , 'table ' )
5257 ->addOption ('packagist-token ' , 'p ' , InputOption::VALUE_REQUIRED , 'Packagist token for the webhook ' )
5358 ;
@@ -77,19 +82,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
7782 ];
7883 (clone $ table )->setHeaders ($ headers )->render ();
7984
80- $ componentName = $ input ->getOption ('component ' );
81- $ components = $ componentName ? [new Component ($ componentName )] : Component::getComponents ();
85+ $ components = $ input ->getOption ('component ' )
86+ ? array_map (fn ($ c ) => new Component ($ c ), $ input ->getOption ('component ' ))
87+ : Component::getComponents ();
8288
83- $ isCompliant = true ;
8489 $ emoji = fn ($ check ) => match ($ check ) { 'skipped ' => '⚪ ' , false => '❌ ' , true => '✅ ' , null => '❓ ' };
90+ $ failed = [];
8591 foreach ($ components as $ i => $ component ) {
8692 $ isNewComponent = $ component ->getPackageVersion () === '0.0.0 '
87- || $ component ->getPackageVersion () === '0.1.0 ' && $ format == 'ci ' ;
93+ || ( $ component ->getPackageVersion () === '0.1.0 ' && $ format == 'ci ' ) ;
8894
8995 do {
9096 $ refreshDetails = false ;
9197 if (!$ details = $ this ->getRepoDetails ($ component )) {
92- $ isCompliant = $ settingsCheck = $ packagistCheck = $ webhookCheck = $ teamCheck = false ;
98+ $ settingsCheck = $ packagistCheck = $ webhookCheck = $ teamCheck = false ;
9399 $ details = array_fill (0 , count ($ headers ) - 1 , '**REPO NOT FOUND** ' );
94100 $ details [0 ] = str_replace ('googleapis/ ' , '' , $ component ->getRepoName ());
95101 continue ;
@@ -122,14 +128,26 @@ protected function execute(InputInterface $input, OutputInterface $output)
122128 sprintf ('%s Github teams permissions are configured correctly ' , $ emoji ($ teamCheck )),
123129 '' ,
124130 ]);
125- $ isCompliant &= $ settingsCheck && $ webhookCheck && $ packagistCheck && $ teamCheck ;
126131 if ($ format == 'ci ' ) {
127132 unset($ details ['repo_config ' ], $ details ['packagist_config ' ], $ details ['teams ' ]);
128133 }
129- (clone $ table )->addRow ($ details )->render ();
134+ $ componentTable = (clone $ table );
135+ $ componentTable ->addRow ($ details )->render ();
136+
137+ if (!($ settingsCheck && $ webhookCheck && $ packagistCheck && $ teamCheck )) {
138+ $ failed [] = $ componentTable ;
139+ }
140+ }
141+
142+ if (count ($ failed ) > 0 ) {
143+ $ output ->writeln ('<error>ERROR: ' . count ($ failed ) . ' components failed the repo compliance check: ' );
144+ foreach ($ failed as $ table ) {
145+ $ table ->render ();
146+ }
147+ return Command::FAILURE ;
130148 }
131149
132- return $ isCompliant ? Command::SUCCESS : Command:: FAILURE ;
150+ return Command::SUCCESS ;
133151 }
134152
135153 private function checkSettingsCompliance (array $ details )
0 commit comments