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 Use supported modules repo for branch-based logic #87

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Apr 29, 2024

@GuySartorelli GuySartorelli marked this pull request as draft April 29, 2024 02:38
@GuySartorelli GuySartorelli force-pushed the pulls/1/use-supported-modules-repo branch 9 times, most recently from 14002c3 to a2f5fca Compare May 2, 2024 03:42
Comment on lines -1025 to +1013
github_repository: 'silverstripe/installer'
github_repository: 'silverstripe/fake-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.

Note that silverstripe/installer was incorrect here, and all the tests for this are assuming therefore that this is effectively some random repo in the silverstripe org. I felt it's best to preserve those tests as they are and explicitly indicate that this is just a random repo.

The alternative is to rename this to silverstripe/silverstripe-installer here but that fundamentally changes what's being tested. I think it's better that this works for any-old-random-repo rather than that it specifically works for installer.

Comment on lines -638 to +626
'dev-4.10-release'
'4.11.x-dev'
Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed all of the logic for -release branches and removed most scenarios that tested against them - but I've kept this one (and just updated the expected value accordingly) so we do still have some check against what would happen with a branch with that suffix.

Comment on lines -251 to +240
private function getBranchName(): string
private function getInstallerBranch(): string
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to be clearer what this actually is - it's not the branch name in the repo, it's the name of the branch of installer that will be pulled in via composer.

Comment on lines -31 to +39
if (in_array($this->repoName, NO_INSTALLER_LOCKSTEPPED_REPOS) || in_array($this->repoName, NO_INSTALLER_UNLOCKSTEPPED_REPOS)) {
if (!$this->needsInstallerVersion()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This change exits earlier under any scenario where we don't need installer for this repo.
Previously we had scenarios where we'd get through a bunch of this method only to hit a return '' - now it does most of the relevant checks upfront.

This is mostly unrelated refactoring, but made the rest of it a lot easier to debug and refactor the relevant stuff.

Comment on lines +702 to +714
{
if (!$this->composerJsonContent) {
if (!file_exists($this->composerJsonPath)) {
return null;
}
$this->composerJsonContent = json_decode(file_get_contents($this->composerJsonPath));
if ($this->composerJsonContent === null) {
throw new RuntimeException('Could not decode composer.json - last error was: ' . json_last_error_msg());
}
}
return $this->composerJsonContent;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously we were decoding the file multiple times at different stages - now we just decode it once, whenever the first time is that we need it, and use that same decoded result every time.

hardcoded.php Outdated
Copy link
Member Author

Choose a reason for hiding this comment

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

Checked this by commenting out the 5.2 in consts and ran this with the 5.2.0 copy of .cow.pat.json

Comment on lines -106 to +99
$installerVersions = array_diff($installerVersions, ['4', '5', '6', '7', '8', '9']);
// get the minor portions of the verisons e.g. [9, 10, 11]
$installerVersions = array_filter($installerVersions, fn ($v) => !ctype_digit((string) $v));
// get the minor portions of the versions e.g for ['4.9', '4.10', '4.11'] this returns [9, 10, 11]
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated refactoring that makes this more robust - we don't care about those specific values, we just care whether the value is a major (all digits) or not.

@GuySartorelli GuySartorelli force-pushed the pulls/1/use-supported-modules-repo branch 2 times, most recently from 89dcff5 to 840b80e Compare May 3, 2024 00:30
action.yml Outdated
rm ${{ github.action_path }}/composer.lock
fi
if [[ -d ${{ github.action_path }}/vendor ]]; then
rm -r ${{ github.action_path }}/vendor
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
rm -r ${{ github.action_path }}/vendor
rm -rf ${{ github.action_path }}/vendor

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't be necessary since we're not doing a --prefer-source - but done nevertheless since it doesn't hurt anything I think.

composer.json Outdated
@@ -0,0 +1,14 @@
{
"require-dev": {
Copy link
Member

Choose a reason for hiding this comment

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

require-dev should be below require, just cos :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

That 1000000000% does not matter, but I'll make that change to humour you since I have to touch this file anyway. :p

composer.json Outdated
"phpunit/phpunit": "^9.6"
},
"require": {
"silverstripe/supported-modules": "dev-pulls/main/combine-all-versions"
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
"silverstripe/supported-modules": "dev-pulls/main/combine-all-versions"
"silverstripe/supported-modules": "dev-main"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, that'll be done once the PR for that fork is merged, so we can easily rerun CI here against that PR to see it go green if changes are needed over there.

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

composer.json Outdated
Comment on lines 8 to 7
"repositories": {
"silverstripe/supported-modules": {
"type": "vcs",
"url": "[email protected]:creative-commoners/supported-modules.git"
}
}
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
"repositories": {
"silverstripe/supported-modules": {
"type": "vcs",
"url": "[email protected]:creative-commoners/supported-modules.git"
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussion in #87 (comment)

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

@GuySartorelli GuySartorelli force-pushed the pulls/1/use-supported-modules-repo branch from 840b80e to 4b44f91 Compare May 6, 2024 02:14
@GuySartorelli GuySartorelli force-pushed the pulls/1/use-supported-modules-repo branch from 4b44f91 to d7e9094 Compare May 6, 2024 21:49
@GuySartorelli GuySartorelli marked this pull request as ready for review May 6, 2024 21:49
@emteknetnz emteknetnz merged commit 1dfa92a into silverstripe:1 May 6, 2024
4 checks passed
@emteknetnz emteknetnz deleted the pulls/1/use-supported-modules-repo branch May 6, 2024 23:22
@emteknetnz
Copy link
Member

@GuySartorelli Remember to create a new minor branch and manually tag

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