Portable phpunit script
The source repo contains a
phpunit script that wraps executing a docker container to execute phpunit. The current directory is mounted into
/src in the container and a wrapper script executes
phpunit as a user who's
gid matches those properties on that directory. This way any output is written as the directory owner/group instead of root or a random user.
Because this runs out of a Docker container, all code required by your tests must be available within the current directory. Including files from other directories on the system will not work. The simplest solution is to use Composer to install any dependencies.
This assumes that you already have Docker installed. A running
docker daemon is required.
Installation is just a matter of putting the shell script somewhere in your path and making it executable. I like to put my scripts in a
bin/ folder in my home directory:
wget -nv -O ~/bin/phpunit https://raw.githubusercontent.com/mkenney/docker-phpunit/php5/bin/phpunit && chmod 0755 ~/bin/phpunit
wget -nv -O ~/bin/phpunit https://raw.githubusercontent.com/mkenney/docker-phpunit/master/bin/phpunit && chmod 0755 ~/bin/phpunit
self-updatecommand pulls down the latest docker image and then updates the shell script itself. If you don't have write permissions on the shell script you'll get a permissions error, you can run the self-update command with
Based on mkenney/php-base (debian:jessie) which is simply a php CLI binary built with various tools, most notably Oracle OCI libraries, because they're a pain to install.
I have re-enabled automated Docker Hub builds, with a small difference. Docker builds are no longer triggered by GitHub pushes, instead they are triggered by a deployment script that is executed on successful
travis-ci builds. This way, even if builds are failing the image on DockerHub should remain the last stable image at all times.
There may be an issue with API call throttling on the Docker Hub side, if that seems to be happening I'll dig in further.
Please let me know if you have any problems.
I have created a
travis-ci integration that should prevent the issue brought to my attention yesterday. The validation is extremely simple (it just makes sure that phpunit executes successfully). I also disabled automated Docker Hub builds and added a build trigger to the travis-ci integration so no bad builds should accidently make it to Docker Hub.
Let me know if anything unexpected happens or if you uncover any other issues and I will add validation checks to the build.
I received a pull request to fix an issue caused by an upstream change. I merged the request into both project branches and all appears to be working correctly to me, however I need to prevent this issue from coming up again. I created an issue to address this going forward and I should have it implementd by next week.
My appologies for any inconvenience the recent unstable builds may have caused. If anyone has any trouble, please let me know.