Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Update reference to supported modules data #45

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented May 8, 2024

Comment on lines 129 to 131
if (isset($repoData['type'])) {
return $repoData['type'] === 'recipe';
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type key is only available for repos in the "supportedModules" category - but e.g. testing-recipe is a recipe so we need to still check the old way as well.

Same idea with all other changes below checking type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we even need to use the supported-modules repositories.json as the source of truth instead of composer.json of each module? Nothing was broken before?

Ditto for all the other updates in the PR doing the same e.g. is_module()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just feels more correct. I'll remove it if you insist, but I don't see any reason to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say remove it, it's confusing as to why we'd need two methods.

Having it here and then having a fallback of composer.json looks just like we don't trust supported-modules to be correct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks just like we don't trust supported-modules to be correct

A comment could easily solve that lol. I'll remove it just to avoid ping pong, I think either way the result ends up being the same so it doesn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines -246 to +254
global $MODULE_DIR;
return !is_module() && strpos($MODULE_DIR, '/gha-') !== false;
global $GITHUB_REF;
return in_array(
$GITHUB_REF,
array_column(
MetaData::getAllRepositoryMetaData()[MetaData::CATEGORY_WORKFLOW],
'github'
)
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gha-* repos are in the workflow category, and nothing else is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should revert this, this one is like is_module() where we're not using MetaData as source of truth. This function is specifically for gha repos, and the naming convention on gha- will always be there, though there is some chance someone will put in a non-gha workflow file in the workflow section of repositories.json.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason we're not using MetaData in is_module() is because there might be repositories in other categories which are also modules, so we need to fall back on composer.json values.

This function is different. There's no need to fall back on anything, everything we need to know is in the CATEGORY_WORKFLOW category. All of the repositories in that category are the "gha-*" repositories. Nothing else is in that category. This is robust, and is much better than checking against a naming convention.

there is some chance someone will put in a non-gha workflow file in the workflow section of repositories.json.

If they do that, they're doing the wrong thing.
The same can be said of naming conventions - there is a chance someone could make a workflow repository that doesn't follow the naming convention, or could make another repository that accidentally starts with "gha-".

Both of those are a low chance and aren't worth considering IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, the whole reason that category even exists in the file is so you can tell if something's a gha repo by just checking if it's in that category.

Comment on lines -296 to +304
$s = read_file('.git/config');
if (!preg_match('#github.com:([^/]+)/#', $s, $matches)) {
error('Could not determine github account');
}
return $matches[1];
global $GITHUB_REF;
return explode('/', $GITHUB_REF)[0];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check .git - we have this information ahead of time.

Comment on lines -86 to -93
function extra_repositories()
{
$importantRepos = [
'silverstripe/markdown-php-codesniffer',
'silverstripe/silverstripe-standards',
'silverstripe/documentation-lint',
'silverstripe/.github',
];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set of "extra" repos we're gonna end up with after this change is a lot bigger than we were getting before. I've added a note to silverstripe/.github#242 that when this gets run next we should take care to check if there's anything we want to skip and add an exclude list if there is.

Comment on lines -362 to 286
// Some repositories don't have a valid matching CMS major
$ignoreCMSMajor = [
'/silverstripe-simple',
'/markdown-php-codesniffer',
];
foreach ($ignoreCMSMajor as $ignore) {
if (strpos($MODULE_DIR, $ignore) !== false) {
return CURRENT_CMS_MAJOR;
}
// This repo matches every major and matches start at the lowest - but we only want the highest stable.
if ($GITHUB_REF === 'silverstripe/silverstripe-simple') {
return MetaData::HIGHEST_STABLE_CMS_MAJOR;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markdown-php-codesniffer will get correctly identified - but the theme still needs some help.

@GuySartorelli GuySartorelli force-pushed the pulls/main/new-supported-modules branch from 91210a7 to f7d6f2d Compare May 8, 2024 04:37
funcs_utils.php Outdated Show resolved Hide resolved
funcs_utils.php Outdated Show resolved Hide resolved
funcs_utils.php Outdated Show resolved Hide resolved
Comment on lines 129 to 131
if (isset($repoData['type'])) {
return $repoData['type'] === 'recipe';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we even need to use the supported-modules repositories.json as the source of truth instead of composer.json of each module? Nothing was broken before?

Ditto for all the other updates in the PR doing the same e.g. is_module()

funcs_scripts.php Outdated Show resolved Hide resolved
Comment on lines 129 to 131
if (isset($repoData['type'])) {
return $repoData['type'] === 'recipe';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say remove it, it's confusing as to why we'd need two methods.

Having it here and then having a fallback of composer.json looks just like we don't trust supported-modules to be correct

@GuySartorelli GuySartorelli force-pushed the pulls/main/new-supported-modules branch from 8123501 to d80e9f7 Compare May 9, 2024 04:17
Comment on lines -246 to +254
global $MODULE_DIR;
return !is_module() && strpos($MODULE_DIR, '/gha-') !== false;
global $GITHUB_REF;
return in_array(
$GITHUB_REF,
array_column(
MetaData::getAllRepositoryMetaData()[MetaData::CATEGORY_WORKFLOW],
'github'
)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should revert this, this one is like is_module() where we're not using MetaData as source of truth. This function is specifically for gha repos, and the naming convention on gha- will always be there, though there is some chance someone will put in a non-gha workflow file in the workflow section of repositories.json.

@emteknetnz emteknetnz merged commit c42e9b4 into silverstripe:main May 9, 2024
1 check passed
@emteknetnz emteknetnz deleted the pulls/main/new-supported-modules branch May 9, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants