Bulgaria PHP Conference was great

The weekend of 7 - 9 october some Troviters attend the Bulgaria PHP Conference. Now I can say that I have new favorite php conference in Europe. Everything was amazing, great talks, great speakers and a lot of ideas and new things that I want to try in my projects.

We stay in the legends hotel which is near Sofia Events Center. At the Hotel we met Composer’s creator and some of the Speakers.

The first day at the hall of the hotel we met Michelangelo van Dam he is a Senior PHP Architect and leader at PHP Benelux.

The talk was about run your unit test using docker and parallelise to make them faster. (slides)

In the talk he explain, that we can run the test faster running each phpunit group in parallel using gnu parallels and docker.

Here are some steps to figure out.

Get all the phpunit groups:

for i in `./vendor/bin/phpunit -c build/phpunit.xml --list-groups | grep "^ -" | 
awk {'print $2'}`; do ./vendor/bin/phpunit -c build/phpunit.xml --group $i; done

Run all the unit test using docker:

docker run -ti --rm -v "$PWD":/Users/mcobos/ProjectName
-w /Users/mcobos/ProjectName php /Users/mcobos/ProjectNamevendor/bin/phpunit 
-c /Users/mcobos/ProjectName/build/phpunit.xml 

Run all unit test groups using parallel and docker

for i in `./vendor/bin/phpunit -c build/phpunit.xml --list-groups | grep "^ -"
| awk {'print $2'}`; do echo $i; done | time /usr/local/bin/parallel 
docker run -d -v "$PWD":/Users/mcobos/ProjectName -w /Users/mcobos/ProjectName 
php /Users/mcobos/ProjectName/vendor/bin/phpunit -c /Users/mcobos/ProjectName/build/phpunit.xml --group {}

It works if you have more than 5K tests and the tests are classified by groups. If you have less than 5k tests the docker overhead is going to give you a worse results than running the test normally.