Use roave/better-reflection to guess packages#346
Use roave/better-reflection to guess packages#346DanielBadura wants to merge 5 commits intomaglnet:4.1.xfrom
Conversation
| $cleanPath = preg_quote(sprintf('%s/vendor', str_replace(DIRECTORY_SEPARATOR, '/', $installationPath)), '@'); | ||
| $this->pathRegex = sprintf('@^%s/(?:composer/\.\./)?([^/]+/[^/]+)/@', $cleanPath); |
There was a problem hiding this comment.
I'm not sure for this regex tbh. Is there a way to get the name from the composer.json maybe?
There was a problem hiding this comment.
Getting the name from composer.json would be best, since the path will break anyway, due to people doing ugly things like changing the location of the vendor dir 🤔
There was a problem hiding this comment.
Is there already a way to get the name from the composer.json?
There was a problem hiding this comment.
each composer.json must have a "name" property, in order to be valid.
There was a problem hiding this comment.
So i reused now the regex but to get the composer.json and load it via the JsonLoader already present in this lib.
Im not sure if this is now really better since we are still using a regex but also have now more I/O which impacts performance. But since this is a CI tool i think the performance aspect could be overlooked.
|
I would add some more tests the next days |
| } | ||
| } | ||
|
|
||
| public function addGuesser(Guesser $guesser): void |
There was a problem hiding this comment.
Let's avoid introducing mutability here: instead, let's use a new constructor argument?
There was a problem hiding this comment.
Optional or not: the BC break from using roave/better-reflection by default will probably be notable anyway, so we can potentially break BC here, and release in 5.0.0
There was a problem hiding this comment.
Could you explain why adding the dependency would lead to a BC break?
Yeah, would go for the argument too.
There was a problem hiding this comment.
Potentially because scanning behavior changes => new symbols detected (or missed) => CI failure for consumers that upgrade.
There was a problem hiding this comment.
Maybe I misunderstand: But we are not detecting here more / new symbols, we just give here a hint which dependency should be installed to get rid of the warning, no?
There was a problem hiding this comment.
I removed the mutability but still i dont get why we already break BC with using better-reflection. Maybe you could explain it more?
| $cleanPath = preg_quote(sprintf('%s/vendor', str_replace(DIRECTORY_SEPARATOR, '/', $installationPath)), '@'); | ||
| $this->pathRegex = sprintf('@^%s/(?:composer/\.\./)?([^/]+/[^/]+)/@', $cleanPath); |
There was a problem hiding this comment.
Getting the name from composer.json would be best, since the path will break anyway, due to people doing ugly things like changing the location of the vendor dir 🤔
src/ComposerRequireChecker/DependencyGuesser/GuessFromInstalledComposerPackages.php
Outdated
Show resolved
Hide resolved
|
|
||
| public function __construct(string $installationPath) | ||
| { | ||
| $this->sourceLocator = new MemoizingSourceLocator((new MakeLocatorForInstalledJson())( |
There was a problem hiding this comment.
This locator does not include PHP symbols
There was a problem hiding this comment.
I just realized that this is potentially also broken in roave/backward-compatibility-check :|
There was a problem hiding this comment.
Not quite sure but dont we have for the php internal stuff the other guesser?
There was a problem hiding this comment.
Possibly, but BetterReflection can also reflect all of that, heh :D
There was a problem hiding this comment.
I would say, follow up PR, if wanted.
…pendencies which was tried to be guessed
|
Would need to kill some Mutants next 🗡️ |
|
I realised that the patch introduced alot of skipped mutants: This result is taken this PR and the action here
Ref: https://github.com/maglnet/ComposerRequireChecker/runs/4844758145?check_suite_focus=true Before this patch, there werent so many skipped mutants see here the result from the latest run. This is taken from the latest infection run
Ref: https://github.com/maglnet/ComposerRequireChecker/runs/4794435067?check_suite_focus=true So i increased lokally the config for timeout from @Ocramius do you think this comes from the slowness of better-reflection or loading of composer.json's? Or did we something wrong with configuring infection? |
…ch seems the increase the runtime the mutation dramatically
|
Just pushed the increase of the config to create the result with the workflow. |
|
That timing seems extreme 😱 Could it be that coverage makes it so steep? What is the PHPUnit runtime, without mutations, but with coverage? |
|
Takes nearly 2 minutes. But i must say: im running docker on mac so, its slow per default :D |
|
So finally i had time to do the measurements! 🥳 I did this on a ubuntu system and running with a php docker image. PHPUnit with NO coverage: Time 01:35.442
PHPUnit with coverage, pcov: Time 02:03.485
Infection 30 Seconds Timeout: Time 2m 32s
Infection 60 Seconds Timeout: Time 2m 29s
Infection 90 Seconds Timeout: Time 39m 25s
Then i checked out 4.1.x and runned some tests: PHPUnit with NO coverage: Time 00:17.724
PHPUnit with coverage, pcov: Time 00:23.006
Infection 30 Seconds Timeout: Time 14m 26s
So this patch slowes down the project ALOT. 😅 |
That's ~2 times the slowdown, which is much better than what I expected anyway :D |
|
If you compare the phpunit calls without coverage or with coverage it's more then a 2 times slowdown, it's roughly 5 times: no coverage: ~95 seconds vs ~18 seconds. So you mean this is fine? I'm not sure about that, seems alot even for a CI tooling. |
|
Yes, IMO this is mostly fine: coverage slows down userland stuff by a gazillion times, so that's understandable. What I'm most worried about is usage of the tool, not the CI of this tool itself. I'm very much used to waiting 15m~4h for a build: that doesn't scare me. What is more worrisome is how much this has an impact on large codebases, such as Magento or similar :) |
|
Well i tried to check it at the actual magento dev branch. |
|
Heh, makes sense 😬 |
|
WDYM makes sense? I mean i understand the error, since the package defined the tests in the normal autoload for whatever reason and does not export them. So i tried symfony as the repo and got these results: Without patch: 1m19.056s Here the complete result with the guessed packages
|
|
Besides the empty lines (?!?!?!), that looks like an excellent result, and 3.5m seems OK too. As for magento having incorrrect mappings, IMO that is an actual bug to be solved on their end :D |
|
(TBH, I expected a much bigger slowdown!) |
|
So my points that i need clearyfication are:
After that, the patch should be ready.
That confused me too.
Yeah but this is not magento here at fault but a third party package AFAIK. EDIT: and already fixed since 2 years... 😕 : https://github.com/Lusitanian/PHPoAuthLib/blob/master/composer.json#L57 |
| )); | ||
|
|
||
| $cleanPath = preg_quote(sprintf('%s/vendor', str_replace(DIRECTORY_SEPARATOR, '/', $installationPath)), '@'); | ||
| $this->pathRegex = sprintf('@^%s/(?:composer/\.\./)?([^/]+/[^/]+)/@', $cleanPath); |
There was a problem hiding this comment.
Mentioned by @DanielBadura in #346 (comment) - hacky as heck, so we may need to check this
There was a problem hiding this comment.
I thought about this now quite some time and I didnt came up with another solution :/
|
@maglnet before we throw these major architectural changes in, perhaps you need to review and discuss this too :D
Fine for me - again, CI runs are not very problematic here.
We can really release a new major just to be safe - not a problem.
Agreed: they haven't released that fix yet, but perhaps I can poke someone about it :) Alternatively, we can improve |
|
Thanks for all this work, I hope I can take a deeper look on the weekend. |
Must have been a really long weekend 😁 Any updates? |
This is an updated version of #162 and should also resolve #91
Should fix #345 #280 #52