composer
composer copied to clipboard
php_version argument is ignored?
Hey,
I’m using following workflow to run my phpunit tests:
name: Pull Request
on: [pull_request]
jobs:
phpunit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
with:
php_version: 7.4
version: 2
- run: composer test
When I print out php version inside tests with phpversion()
or PHP_VERSION
, the output is 8.0.12
. I created a test print here, see "Run composer test" step. Am I using this action wrong or is it something in your action?
Thanks for the report. From a first glance it looks like there's a bug, which I'll work fast to fix as a patch on the v6 tag.
I'll let you know when I've investigated.
Cheers, Greg.
same problem for me
Any news? I still see the problem
Sorry, I've been totally busy with client work over the last couple of weeks. I'll bump this up my priority list to not take much longer.
same problem here
Are there any news? I am using this action to automatically create a zip with the prod code every time I create a new GitHub release and send it to a customer
Also, on the .bash code, I can see
if [ "$ACTION_VERSION" == "latest" ]
then
phar_url="${phar_url}/composer-stable.phar"
else
phar_url="${phar_url}/composer-${ACTION_VERSION}.phar"
fi
While there is no track of ACTION_PHP_VERSION
in the code.
So with the "version" var one could choose the composer version, whole the php_version var is not used at all in the bash code
I have seen now that it executes https://raw.githubusercontent.com/php-actions/php-build/330b13bbb1eadd05bbb627477c1549cd7e62e406/php-build.bash, which uses ACTION_PHP_VERSION, so I don't know why it wouldn't consider it
You guys (@euberdeveloper, @mbretter and @AttLii) are looking at two different PHP binaries actually:
- The step using
php-actions/composer@v6
builds its own PHP in a Docker container and this in fact correctly uses thephp_version
argument. - The
run: composer test
step invokes the PHP that comes with the Ubuntu that you get byruns-on: ubuntu-latest
.
You can easily confirm that by running the action from https://gist.github.com/mj/e6a81b52d72940fd8773a1264cf2da26.
That's a good shout, @mj. I wonder what you think would be the best idea to help people avoid this in the future? It might just be something for the documentation to deal with.
Is there a way to avoid this behaviour, I mean like use the specified version also for the run command?
This would be good for instance if you want to run more than a command with composer and the specified PHP version
I agree on this to be added to the documentation
The analysis by @mj seems correct - if you have a separate run
step, then it will use the PHP from the system. The solution is not to use a separate run
step to run Composer but instead to tweak the configuration of the php-actions/phpunit
step.
However, this is not the cause for the 8.1 vs 8.0 problem reported in #73. (Will elaborate there in a moment)
I have a solution that I've used on a project internally - we needed to test a live deployment succeeded, and this task required running an arbitrary command on the same PHP version that was used to deploy.
I used Docker to run the same image, and mounted the project directory as a volume... this isn't a very elegant solution, so I am planning on releasing a new repository to php-actions, "command" (or something named better...), which will work exactly like these other repos, but allow you to run arbitrary php scripts or shell commands within the same php-build container.
Let me know what you think, or any ideas you have for what to name this project and I'll put something together soon.
This functionality will be developed here: https://github.com/php-actions/command