From 5301d7753f318eca57e44d85360b5bb07c9bb1a0 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 18 Jun 2024 16:28:22 +1200 Subject: [PATCH 1/3] Fix syntax error --- scripts/cms-any/add-prs-to-project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cms-any/add-prs-to-project.php b/scripts/cms-any/add-prs-to-project.php index ea4e2b6..f900eee 100644 --- a/scripts/cms-any/add-prs-to-project.php +++ b/scripts/cms-any/add-prs-to-project.php @@ -1,6 +1,6 @@ Date: Tue, 18 Jun 2024 16:28:51 +1200 Subject: [PATCH 2/3] FIX Only add new action to supported modules and docs --- funcs_scripts.php | 22 ++++++++++++++++++++-- scripts/cms-any/add-prs-to-project.php | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/funcs_scripts.php b/funcs_scripts.php index 1fe20a6..d7c46b2 100644 --- a/funcs_scripts.php +++ b/funcs_scripts.php @@ -240,6 +240,24 @@ function is_docs() return $moduleName === 'developer-docs' || $moduleName === 'silverstripe-userhelp-content'; } +/** + * Determine if the module being processed is commercially supported + * + * Example usage: + * is_supported() + */ +function is_supported() +{ + global $GITHUB_REF; + return in_array( + $GITHUB_REF, + array_column( + MetaData::getAllRepositoryMetaData()[MetaData::CATEGORY_SUPPORTED], + 'github' + ) + ); +} + /** * Determine if the module being processed is a gha-* repository e.g. gha-ci * aka "WORKFLOW" @@ -263,7 +281,7 @@ function is_gha_repository() * Determine if the module being processed is "TOOLING" * * Example usage: - * is_gha_repository() + * is_tooling() */ function is_tooling() { @@ -281,7 +299,7 @@ function is_tooling() * Determine if the module being processed is "MISC" * * Example usage: - * is_gha_repository() + * is_misc() */ function is_misc() { diff --git a/scripts/cms-any/add-prs-to-project.php b/scripts/cms-any/add-prs-to-project.php index f900eee..05d93cb 100644 --- a/scripts/cms-any/add-prs-to-project.php +++ b/scripts/cms-any/add-prs-to-project.php @@ -25,7 +25,7 @@ EOT; $actionPath = '.github/workflows/add-prs-to-project.yml'; -$shouldHaveAction = module_account() === 'silverstripe' && is_module() && !module_is_recipe(); +$shouldHaveAction = module_account() === 'silverstripe' && is_supported() && is_docs() || (is_module() && !module_is_recipe()); if ($shouldHaveAction) { write_file_even_if_exists($actionPath, $content); From 849fbff0eeefffc022ed443419c7cfca9ff4e85a Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 18 Jun 2024 16:29:20 +1200 Subject: [PATCH 3/3] ENH Don't interrupt processing just cause a branch is missing --- update_command.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/update_command.php b/update_command.php index 164c436..fc96f49 100644 --- a/update_command.php +++ b/update_command.php @@ -12,6 +12,8 @@ global $MODULE_DIR, $GITHUB_REF, $OUT, $PRS_CREATED, $REPOS_WITH_PRS_CREATED; $OUT = $output; + $reposMissingBranch = []; + // validate system is ready validate_system(); @@ -146,8 +148,10 @@ $branchOption ); } + // If we can't identify an appropriate branch, add to a list so we can report about it later. if (!in_array($branchToCheckout, $allBranches)) { - error("Could not find branch to checkout for $repo using --branch=$branchOption"); + $reposMissingBranch[] = $repo; + continue; } } cmd("git checkout $branchToCheckout", $MODULE_DIR); @@ -219,5 +223,13 @@ } output_repos_with_prs_created(); output_prs_created(); + + // Report about any repos for which we couldn't find the right branch. + if (count($reposMissingBranch)) { + $reposString = implode("\n- ", $reposMissingBranch); + warning("Could not find branch to checkout for the following repos using --branch=$branchOption:\n- $reposString"); + return Command::FAILURE; + } + return Command::SUCCESS; };