-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Proxy bin file regression in 2.2.0 #10387
Comments
Seeing a similar issue trying to run psalm.
|
We do have a similar issue on PrestaShop CI We have narrowed down the problem. PR #10137 is believed to be the root cause as mentioned by @jenkoian. When running PrestaShop phpunit suite test, we used It seems a combination of
In the short term, we work around the issue by running our test suite using the real phpunit binary |
This should not happen in the latest iteration of the bin proxy code unless perhaps if you have stream_wrapper_register in disable_functions? Or if there's a bug I suppose. It'd be good if those able to repro could investigate why it doesn't do the include using stream wrapper inside the bin proxy file. BTW another mitigation to this is upgrading to php 8.. |
Another point would be to make sure you have the latest proxy code by removing the proxy files and running composer install again, altho I doubt that's the problem if you first saw the regression after upgrading to composer 2.2.0 @GrahamCampbell that seems like an unrelated issue that I've never seen, maybe best report it separately. |
Indeed if stream_wrapper_register is disabled you'll see this error. I don't know what else would trigger it, nor why you'd have stream wrappers disabled.. With the composer.json from OP I see this:
|
maybe the generated proxy should check for that case |
@Seldaek I have 2 different results when disabling
|
Added a GH workflow to run the reproduction against various PHP versions: https://github.com/jenkoian/composer-issue-10387/runs/4616783070?check_suite_focus=true It seems to fail on PHP8(.1) as well but for a different reason (times out). |
@Seldaek yes we do! |
If it helps I added a |
Yeah this isn't related to stream_wrapper_register IMO, otherwise it would fail without even starting PHPUnit. It seems to break the PHPUnit process isolation but I am not entirely sure how/why yet. |
@Seldaek good spot with the process isolation, I didn't even notice that, but did copy the phpunit config from the project I was seeing the issue. Can confirm it works just fine if I set that to false. |
Ok padded out the workflow a bit, hope it helps https://github.com/jenkoian/composer-issue-10387/actions/runs/1615203291 |
It seems the global state collection/restore process of PHPUnit includes all included files again which includes phpunit itself then because we now include it instead of running it directly. I got a "fix" here by adding Will keep digging a bit to see if I find a better way to solve this. |
OK I think the workaround should work, feel free to give it a shot with |
Confirmed! https://github.com/jenkoian/composer-issue-10387/actions/runs/1615405186 Many thanks 🙏 |
Composer versions 2.2.0 and 2.2.1 have a bug that breaks PHPUnit. Until version 2.2.2 is released with a fix, we need to keep to Composer 2.1 to keep the tests from breaking. See composer/composer#10387 for details.
2.2.2 is now out with this fix 👍🏻 |
Both Composer, as well as PHPUnit have released new versions to try and fix the issue with tests being run with process isolation, which were resulting in the following error: ``` PHPUnit\Framework\Exception: PHP Fatal error: strict_types declaration must be the very first statement in the script in /home/runner/work/BrainMonkey/BrainMonkey/vendor/phpunit/phpunit/phpunit on line 2 ``` While that fixes the builds for runs against the `highest` versions of dependencies, it still does not solve the problem when running the tests with the `lowest` dependencies. Build against the `lowest` dependencies now hang indefinitely. This commit attempts to fix this by using Composer 2.1 for builds against `lowest` dependencies. It also sets a 15 minute time-out for the test runs against the `lowest` dependencies to prevent builds being very slow in reporting. Refs: * composer/composer#10387 * sebastianbergmann/phpunit#4846 * https://github.com/composer/composer/releases/tag/2.2.2 * https://github.com/sebastianbergmann/phpunit/blob/9.5/ChangeLog-9.5.md#9511---2021-12-25
Both Composer, as well as PHPUnit have released new versions to try and fix the issue with tests being run with process isolation in combination with installation via Composer 2.2, which were resulting in the following error: ``` PHPUnit\Framework\Exception: PHP Fatal error: strict_types declaration must be the very first statement in the script in /home/runner/work/BrainMonkey/BrainMonkey/vendor/phpunit/phpunit/phpunit on line 2 ``` While that fixes the builds for runs against the `highest` versions of dependencies, it still does not solve the problem when running the tests with the `lowest` dependencies (or against PHP 5.6). Those builds now hang indefinitely. This commit attempts to fix this by using Composer 2.1 for builds against `lowest` dependencies and against PHP 5.6. It also sets a 15 minute time-out for the test runs against the `lowest` dependencies to prevent builds being very slow in reporting. Refs: * composer/composer#10387 * sebastianbergmann/phpunit#4846 * https://github.com/composer/composer/releases/tag/2.2.2 * https://github.com/sebastianbergmann/phpunit/blob/9.5/ChangeLog-9.5.md#9511---2021-12-25
Thank you all for all your work on this. Unfortunately, this still doesn't solve the problem for packages where PHPUnit is a non-dev dependency and a range of PHPUnit versions is supported. Case in point: the BrainMonkey test utilities package. While running the CI with For now, I'm "fixing" this for the BrainMonkey CI by using Composer 2.1 when running with |
@jrfnl iirc my commit should fix it for phpunit 6.x (not sure from which minor/patch) and above, but earlier releases do not have the global var to exclude files from being included so for those I think projects would have to mark the I am hoping the amount of projects still using such old phpunit versions combined with proc isolation will be small enough that this is manageable on a case by case basis. |
Thanks for your reply @Seldaek.
Ah! That explains the outlier on PHP 5.6 I was seeing (using PHPUnit 5.x)
Would this work-around also work when using a Composer script ? I know of quite a few projects using scripts like the below to have things execute on the same PHP version as used by Composer (which may not be the system default), so the issue would not exist for any of those (which would be great!). "scripts": {
"test": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
} (For anyone wondering why this doesn't use
Well, considering WP is still insisting on a PHP 5.6 minimum (yeah, I know, I'm trying to change it, but there's lots of resistance), I fear that amount of projects may be larger than expected... |
OK I dug up some more info:
|
@Seldaek That sounds awesome! I'm going to set up a complete test run for BrainMonkey now and am keeping my fingers crossed 🤞🏻 |
@Seldaek Test run finished, definitely an improvement, but there's still some tweaks needed. Seeing the below on PHP 7.4 with
And this on PHP 7.4 with
And it looks like the builds on PHP 5.6 (both) and PHP 7.0/7.1 with Doing a run with |
Just to share that with 2.2.2 (without the extra hackery, I think) we have started to get a number of "old" branches (still using phpunit 7.5, that's the "oldest" we use) , only with php74, some parse errors: https://github.com/stronk7/moodle/runs/4668195077?check_suite_focus=true And, with current phpunit 9.5.x... also a good number of php warnings with php73:
https://github.com/paulholden/moodle/runs/4666343704?check_suite_focus=true Both seem to be related to the changes here... and they weren't happening before yesterday (2.2.2 release). Ciao :-) |
… error when the returned file size is bigger than the fstat size, refs #10387
OK 164a769 should fix the parse errors and 09d1330 the is_file warnings. This is getting really nasty IMO but I'm hoping we at least are getting close to a complete solution. cc @johnstevenson if you also want to try your tests again |
@Seldaek ❤️ I'm re-running the build for BrainMonkey now: https://github.com/Brain-WP/BrainMonkey/runs/4668635915 Looks like the PHP 7.4 failures no longer break the builds, but I'm seeing a lot warnings on all PHP 7.2, 7.3 and 7.4 builds:
Test runs against PHPUnit 5.x still hang indefinitely though (both PHP 5.6 builds, PHP 7.0/7.1 with |
Huh.. really curious where that is coming from but won't have time to dig in tonight I am afraid. I can't repro the hanging on PHPUnit 5.7.26 though :/ May have to try to reproduce exactly your build steps from CI and hopefully that triggers it. |
@Seldaek I can confirm this fixes the parsing errors in PHP 7.4 (and upwards, though not relevant here). Nice trick with |
No worries. I really appreciate all you are trying to do to mitigate the fall-out of Composer 2.2.
Please let me know if there's anything I can do to help with this. The CI script is actually pretty straight-forward, but the repo is combining a number of test utilities (Patchwork, Mockery and BrainMonkey native), so that may be making things more complex. Let me do a test run with WP Core with the current dev version of Composer. I heard they were having some issues with PHP 5.6/PHPUnit 5.x builds as well. |
Not seeing any failures on any of the PHP 5.6 with PHPUnit 5.7.27 jobs on WP Core at the moment, so at least, that's one less thing to worry about ;-) |
…er to try and access other files, refs #10387
Yes and no ;) I am sure this would have been more stressful with everyone at work freaking out at the same time.
75e4d30 fixes the warnings coming from Patchwork. I still cannot reproduce the hanged phpunit run locally with PHP 5.6. I have all the exact same dependencies as your 5.6 highest build installed, but somehow it runs fine.
|
2.2.3 is out now - let's hope we can finally put this issue behind for good 😄 |
@Seldaek I can't say it enough: thanks for all your work on resolving this! ❤️ I've just rerun the BrainMonkey |
Seems to be a regression in 2.2.0 (since RC-1 sorry for not testing earlier 😞 ) which can be summarised as a reintroduction of this bug: #10246 which I think was caused by this PR: #10137
Reproduction repo: https://github.com/jenkoian/composer-issue-10387
My
composer.json
:Output of
composer diagnose
:When I run this command:
I get the following output:
And I expected this to happen:
The text was updated successfully, but these errors were encountered: