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

NEW Start with lowest installer version for --prefer-lowest #97

Closed

Conversation

emteknetnz
Copy link
Member

Issue #93

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Why are we making a distinction between "installer" (aka core) modules and others?

Comment on lines +26 to +55
// list of modules that are required in either:
// - silverstripe/installer
// - silverstripe/recipe-cms
// - silverstripe/recipe-core
const INSTALLER_MODULES = [
// installer
'recipe-plugin',
'vendor-plugin',
'recipe-cms',
'silverstripe-simple',
'silverstripe-login-forms',
// recipe-cms
'recipe-core',
'silverstripe-admin',
'silverstripe-asset-admin',
'silverstripe-campaign-admin',
'silverstripe-versioned-admin',
'silverstripe-cms',
'silverstripe-errorpage',
'silverstripe-reports',
'silverstripe-siteconfig',
'silverstripe-versioned',
'silverstripe-graphql',
'silverstripe-session-manager',
// recipe-core
'silverstripe-assets',
'silverstripe-config',
'silverstripe-framework',
'silverstripe-mimevalidator',
];
Copy link
Member

Choose a reason for hiding this comment

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

These should be all of the modules which have isCore = true in repositories.json - no need to have a duplicate list here.

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 list isn't quite the same:

repositories.json - isCore:

developer-docs
admin
asset-admin
assets
campaign-admin
cms
config
errorpage
framework
graphql
installer
session-manager
recipe-cms
recipe-core
recipe-plugin
reports
siteconfig
vendor-plugin
versioned
versioned-admin
simple

Things in repositories.json not in INSTALLER_MODULES (this doesn't really matter):

developer-docs
installer

Things in INSTALLER_MODULES not in repositories.json (this matters):

login-forms
mime-validator

$isPreferLoweset = strpos($opts['composer_args'] ?? '', '--prefer-lowest') !== false;
$installerVersion = $this->installerVersion;
$cmsMajor = BranchLogic::getCmsMajor($this->repoData, $this->branch, $this->getComposerJsonContent());
if ($cmsMajor >= 5 && !$isInstallerModule && $isPreferLoweset && $installerVersion) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ($cmsMajor >= 5 && !$isInstallerModule && $isPreferLoweset && $installerVersion) {
if (!$isInstallerModule && $isPreferLoweset && $installerVersion) {

There's no reason to exclude CMS 4 here - those should all have compatible dependencies already (and if they don't, that's a problem)

Copy link
Member Author

@emteknetnz emteknetnz Jul 3, 2024

Choose a reason for hiding this comment

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

The reason it's excluded is because in the corresponding gha-ci PR each major will have the following minor releases:
x.0, x.1, x.2, x.3, x.4

The way this solution works it needs to start at x.0. CMS 4 goes all the was up to 4.13. I don't really want it to waste lots of time incrementing all the way up to x.13 if something just isn't going to install.

If CMS 4 does suffer from a --prefer-lowest incompatibility, it's not worth fixing at this point in its lifecycle. There's a simple work around of simply upgrade something else to get things to install.

Comment on lines +141 to +142
// gha-ci will increment the installer version higher if composer is unable to install
// and try installing again
Copy link
Member

Choose a reason for hiding this comment

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

For prefer-lowest it probably shouldn't increment the installer version - that goes against the entire point of using prefer-lowest.

Copy link
Member Author

@emteknetnz emteknetnz Jul 3, 2024

Choose a reason for hiding this comment

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

Incrementing installer is the entire point of this solution

It always starts off trying to using installer 5.0. If that fails to installs, then it attempts installer 5.1

This would have caught out the original issue that started all of this. That version of elemental has a framework dep of ^5, instead of ^5.1. What happened before is the --prefer-lowest builds were installing using a recent version of installer that included a version of framework that DID have the eagerLoad API (added in 5.1).

With this new solution it would have instead installed with installer 5.0, and this would have lead to the CI build going red because of the missing API called in the unit test and we'd see the issue.

With this solution, which the framework dep correctly being ^5.1 instead, it will fail to install with installer 5.0, then it will successfully install with installer 5.1. Which is what we want to test --prefer-lowest with because that's what the specified minimum version of framework/installer is.

Comment on lines +144 to +147
// Was going to use something like 5.2.x-dev, install 5.0.x-dev instead
$installerVersion = preg_replace('#^([0-9])\.[0-9]\.x-dev$#', '$1.0.x-dev', $installerVersion);
// Was going to use something like 5.x-dev, install 5.0.x-dev instaed
$installerVersion = preg_replace('#^([0-9])\.x-dev$#', '$1.0.x-dev', $installerVersion);
Copy link
Member

Choose a reason for hiding this comment

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

Should detect the lowest supported version based on the composer dependencies! That's what this is all about.

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 detection is done gha-ci rather than gha-generate-matrix

Makes far more sense to use composer to work out what's installable and what's not rather than trying to work out what's installable and what's not by looking at composer.json files in gha-generate-matrix

@emteknetnz emteknetnz closed this Jul 3, 2024
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