From 5d11e3089bdf0ac602a17054ceb5e2cd14efb8b5 Mon Sep 17 00:00:00 2001 From: Fabri Di Napoli Date: Wed, 26 Jul 2017 23:23:59 +0200 Subject: [PATCH 1/5] Add docker-compose yaml with basics --- docker-compose.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..21dad2c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.1" + +services: + php: + image: php:7.1.7-cli + volumes: + - .:/opt/php + privileged: true + command: ["/opt/php/docker/test_runner.sh"] \ No newline at end of file From e65bf1ea24dfcc55155a3525f76362e030c2b1d6 Mon Sep 17 00:00:00 2001 From: Fabri Di Napoli Date: Wed, 26 Jul 2017 23:24:21 +0200 Subject: [PATCH 2/5] Add docker test runner script --- docker/test_runner.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 docker/test_runner.sh diff --git a/docker/test_runner.sh b/docker/test_runner.sh new file mode 100755 index 0000000..47ba381 --- /dev/null +++ b/docker/test_runner.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +cd /opt/php + +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +php composer-setup.php +php -r "unlink('composer-setup.php');" + +php composer.phar install --prefer-dist --no-interaction + +ls -la ./vendor/bin + +if ./vendor/bin/phpunit; then + echo "Tests passed successfully!" + exit 0 +else + echo "Tests failed :(" + exit 1 +fi \ No newline at end of file From e7b7d26351a6d78a85d45f598c8d3d203cded394 Mon Sep 17 00:00:00 2001 From: Fabri Di Napoli Date: Wed, 26 Jul 2017 23:24:42 +0200 Subject: [PATCH 3/5] Add docker part in readme and deprecate vagrant one --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b391b77..b1cf596 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,15 @@ I think the problem with patterns is that often people do know them but don't kn You should look at and run the tests to see what happens in the example. To do this, you should install dependencies with `Composer` first: -### [optional] Using a Virtual Machine (VM) +### [option] Using Docker + +You can optionally run tests using [Docker for Mac](https://www.docker.com/docker-mac) or [Windows](https://www.docker.com/docker-windows) or native one for [Linux](https://www.docker.com/docker-debian). +Just run: +``` +docker-compose up +``` + +### [optional] [DEPRECATED] Using a Virtual Machine (VM) If you wish to use a ready made VM environment, you can easily create one with Vagrant and Ansible. From bcb128ac6d9371860c33223680915842593a1dca Mon Sep 17 00:00:00 2001 From: Fabri Di Napoli Date: Wed, 26 Jul 2017 23:26:31 +0200 Subject: [PATCH 4/5] Add some output to test runner script --- docker/test_runner.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/test_runner.sh b/docker/test_runner.sh index 47ba381..018b291 100755 --- a/docker/test_runner.sh +++ b/docker/test_runner.sh @@ -2,15 +2,16 @@ cd /opt/php +echo "Installing composer..." php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" +echo "Downloading dependencies using composer..." php composer.phar install --prefer-dist --no-interaction -ls -la ./vendor/bin - +echo "Running tests..." if ./vendor/bin/phpunit; then echo "Tests passed successfully!" exit 0 From 151323bc403f9239f7af0c139bef27c627302c1f Mon Sep 17 00:00:00 2001 From: Fabri Di Napoli Date: Mon, 21 Aug 2017 08:53:44 +0200 Subject: [PATCH 5/5] Add new line at eof --- docker/test_runner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/test_runner.sh b/docker/test_runner.sh index 018b291..dbe3677 100755 --- a/docker/test_runner.sh +++ b/docker/test_runner.sh @@ -18,4 +18,4 @@ if ./vendor/bin/phpunit; then else echo "Tests failed :(" exit 1 -fi \ No newline at end of file +fi