From 16ee9ed121681b7ce83cecded8a97dfaaea6c895 Mon Sep 17 00:00:00 2001 From: Pablo Grass Date: Thu, 8 Feb 2018 13:17:35 +0100 Subject: [PATCH 1/3] maintain only one dockerfile Compare wmde/email-address --- Dockerfile-7.1 => Dockerfile | 4 +++- Dockerfile-7.2 | 7 ------- README.md | 2 +- docker-compose.yml | 13 +++++++------ 4 files changed, 11 insertions(+), 15 deletions(-) rename Dockerfile-7.1 => Dockerfile (72%) delete mode 100644 Dockerfile-7.2 diff --git a/Dockerfile-7.1 b/Dockerfile similarity index 72% rename from Dockerfile-7.1 rename to Dockerfile index 5ac654f..0d8e7ac 100644 --- a/Dockerfile-7.1 +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM php:7.1-cli +ARG PHP_VERSION + +FROM php:${PHP_VERSION}-cli RUN \ apt-get update && \ diff --git a/Dockerfile-7.2 b/Dockerfile-7.2 deleted file mode 100644 index b820315..0000000 --- a/Dockerfile-7.2 +++ /dev/null @@ -1,7 +0,0 @@ -FROM php:7.2-cli - -RUN \ - apt-get update && \ - # for intl - apt-get install -y libicu-dev && \ - docker-php-ext-install -j$(nproc) intl diff --git a/README.md b/README.md index 6580717..0ef1189 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ To run just the PHPUnit tests run To run only a subset of PHPUnit tests or otherwise pass flags to PHPUnit, run - docker-compose run --rm app ./vendor/bin/phpunit --filter SomeClassNameOrFilter + docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpunit --filter SomeClassNameOrFilter If you have failing unit tests but want to run them for all PHP versions (normally it would bail on the first error) you can do so using diff --git a/docker-compose.yml b/docker-compose.yml index 2e859cb..615c404 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,17 +3,18 @@ version: '2' services: fun-validators-7.1: build: - context: ./ - dockerfile: Dockerfile-7.1 - image: fun-validators:7.1 + context: . + args: + PHP_VERSION: 7.1 volumes: - ./:/usr/src/app working_dir: /usr/src/app + image: wmde/fun-validators:7.1 fun-validators-7.2: extends: service: fun-validators-7.1 build: - context: ./ - dockerfile: Dockerfile-7.2 - image: fun-validators:7.2 + args: + PHP_VERSION: 7.2 + image: wmde/fun-validators:7.2 From 2c1413448804f9c496ea0fa3d6348630a1fb362c Mon Sep 17 00:00:00 2001 From: Pablo Grass Date: Thu, 8 Feb 2018 13:22:50 +0100 Subject: [PATCH 2/3] run platform-independent tasks only once The assumption being that phpcs, phpstan, covers-validator provide the same result (as long as PHP syntax fits the version) no matter the PHP version. --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 15e1a3d..603eced 100644 --- a/Makefile +++ b/Makefile @@ -20,15 +20,12 @@ phpunit: phpcs: docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpcs - docker-compose run --rm fun-validators-7.2 ./vendor/bin/phpcs stan: docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/ - docker-compose run --rm fun-validators-7.2 ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/ covers: docker-compose run --rm fun-validators-7.1 ./vendor/bin/covers-validator - docker-compose run --rm fun-validators-7.2 ./vendor/bin/covers-validator composer: docker run --rm --interactive --tty --volume $(shell pwd):/app -w /app\ From c20258eaee807ae277f96a421e4132d87c7e2b00 Mon Sep 17 00:00:00 2001 From: Pablo Grass Date: Thu, 8 Feb 2018 13:25:37 +0100 Subject: [PATCH 3/3] separate utility and app PHP more clearly Travis runs PHP for setup and QA, too - but this is not the same as the application runtime environment. --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2785c94..0214a87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: php +# php version to use for travis' composer & coverage php: - 7.1 -sudo: false - services: - docker @@ -16,7 +15,6 @@ script: - make ci after_success: - - if [[ "`phpenv version-name`" != "7.1" ]]; then exit 0; fi - vendor/bin/phpunit --coverage-clover coverage.clover - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover