phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Use composer.json/lock PHPUnit version

Open westy92 opened this issue 2 years ago • 10 comments

Either by default or with a new option, use the PHPUnit version specified in the repo's composer.json/lock file.

westy92 avatar Apr 28 '23 05:04 westy92

This is currently possible by specifying the vendored_phpunit_path option, but seeing as you're not the first to ask about this, I think there should be a better way.

Here's what I propose: a new value to version, so you don't specify 10.1 or latest, but you can specify composer to get what you want.

Also, I think it makes sense to change the default value for the version input to composer. What do you think?

g105b avatar Apr 28 '23 12:04 g105b

Thanks for the quick response! I think having a default composer version option is a great solution.

westy92 avatar Apr 28 '23 15:04 westy92

I agree, I'm amazed I didn't think of this before - not everyone always wants/expects the latest version of these tools.

Thanks for the report. I'll get it into action as soon as I can.

g105b avatar Apr 28 '23 16:04 g105b

I thought of it because my builds on PHP 8.0 kept falling even though I have PHPUnit 9.x in my config. Then I looked at the logs and saw this was using the latest. For now I'm hardcoding the version to '9' to match my dependency version. Thank you for jumping right into this. Feel free to tag me for PR review.

westy92 avatar Apr 28 '23 19:04 westy92

Just keeping you in the loop on the development of this.

I thought I'd implement on my lesser-used https://github.com/php-actions/phpstan repository to test some real world impacts. There are a few issues already cropping up from people who use non-standard bin directories, different composer configurations, etc. so I'm glad I didn't implement my naive solution too quickly.

I will work through the issues and eventually make a v4 release to this Action.

g105b avatar May 02 '23 13:05 g105b

You could add the option in v3 and make it the default in v4, right? Or maybe never make it the default but make it clear and obvious how and when to use it.

westy92 avatar May 02 '23 14:05 westy92

Yep, good idea. Still need to make sure things don't break but I'll add it as an optional change in v3.

g105b avatar May 02 '23 16:05 g105b

This has been implemented in the test branch composer-version--user. Please read https://github.com/php-actions/phpunit/issues/51#issuecomment-1723958575 for more information on how to test - your feedback is appreciated.

g105b avatar Sep 18 '23 21:09 g105b

@g105b this works nice for me. Can we expect a release with this fix in the near future?

jacek-jablonski avatar Mar 04 '24 12:03 jacek-jablonski

Yes, I'll make a PR later today. Thank you for testing.

g105b avatar Mar 04 '24 13:03 g105b

I'm picking this up out of necessity. I ran into this issue here: https://github.com/PhpGt/Dom/pull/454

g105b avatar Apr 25 '24 16:04 g105b

V4 release made that includes all the latest changes. You can see in PHP.Gt/Dom that the tests are passing nicely. Thanks to everyone here for chipping in :)

g105b avatar Apr 25 '24 16:04 g105b