diff --git a/app/src/DataFetcher/Misc/Consts.php b/app/src/DataFetcher/Misc/Consts.php deleted file mode 100644 index 65142a9..0000000 --- a/app/src/DataFetcher/Misc/Consts.php +++ /dev/null @@ -1,208 +0,0 @@ - [ - 'bringyourownideas' => [ - 'silverstripe-maintenance', - 'silverstripe-composer-update-checker', - ], - 'colymba' => [ - // 'GridFieldBulkEditingTools' // supported dependency - ], - 'dnadesign' => [ - 'silverstripe-elemental-subsites', // supported depenendecy - 'silverstripe-elemental-userforms', // supported depenendecy - ], - 'silverstripe' => [ - 'silverstripe-reports', - 'silverstripe-siteconfig', - 'silverstripe-versioned', - 'silverstripe-versioned-admin', - 'silverstripe-userhelp-content', // not an installed module, though still relevant - 'comment-notifications', - 'cwp', - 'cwp-agencyextensions', - 'cwp-core', - 'cwp-pdfexport', - 'cwp-search', - 'cwp-starter-theme', - 'cwp-watea-theme', - 'doorman', - 'silverstripe-simple', - 'silverstripe-akismet', - 'silverstripe-auditor', - 'silverstripe-admin', - 'silverstripe-asset-admin', - 'silverstripe-assets', - 'silverstripe-blog', - 'silverstripe-campaign-admin', - 'silverstripe-ckan-registry', - 'silverstripe-cms', - 'silverstripe-config', - 'silverstripe-errorpage', - 'silverstripe-framework', - 'silverstripe-graphql', - 'silverstripe-installer', - 'silverstripe-comments', - 'silverstripe-content-widget', - 'silverstripe-contentreview', - 'silverstripe-crontask', - 'silverstripe-documentconverter', - 'silverstripe-dynamodb', - 'silverstripe-elemental', - 'silverstripe-elemental-bannerblock', - 'silverstripe-elemental-fileblock', - 'silverstripe-environmentcheck', - 'silverstripe-event-dispatcher', - 'silverstripe-externallinks', - 'silverstripe-fulltextsearch', - 'silverstripe-gridfieldqueuedexport', - 'silverstripe-html5', - 'silverstripe-hybridsessions', - 'silverstripe-iframe', - 'silverstripe-ldap', - 'silverstripe-lumberjack', - 'silverstripe-mimevalidator', - 'silverstripe-postgresql', - 'silverstripe-realme', - 'silverstripe-session-manager', - 'recipe-authoring-tools', - 'recipe-blog', - 'recipe-ccl', - 'recipe-cms', - 'recipe-collaboration', - 'recipe-content-blocks', - 'recipe-core', - 'recipe-form-building', - 'recipe-reporting-tools', - 'recipe-kitchen-sink', - 'recipe-plugin', - 'recipe-services', - 'recipe-solr-search', - 'silverstripe-registry', - 'silverstripe-restfulserver', - 'silverstripe-securityreport', - 'silverstripe-segment-field', - 'silverstripe-selectupload', - 'silverstripe-sharedraftcontent', - 'silverstripe-sitewidecontent-report', - 'silverstripe-spamprotection', - 'silverstripe-spellcheck', - 'silverstripe-sqlite3', - 'silverstripe-staticpublishqueue', - 'silverstripe-subsites', - 'silverstripe-tagfield', - 'silverstripe-taxonomy', - 'silverstripe-textextraction', // only a supported dependency, though ... - 'silverstripe-userforms', - 'silverstripe-widgets', - 'silverstripe-mfa', - 'silverstripe-totp-authenticator', - 'silverstripe-webauthn-authenticator', - 'silverstripe-login-forms', - 'silverstripe-security-extensions', - // 'silverstripe-upgrader', - 'silverstripe-versionfeed', // not in commercially supported list, though is in cwp - 'vendor-plugin', - 'developer-docs', - '.github', - 'silverstripe-frameworktest', - 'silverstripe-linkfield', - ], - 'symbiote' => [ - 'silverstripe-advancedworkflow', - 'silverstripe-gridfieldextensions', // only a supported dependency, though ... - 'silverstripe-multivaluefield', - 'silverstripe-queuedjobs', - ], - 'tractorcow' => [ - // 'classproxy', // supported dependency - // 'silverstripe-fluent', // supported dependency - misrepoerting next minor branch as only 4.1.x-dev - // 'silverstripe-proxy-db', // supported dependency - ], - 'undefinedoffset' => [ - // 'sortablegridfield' - ] - ], - 'ss3' => [ - 'silverstripe' => [ - // 'cwp-recipe-basic', - // 'cwp-recipe-basic-dev', - // 'cwp-recipe-blog', - // 'silverstripe-activedirectory', - // 'silverstripe-dms', - // 'silverstripe-dms-cart', - // 'silverstripe-secureassets', - // 'silverstripe-staticpublishqueue', - // 'silverstripe-translatable', - ], - 'symbiote' => [ - 'silverstripe-versionedfiles', - ], - ], - 'legacy' => [ - 'silverstripe' => [ - 'cwp-installer', - 'cwp-recipe-cms', - 'cwp-recipe-core', - 'cwp-recipe-kitchen-sink', - 'cwp-recipe-search', - 'cwp-theme-default', - 'silverstripe-controllerpolicy', - 'silverstripe-elemental-blocks', - 'silverstripe-sqlite3', - ], - 'bringyourownideas' => [ - 'silverstripe-composer-security-checker', // abandoned - ], - ], - 'tooling' => [ - 'composer' => [ - // 'installers' // supported depenendecy - ], - 'lekoala' => [ - // 'silverstripe-debugbar', - ], - 'hafriedlander' => [ - // 'phockito', // supported depenendecy - // 'silverstripe-phockito' // supported depenendecy - ], - 'silverstripe' => [ - 'cow', - 'eslint-config', - 'github-actions-ci-cd', - 'MinkFacebookWebDriver', - 'recipe-testing', - 'silverstripe-behat-extension', - 'silverstripe-graphql-devtools', - 'silverstripe-testsession', - 'webpack-config', - 'gha-merge-up', - 'gha-generate-matrix', - 'gha-gauge-release', - 'gha-action-ci', - 'gha-update-js', - 'gha-keepalive', - 'gha-pull-request', - 'gha-auto-tag', - 'gha-run-tests', - 'gha-trigger-ci', - 'gha-tag-release', - 'gha-ci', - 'gha-dispatch-ci', - 'gha-issue', - 'markdown-php-codesniffer', - 'silverstripe-standards', - 'documentation-lint', - ] - ], - ]; -} diff --git a/app/src/DataFetcher/Requesters/AbstractRequester.php b/app/src/DataFetcher/Requesters/AbstractRequester.php index 7e1cb34..20935f9 100644 --- a/app/src/DataFetcher/Requesters/AbstractRequester.php +++ b/app/src/DataFetcher/Requesters/AbstractRequester.php @@ -3,7 +3,6 @@ namespace App\DataFetcher\Requesters; use App\DataFetcher\Apis\ApiConfigInterface; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Models\ApiData; use App\DataFetcher\Misc\Logger; use App\DataFetcher\Interfaces\TypeInterface; @@ -119,7 +118,7 @@ abstract protected function fetchDataFromApi(string $path, string $postBody = '' protected function getMethod(string $postBody): string { - return $postBody ? Consts::METHOD_POST : Consts::METHOD_GET; + return $postBody ? 'post' : 'get'; } protected function waitUntilCanFetch() diff --git a/app/src/DataFetcher/Requesters/RestRequester.php b/app/src/DataFetcher/Requesters/RestRequester.php index 594b00b..c3f8fa3 100644 --- a/app/src/DataFetcher/Requesters/RestRequester.php +++ b/app/src/DataFetcher/Requesters/RestRequester.php @@ -2,7 +2,6 @@ namespace App\DataFetcher\Requesters; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Misc\Logger; class RestRequester extends AbstractRequester @@ -29,7 +28,7 @@ protected function fetchDataFromApi(string $path, string $postBody = ''): string $url = $apiConfig->deriveUrl($path, $offset); Logger::singleton()->log("REST {$ucMethod} {$url}"); curl_setopt($ch, CURLOPT_URL, $url); - if ($method == Consts::METHOD_POST) { + if (strtolower($method) == 'post') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody); } diff --git a/app/src/Misc/SupportedModulesManager.php b/app/src/Misc/SupportedModulesManager.php new file mode 100644 index 0000000..d70b3bb --- /dev/null +++ b/app/src/Misc/SupportedModulesManager.php @@ -0,0 +1,58 @@ +modules)) { + return $this->modules; + } + $repoData = MetaData::getAllRepositoryMetaData(); + $this->modules = [ + 'regular' => [], + 'tooling' => [], + ]; + // Adapt json keys to the keys used in rhino + $types = [ + MetaData::CATEGORY_SUPPORTED => 'regular', + MetaData::CATEGORY_WORKFLOW => 'tooling', + MetaData::CATEGORY_TOOLING => 'tooling', + MetaData::CATEGORY_MISC => 'tooling', + ]; + foreach ($types as $category => $type) { + foreach ($repoData[$category] as $module) { + [$account, $repo] = explode('/', $module['github']); + $this->modules[$type][$account] ??= []; + $this->modules[$type][$account][] = $repo; + $this->cmsMajorToBranches[$repo] = $module['majorVersionMapping']; + } + } + return $this->modules; + } + + public function getMajorBranchIsSupported(string $repo, string $majorBranch): bool + { + if (empty($this->cmsMajorToBranches)) { + $this->getModules(); + } + $cmsMajorToBranches = $this->cmsMajorToBranches[$repo] ?? []; + foreach ($cmsMajorToBranches as $cmsMajor => $branches) { + if ($cmsMajor === '*') { + return true; + } + if (in_array($majorBranch, $branches)) { + return true; + break; + } + } + return false; + } +} diff --git a/app/src/Pages/PageController.php b/app/src/Pages/PageController.php index 3cfa4f5..74afd9f 100644 --- a/app/src/Pages/PageController.php +++ b/app/src/Pages/PageController.php @@ -2,7 +2,6 @@ namespace { - use App\DataFetcher\Models\ApiData; use SilverStripe\CMS\Controllers\ContentController; class PageController extends ContentController diff --git a/app/src/Processors/BuildsProcessor.php b/app/src/Processors/BuildsProcessor.php index a62fa98..d4d4b48 100644 --- a/app/src/Processors/BuildsProcessor.php +++ b/app/src/Processors/BuildsProcessor.php @@ -3,8 +3,8 @@ namespace App\Processors; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Requesters\RestRequester; +use App\Misc\SupportedModulesManager; class BuildsProcessor extends AbstractProcessor { @@ -44,7 +44,8 @@ public function getHtmlTableScript(): string public function process(bool $refetch): array { - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $apiConfig = new GitHubApiConfig(); $requester = new RestRequester($apiConfig); @@ -53,14 +54,14 @@ public function process(bool $refetch): array foreach (['regular', 'tooling'] as $moduleType) { foreach ($modules[$moduleType] as $account => $repos) { foreach ($repos as $repo) { - $varsList[] = [$account, $repo]; + $varsList[] = [$account, $repo, $moduleType]; } } } $rows = []; foreach ($varsList as $vars) { - list($account, $repo) = $vars; + list($account, $repo, $moduleType) = $vars; if ($repo == 'silverstripe-frameworktest') { continue; @@ -100,20 +101,6 @@ public function process(bool $refetch): array }); $minorBranches = array_reverse($minorBranches); $majorBranches = array_reverse($majorBranches); - // remove any < 4 minor and major branches for linkfield - if ($repo == 'silverstripe-linkfield') { - $minorBranches = array_filter($minorBranches, function ($branch) { - return (int) $branch >= 4; - }); - $majorBranches = array_filter($majorBranches, function ($branch) { - return (int) $branch >= 4; - }); - // hack for linkfield which only has a `4` branch while it's in dev - // this is done so that `$minorBranches[0]` below passes - if (count($minorBranches) == 0) { - $minorBranches = ['4.0']; - } - } $nextPatBrn = ''; $nextMinBrn = ''; $pmMinBrn = ''; @@ -151,20 +138,22 @@ public function process(bool $refetch): array } }; - // remove any < 4 branches for linkfield - // note: this is not duplicated code from the other silverstripe-linkfield conditional above - if ($repo == 'silverstripe-linkfield') { - if ($pmMinBrn == '3') { - $pmMinBrn = ''; + // Don't show unsupported branches for regular repos + if ($moduleType == 'regular') { + if ($nextMajBrn && !$manager->getMajorBranchIsSupported($repo, $nextMajBrn)) { + $nextMajBrn = ''; + } + if ($nextMinBrn && !$manager->getMajorBranchIsSupported($repo, $nextMinBrn)) { + $nextMinBrn = ''; + $nextPatBrn = ''; + } + if ($pmMinBrn) { + $previousMajor = explode('.', $pmMinBrn)[0]; + if (!$manager->getMajorBranchIsSupported($repo, $previousMajor)) { + $pmMinBrn = ''; + $pmPatBrn = ''; + } } - } - - $skipCurrentMajor = false; - if (in_array($repo, [ - 'silverstripe-postgresql', - 'silverstripe-sqlite3' - ])) { - $skipCurrentMajor = true; } $runName = 'CI'; @@ -178,27 +167,27 @@ public function process(bool $refetch): array // next major 'nextMajBrn' => $nextMajBrn ? ($nextMajBrn . '.x-dev') : '', - 'nextMajGhaStat' => $nextMajBrn == '' - ? $this->buildBlankBadge() - : $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextMajBrn, $runName), + 'nextMajGhaStat' => $nextMajBrn + ? $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextMajBrn, $runName) + : $this->buildBlankBadge(), // current major '| ' => '', - 'nextMinBrn' => $skipCurrentMajor ? '' : $nextMinBrn . '.x-dev', - 'nextMinGhaStat' => $skipCurrentMajor - ? $this->buildBlankBadge() - : $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextMinBrn, $runName), - 'nextPatBrn' => $skipCurrentMajor ? '' : $nextPatBrn . '.x-dev', - 'nextPatGhaStat' => $skipCurrentMajor - ? $this->buildBlankBadge() - : $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextPatBrn, $runName), + 'nextMinBrn' => $nextMinBrn ? ($nextMinBrn . '.x-dev') : '', + 'nextMinGhaStat' => $nextMinBrn + ? $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextMinBrn, $runName) + : $this->buildBlankBadge(), + 'nextPatBrn' => $nextPatBrn ? ($nextPatBrn . '.x-dev') : '', + 'nextPatGhaStat' => $nextPatBrn + ? $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $nextPatBrn, $runName) + : $this->buildBlankBadge(), // prev major '|' => '', 'pmMinBrn' => $pmMinBrn ? ($pmMinBrn . '.x-dev') : '', 'pmMinGhaStat' => $pmMinBrn - ? ($this->getGhaStatusBadge($requester, $refetch, $account, $repo, $pmMinBrn, $runName)) + ? $this->getGhaStatusBadge($requester, $refetch, $account, $repo, $pmMinBrn, $runName) : $this->buildBlankBadge(), 'pmPatBrn' => $pmPatBrn ? ($pmPatBrn . '.x-dev') : '', diff --git a/app/src/Processors/IssuesProcessor.php b/app/src/Processors/IssuesProcessor.php index 2cb0702..43d6663 100644 --- a/app/src/Processors/IssuesProcessor.php +++ b/app/src/Processors/IssuesProcessor.php @@ -6,8 +6,8 @@ use App\Utils\DateTimeUtil; use App\Utils\MiscUtil; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Requesters\RestRequester; +use App\Misc\SupportedModulesManager; class IssuesProcessor extends AbstractProcessor { @@ -47,7 +47,8 @@ public function process(bool $refetch): array { $apiConfig = new GitHubApiConfig(); $requester = new RestRequester($apiConfig); - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $rows = []; diff --git a/app/src/Processors/MergeUpsProcessor.php b/app/src/Processors/MergeUpsProcessor.php index 99df0e5..010d0da 100644 --- a/app/src/Processors/MergeUpsProcessor.php +++ b/app/src/Processors/MergeUpsProcessor.php @@ -3,11 +3,11 @@ namespace App\Processors; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Requesters\AbstractRequester; use App\DataFetcher\Requesters\RestRequester; use SilverStripe\SupportedModules\BranchLogic; use SilverStripe\SupportedModules\MetaData; +use App\Misc\SupportedModulesManager; class MergeUpsProcessor extends AbstractProcessor { @@ -64,7 +64,8 @@ public function process(bool $refetch): array { $apiConfig = new GitHubApiConfig(); $requester = new RestRequester($apiConfig); - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $repoList = []; foreach (['regular', 'tooling'] as $moduleType) { diff --git a/app/src/Processors/OpenPrsProcessor.php b/app/src/Processors/OpenPrsProcessor.php index 695e023..a333cb0 100644 --- a/app/src/Processors/OpenPrsProcessor.php +++ b/app/src/Processors/OpenPrsProcessor.php @@ -7,10 +7,10 @@ use App\Utils\MiscUtil; use App\Utils\PullRequestUtil; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Misc\Logger; use App\DataFetcher\Requesters\GraphQLRequester; use stdClass; +use App\Misc\SupportedModulesManager; class OpenPrsProcessor extends AbstractProcessor { @@ -50,7 +50,8 @@ public function process(bool $refetch): array { $apiConfig = new GitHubApiConfig(); $requester = new GraphQLRequester($apiConfig); - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $rows = []; diff --git a/app/src/Processors/RecentMergedPrsProcessor.php b/app/src/Processors/RecentMergedPrsProcessor.php index b310cef..21b78c8 100644 --- a/app/src/Processors/RecentMergedPrsProcessor.php +++ b/app/src/Processors/RecentMergedPrsProcessor.php @@ -7,10 +7,10 @@ use App\Utils\MiscUtil; use App\Utils\PullRequestUtil; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Misc\Logger; use App\DataFetcher\Requesters\GraphQLRequester; use stdClass; +use App\Misc\SupportedModulesManager; class RecentMergedPrsProcessor extends AbstractProcessor { @@ -74,7 +74,8 @@ public function process(bool $refetch): array { $apiConfig = new GitHubApiConfig(); $requester = new GraphQLRequester($apiConfig); - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $rows = []; diff --git a/app/src/Processors/ReleasesProcessor.php b/app/src/Processors/ReleasesProcessor.php index 6c13b11..bfc7a0f 100644 --- a/app/src/Processors/ReleasesProcessor.php +++ b/app/src/Processors/ReleasesProcessor.php @@ -3,11 +3,11 @@ namespace App\Processors; use App\DataFetcher\Apis\GitHubApiConfig; -use App\DataFetcher\Misc\Consts; use App\DataFetcher\Requesters\AbstractRequester; use App\DataFetcher\Requesters\RestRequester; use App\Utils\DateTimeUtil; use stdClass; +use App\Misc\SupportedModulesManager; class ReleasesProcessor extends AbstractProcessor { @@ -85,7 +85,8 @@ private function getRequestor(): AbstractRequester private function deriveData(): array { - $modules = Consts::MODULES; + $manager = new SupportedModulesManager(); + $modules = $manager->getModules(); $rows = []; $varsList = [];