From 69a88c5414f66a67c7f9f5405e5a24e5711cd1e1 Mon Sep 17 00:00:00 2001 From: Szabolcs Hajdu Date: Sun, 19 May 2024 17:21:19 +0200 Subject: [PATCH] Add explicit support for PHP 8.3 in test pipeline (#71) --- .gitattributes | 5 ++-- .github/workflows/main.yml | 2 +- Makefile | 15 ++++++++-- docker-compose.yml | 3 +- php81.Dockerfile => docker/php8.0/Dockerfile | 4 +-- docker/php8.1/Dockerfile | 29 +++++++++++++++++++ docker/php8.2/Dockerfile | 29 +++++++++++++++++++ docker/php8.3/Dockerfile | 29 +++++++++++++++++++ tests/README.md | 18 ++++++++++++ tests/data/sqlite.db | Bin 10 files changed, 125 insertions(+), 9 deletions(-) rename php81.Dockerfile => docker/php8.0/Dockerfile (87%) create mode 100644 docker/php8.1/Dockerfile create mode 100644 docker/php8.2/Dockerfile create mode 100644 docker/php8.3/Dockerfile mode change 100644 => 100755 tests/data/sqlite.db diff --git a/.gitattributes b/.gitattributes index 6e7735a0..4a905c87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,9 @@ # Exclude files that don't need to be present in packages (so they're not downloaded by Composer) +/docker export-ignore /tests export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/Robofile.php export-ignore +/Makefile export-ignore /*.md export-ignore +/*.xml export-ignore /*.yml export-ignore -/*.Dockerfile export-ignore diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 730b33ef..c1e6b1c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,7 @@ jobs: strategy: matrix: - php: [8.0, 8.1, 8.2] + php: [8.0, 8.1, 8.2, 8.3] steps: - name: Create default database for sqlsrv as image does not support it diff --git a/Makefile b/Makefile index 5d5cdee6..5397eed2 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ start: ## Start the containers for testing $(MAKE) -i stop CURRENT_USER=$(CURRENT_USER) $(DOCKER_COMPOSE) up -d --build --force-recreate --remove-orphans $(DOCKER_COMPOSE) run --rm wait -c mysql:3306,postgres:5432,mssql:1433 -t 60 - $(MAKE) vendor stop: ## Stop and remove containers $(DOCKER_COMPOSE) down --remove-orphans --volumes @@ -34,7 +33,19 @@ php-cli: ## Open bash in PHP container $(DOCKER_COMPOSE) exec -u $(CURRENT_USER) php bash vendor: ## Install dependencies - $(DOCKER_EXEC_PHP_WITH_USER) "composer install --no-interaction --prefer-dist" + $(DOCKER_EXEC_PHP_WITH_USER) "composer update --no-interaction --prefer-dist" test: ## Run the tests $(DOCKER_EXEC_PHP_WITH_USER) "php vendor/bin/codecept run" + +pipeline: ## Run the tests pipeline + $(MAKE) start + $(MAKE) vendor + $(MAKE) test + $(MAKE) stop + +ci: ## Run the tests + $(MAKE) pipeline php=8.0 + $(MAKE) pipeline php=8.1 + $(MAKE) pipeline php=8.2 + $(MAKE) pipeline php=8.3 diff --git a/docker-compose.yml b/docker-compose.yml index d2052501..6fbad477 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,7 @@ services: php: container_name: codeception-module-db build: - context: . - dockerfile: ./php81.Dockerfile + context: ./docker/php${php:-8.3} environment: COMPOSER_HOME: /tmp/.composer MYSQL_HOST: host.docker.internal diff --git a/php81.Dockerfile b/docker/php8.0/Dockerfile similarity index 87% rename from php81.Dockerfile rename to docker/php8.0/Dockerfile index 440dfa19..0f9c98b1 100644 --- a/php81.Dockerfile +++ b/docker/php8.0/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm +FROM php:8.0-fpm COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ @@ -21,7 +21,7 @@ RUN install-php-extensions \ zip-stable \ xdebug-3.1.5 -COPY --from=composer /usr/bin/composer /usr/bin/composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html diff --git a/docker/php8.1/Dockerfile b/docker/php8.1/Dockerfile new file mode 100644 index 00000000..47b46a07 --- /dev/null +++ b/docker/php8.1/Dockerfile @@ -0,0 +1,29 @@ +FROM php:8.1-fpm + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ + +RUN apt-get update && \ + apt-get install -y \ + unzip \ + wget \ + git \ + zlib1g-dev \ + libzip-dev \ + libpq-dev \ + default-mysql-client + +RUN install-php-extensions \ + pdo_mysql-stable \ + pdo_pgsql-stable \ + pdo_dblib-stable \ + pdo_sqlsrv-5.11.0 \ + pgsql-stable \ + zip-stable \ + xdebug-3.3.2 + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +ENTRYPOINT ["tail"] +CMD ["-f", "/dev/null"] diff --git a/docker/php8.2/Dockerfile b/docker/php8.2/Dockerfile new file mode 100644 index 00000000..434fc9db --- /dev/null +++ b/docker/php8.2/Dockerfile @@ -0,0 +1,29 @@ +FROM php:8.2-fpm + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ + +RUN apt-get update && \ + apt-get install -y \ + unzip \ + wget \ + git \ + zlib1g-dev \ + libzip-dev \ + libpq-dev \ + default-mysql-client + +RUN install-php-extensions \ + pdo_mysql-stable \ + pdo_pgsql-stable \ + pdo_dblib-stable \ + pdo_sqlsrv-5.11.0 \ + pgsql-stable \ + zip-stable \ + xdebug-3.3.2 + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +ENTRYPOINT ["tail"] +CMD ["-f", "/dev/null"] diff --git a/docker/php8.3/Dockerfile b/docker/php8.3/Dockerfile new file mode 100644 index 00000000..babf5c06 --- /dev/null +++ b/docker/php8.3/Dockerfile @@ -0,0 +1,29 @@ +FROM php:8.3-fpm + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ + +RUN apt-get update && \ + apt-get install -y \ + unzip \ + wget \ + git \ + zlib1g-dev \ + libzip-dev \ + libpq-dev \ + default-mysql-client + +RUN install-php-extensions \ + pdo_mysql-stable \ + pdo_pgsql-stable \ + pdo_dblib-stable \ + pdo_sqlsrv-5.12.0 \ + pgsql-stable \ + zip-stable \ + xdebug-3.3.2 + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +ENTRYPOINT ["tail"] +CMD ["-f", "/dev/null"] diff --git a/tests/README.md b/tests/README.md index abab0b5d..213549cb 100644 --- a/tests/README.md +++ b/tests/README.md @@ -31,6 +31,24 @@ make test This command will execute the tests inside the PHP container. +## Running the Tests Pipeline + +To run the tests pipeline, use the following command: + +```bash +make pipeline +``` + +This command will start the containers, install dependencies, run the tests, and then stop the containers. + +## Running the Tests for Continuous Integration + +```bash +make ci +``` + +This command will run the tests pipeline for all supported PHP versions. + ## Other Commands - To stop and remove the Docker containers, use the following command: diff --git a/tests/data/sqlite.db b/tests/data/sqlite.db old mode 100644 new mode 100755