php-actions / phpunit

Run PHPUnit tests in Github Actions.
106 stars 23 forks source link

Use composer.json/lock PHPUnit version #54

Closed westy92 closed 2 months ago

westy92 commented 1 year ago

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

g105b commented 1 year ago

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?

westy92 commented 1 year ago

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

g105b commented 1 year ago

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.

westy92 commented 1 year ago

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.

g105b commented 1 year ago

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.

westy92 commented 1 year ago

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.

g105b commented 1 year ago

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

g105b commented 10 months ago

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.

jacek-jablonski commented 4 months ago

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

g105b commented 4 months ago

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

g105b commented 2 months ago

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

g105b commented 2 months ago

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 :)