-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feature: Use composer/semver
to detect PHP version ranges
#119
base: 1.23.x
Are you sure you want to change the base?
Conversation
bee5e98
to
15c66c4
Compare
…version ranges Signed-off-by: Maximilian Bösing <[email protected]>
15c66c4
to
de55ea6
Compare
Signed-off-by: Maximilian Bösing <[email protected]>
Signed-off-by: Maximilian Bösing <[email protected]>
@@ -25,6 +27,16 @@ ADD laminas-ci.schema.json /action/ | |||
COPY --from=compiler /usr/local/source/dist/main.js /action/ | |||
RUN chmod u+x /action/main.js | |||
|
|||
# Setup PHP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, what the fuck. But since I am not aware on how to actually merge multiple container together, I've thought I can do it like this.
This will:
- ensure that renovate is able to bump versions
- provide alpine PHP version within this container
- allows us to run PHP natively within the matrix container while the container itself is optimized for
nodejs
I hope we can keep it like this as I tried to install php8-cli
via apk
which is PHP 8.1.1 which is not supported by the "boxed" PHAR of my composer-semver
docker image...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the matrix container run any PHP? What happens with PHP 8.0 or PHP 7.4 runs? nm, I see where it's used now
@@ -5,9 +5,9 @@ | |||
}, | |||
"type": "commonjs", | |||
"devDependencies": { | |||
"@types/node": "^18.6.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you move this or a tool? Only I've seen tools move it the other way around before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this was due to a merge conflict. So maybe I did that.
@@ -25,6 +27,16 @@ ADD laminas-ci.schema.json /action/ | |||
COPY --from=compiler /usr/local/source/dist/main.js /action/ | |||
RUN chmod u+x /action/main.js | |||
|
|||
# Setup PHP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the matrix container run any PHP? What happens with PHP 8.0 or PHP 7.4 runs? nm, I see where it's used now
|
||
export function satisfies(version: string, constraint: string): boolean { | ||
try { | ||
execSync(`/usr/local/bin/composer-semver.phar semver:match "${version}" "${constraint}" > /dev/null`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some edge case differences between how composer and npm resolve semantic versions (or so I'm led to believe), but I don't see why we aren't using the official semver module used by npm https://www.npmjs.com/package/semver and not even require PHP here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, I know this PR is removing it and replacing it with composer, I'm just wondering why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do parse composer.json
, that file could provide constraints which are mostly supported by composer but i.e. not by the NPM package.
I have not tested this yet, but composer provides some quirks:
^v8.1.0
would be a valid constraint- Comma annotations are valid constraints (as outlined in Composer
php
constraints with,
are not supported #86)
There might be other quirks but since I do not want to hassle with these in this component since we should focus on detecting the correct supported version(s) based on what is supported by composer, we should use composers own logic to detect whats allowed and what not.
But thats just my opinion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That first one would be a valid constraint in node aswell FYI. I did look through the docs for both npm and composer and the comma vs space was the only one I found. Which IMO is npm's mistake here as I know of other examples where a comma is perfectly valid (e.g. go).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on this, I just would prefer not to manipulate the constraint to "make it work" 😅
But I am open for every other suggestion. Should we report this upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about calling the php container via docker here instead? I'm not that familiar with how DinD works on github specifically but something like:
execShell('docker run php /usr/local/bin/composer-semver.phar semver:match "${version}" "${constraint}" > /dev/null')
. After adding composer-semver
to the php container instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work; you're operating inside a container, so the container can not operate as a docker host.
As far as other suggestions... I don't have any. I used the NPM semver package originally, as I assumed it was compatible with how Composer handled semver. Knowing that they're different, we can either:
- Call on a PHP executable (as proposed here)
- Write our own TS utility that passes the same tests as composer/semver (lots more effort, plus it can go out-of-date)
It might make sense to re-do this action such that it uses a dedicated container where we use a PHP application, as we've done with the CI action and the automatic releases action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work; you're operating inside a container, so the container can not operate as a docker host.
Thats actually not true. It definitely works, I am just not sure if it works within GHA.
One has to mount the docker socket to the container tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still wondering if we should just report upstream that they can't handle ,
in the constraint?
Maybe its a fixable issue for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue opened npm/node-semver#468, we can see what they say
Everything checks out though. Looks good to merge if we decide to go down this route, but I'm not convinced its necessary. |
COPY --from=php /usr/local/etc/* /usr/local/etc | ||
COPY --from=php /usr/local/lib/php/* /usr/local/lib/php | ||
COPY --from=php /usr/lib/* /usr/lib | ||
COPY --from=php /lib/* /lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's these parts that worry me mixing the languages. if they both rely on a linked lib in different versions for instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar thoughts: would prefer a composer install
happening with our base image, but we can improve on that later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for composer install
, thats actually to execute the composer-semver.phar
I am building with https://github.com/boesing/composer-semver-docker
But the more I think about this, the more it annoys me that it has to be that hacky...
COPY --from=php /usr/local/etc/* /usr/local/etc | ||
COPY --from=php /usr/local/lib/php/* /usr/local/lib/php | ||
COPY --from=php /usr/lib/* /usr/lib | ||
COPY --from=php /lib/* /lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar thoughts: would prefer a composer install
happening with our base image, but we can improve on that later
@@ -0,0 +1,11 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of issue-86
, would it make sense to name this according to what it does?
I've raised an "issue" in the NPM semver implementation: |
As I understand it, that repository is for the typescript mappings for everything |
It appears there are some other differences, so I think we have to go this route after all. |
Description
By using composers own
composer/semver
library, we are able to detect PHP version ranges from almost every composer-compatible constraint.Fixes #87