From 68df0e1f4983a3a60b211a5a770a67e055b6129c Mon Sep 17 00:00:00 2001 From: Ilyas Salikhov Date: Sat, 27 Jan 2024 19:36:37 +0300 Subject: [PATCH] Environment to run test locally --- Dockerfile | 6 ++++++ Makefile | 16 ++++++++++++++++ docker-compose.yml | 11 +++++++++++ tests/bootstrap.php | 12 +----------- 4 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe601e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +ARG PHP_IMAGE_TAG +FROM php:${PHP_IMAGE_TAG}-cli-alpine + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +WORKDIR /opt/test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4a4f445 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +ifneq (,$(shell (type docker-compose 2>&1 >/dev/null && echo 1) || true)) + PHP=docker-compose run --rm --no-deps php +else + PHP=php +endif + +PHP_CONSOLE_DEPS=vendor + +vendor: composer.json + @$(PHP) composer install -o -n --no-ansi + @touch vendor || true + +phpunit: $(PHP_CONSOLE_DEPS) + @$(PHP) vendor/bin/phpunit --color=always + +check: phpunit diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3295c9a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.4' + +services: + php: + build: + context: . + args: + PHP_IMAGE_TAG: ${PHP_IMAGE_TAG:-7.4} + volumes: + - "./:/opt/test" + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6559848..82562e3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,13 +1,3 @@