From ea371061aa2ebe8bf70d0b1a1dcb0d72907746a7 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Sun, 19 Nov 2023 12:55:20 +0100 Subject: [PATCH 1/6] fix(test): docker images build to handle old linux distributions --- .docker/php53/Dockerfile | 65 +++++++- .docker/php54/Dockerfile | 87 ++++++++++ .docker/php55_71/Dockerfile | 92 +++++++++++ .docker/php72_73/Dockerfile | 74 +++++++++ .docker/php74_82/Dockerfile | 34 ---- .docker/php74_83/Dockerfile | 108 +++++++++++++ .env | 6 + .gitignore | 2 + README.md | 7 +- docker-compose.yml | 65 ++++++-- tests/bin/test | 311 +++++++++++++++++++++++++++++------- 11 files changed, 739 insertions(+), 112 deletions(-) delete mode 100644 .docker/php74_82/Dockerfile create mode 100644 .docker/php74_83/Dockerfile create mode 100644 .env diff --git a/.docker/php53/Dockerfile b/.docker/php53/Dockerfile index fa7261082..38bf19a67 100644 --- a/.docker/php53/Dockerfile +++ b/.docker/php53/Dockerfile @@ -1,12 +1,20 @@ -FROM buildpack-deps:jessie +FROM buildpack-deps:jessie as php53 ENV PHP_VERSION 5.3.29 +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + # php 5.3 needs older autoconf RUN set -eux; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ curl \ autoconf2.13 \ ; \ @@ -18,7 +26,7 @@ RUN set -eux; \ dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \ rm *.deb; \ \ - curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ + curl --insecure -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \ \ mkdir -p /usr/src/php; \ @@ -32,6 +40,8 @@ RUN set -eux; \ --with-pdo-mysql \ --with-zlib \ --enable-mbstring \ + --with-openssl=/usr \ + --with-libdir=lib/x86_64-linux-gnu \ ; \ make -j"$(nproc)"; \ make install; \ @@ -40,9 +50,56 @@ RUN set -eux; \ bison \ libbison-dev \ ; \ - apt-get purge -y --auto-remove \ + apt-get purge -y --force-yes --auto-remove \ autoconf2.13 \ ; \ rm -r /usr/src/php CMD ["php", "-a"] + +FROM php53 + +# Install APC PHP extension +# +RUN set -eux; \ + \ + pecl install apc-3.1.13; \ + echo 'extension=apc.so' >> /usr/local/lib/php.ini; \ + \ + rm -r /tmp/pear; + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + ; \ + rm -r /var/lib/apt/lists/*; \ + :; diff --git a/.docker/php54/Dockerfile b/.docker/php54/Dockerfile index 91baa8c85..b330bcdb0 100644 --- a/.docker/php54/Dockerfile +++ b/.docker/php54/Dockerfile @@ -1,5 +1,92 @@ FROM php:5.4-cli +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + ca-certificates \ + ; \ + \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + :; + RUN docker-php-ext-install pdo RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mbstring + +# Install APC PHP extension +# +RUN set -eux; \ + pecl install apc-3.1.13; \ + docker-php-ext-enable apc; \ + rm -r /tmp/pear; + +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + pecl install memcache-${MEMCACHE_VERSION}; \ + docker-php-ext-enable memcache; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php55_71/Dockerfile b/.docker/php55_71/Dockerfile index 7c901b83a..9438ad49f 100644 --- a/.docker/php55_71/Dockerfile +++ b/.docker/php55_71/Dockerfile @@ -1,6 +1,98 @@ ARG PHP_TAG FROM php:${PHP_TAG} +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + ca-certificates \ + ; \ + \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + :; + RUN docker-php-ext-install pdo RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mbstring + +# Install APCu PHP extension +# +ARG APCU_VERSION +RUN set -eux; \ + \ + test x"" = x"${APCU_VERSION}" || { \ + pecl install apcu-${APCU_VERSION}; \ + docker-php-ext-enable apcu; \ + \ + rm -r /tmp/pear; \ + } + +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + pecl install memcache-${MEMCACHE_VERSION}; \ + docker-php-ext-enable memcache; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php72_73/Dockerfile b/.docker/php72_73/Dockerfile index 1cc2965f5..8e8864668 100644 --- a/.docker/php72_73/Dockerfile +++ b/.docker/php72_73/Dockerfile @@ -5,6 +5,40 @@ RUN docker-php-ext-install pdo RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mbstring +# Install APCu PHP extension +# +ARG APCU_VERSION +RUN set -eux; \ + \ + test x"" = x"${APCU_VERSION}" || { \ + pecl install apcu-${APCU_VERSION}; \ + docker-php-ext-enable apcu; \ + \ + rm -r /tmp/pear; \ + } + +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + pecl install memcache-${MEMCACHE_VERSION}; \ + docker-php-ext-enable memcache; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + # For consistent mime type file guesser RUN set -eux; \ distFilePath=`which file`; \ @@ -20,3 +54,43 @@ RUN set -eux; \ \ file /bin/ls --mime | grep application/x-executable; \ :; + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php74_82/Dockerfile b/.docker/php74_82/Dockerfile deleted file mode 100644 index 7d13d7c82..000000000 --- a/.docker/php74_82/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -ARG PHP_VERSION -FROM php:${PHP_VERSION}-cli - -RUN docker-php-ext-install pdo -RUN docker-php-ext-install pdo_mysql - -# Install mbstring PHP extension -# -RUN set -eux; \ - apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ - libonig-dev \ - ; \ - \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/*; \ - \ - docker-php-ext-install mbstring - -# For consistent mime type file guesser -RUN set -eux; \ - distFilePath=`which file`; \ - \ - mv ${distFilePath} ${distFilePath}.dist; \ - { \ - echo '#! /bin/sh -eu'; \ - echo ''; \ - echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \ - } | tee ${distFilePath}; \ - \ - chmod +x ${distFilePath}; \ - \ - file /bin/ls --mime | grep application/x-executable; \ - :; diff --git a/.docker/php74_83/Dockerfile b/.docker/php74_83/Dockerfile new file mode 100644 index 000000000..8e134233d --- /dev/null +++ b/.docker/php74_83/Dockerfile @@ -0,0 +1,108 @@ +ARG PHP_VERSION +FROM php:${PHP_VERSION}-cli + +RUN docker-php-ext-install pdo +RUN docker-php-ext-install pdo_mysql + +# Install mbstring PHP extension +# +RUN set -eux; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + libonig-dev \ + ; \ + \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + \ + docker-php-ext-install mbstring + +# Install APCu PHP extension +# +ARG APCU_VERSION +RUN set -eux; \ + \ + test x"" = x"${APCU_VERSION}" || { \ + pecl install apcu-${APCU_VERSION}; \ + docker-php-ext-enable apcu; \ + \ + rm -r /tmp/pear; \ + } + +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + pecl install memcache-${MEMCACHE_VERSION}; \ + docker-php-ext-enable memcache; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + +# For consistent mime type file guesser +RUN set -eux; \ + distFilePath=`which file`; \ + \ + mv ${distFilePath} ${distFilePath}.dist; \ + { \ + echo '#! /bin/sh -eu'; \ + echo ''; \ + echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \ + } | tee ${distFilePath}; \ + \ + chmod +x ${distFilePath}; \ + \ + file /bin/ls --mime | grep application/x-executable; \ + :; + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.env b/.env new file mode 100644 index 000000000..8a907cead --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +# +# Environment variables used by for running tests. +# +# Copy to `.env.local` in order to customize it. +# +DOCKER_COMPOSE='docker-compose' diff --git a/.gitignore b/.gitignore index 4a2fca764..dbe6fbd51 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ tests/DoctrineTest/doctrine_tests/* /tests/tmp /tests/foo.sq3 /vendor/ +/var/ +/.env.* diff --git a/README.md b/README.md index 27f085e1b..5a0d7103c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ Using [Composer](http://getcomposer.org/doc/00-intro.md) as dependency managemen composer install - Tests ----- @@ -35,7 +34,11 @@ Tests ### How to execute all tests on all supported PHP versions and dependencies? - tests/bin/test + test/bin/test + +### Want to do specific test ? Ask help with the option. + + test/bin/test --help ### When you finish your work day, do not forget to clean up your desk diff --git a/docker-compose.yml b/docker-compose.yml index 9c36afacc..b2466a08a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,23 +4,14 @@ volumes: db_socket: services: - composer: - image: composer - working_dir: /app - volumes: - - .:/app - entrypoint: - - sh - - -c - - | - exec tail -f /dev/null - php53: build: .docker/php53 working_dir: /app/tests volumes: - .:/app - db_socket:/var/run/mysqld + environment: + COMPOSER_HOME: /app/var/cache/composer entrypoint: - sh - -c @@ -31,13 +22,22 @@ services: echo 'short_open_tag = off' echo 'magic_quotes_gpc = off' echo 'date.timezone = "UTC"' + echo 'apc.enable_cli = on' + echo 'apc.use_request_time = 0' } | tee -a /usr/local/lib/php.ini exec tail -f /dev/null + depends_on: + - db php54: &services_php54 build: context: .docker/php54 + args: + MEMCACHE_VERSION: '3.0.8' + environment: + MEMCACHED_HOST: memcached + COMPOSER_HOME: /app/var/cache/composer working_dir: /app/tests volumes: - .:/app @@ -52,11 +52,14 @@ services: echo 'short_open_tag = off' echo 'magic_quotes_gpc = off' echo 'date.timezone = "UTC"' + echo 'apc.enable_cli = on' + echo 'apc.use_request_time = 0' } | tee -a /usr/local/etc/php/php.ini exec tail -f /dev/null depends_on: - db + - memcached php55: <<: *services_php54 @@ -64,6 +67,8 @@ services: context: .docker/php55_71 args: PHP_TAG: '5.5-cli' + MEMCACHE_VERSION: '3.0.8' + APCU_VERSION: '4.0.11' php56: <<: *services_php54 @@ -71,6 +76,8 @@ services: context: .docker/php55_71 args: PHP_TAG: '5.6-cli-jessie' + MEMCACHE_VERSION: '3.0.8' + APCU_VERSION: '4.0.11' php70: <<: *services_php54 @@ -78,6 +85,8 @@ services: context: .docker/php55_71 args: PHP_TAG: '7.0-cli-jessie' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '' php71: <<: *services_php54 @@ -85,6 +94,8 @@ services: context: .docker/php55_71 args: PHP_TAG: '7.1-cli-jessie' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '' php72: <<: *services_php54 @@ -92,6 +103,8 @@ services: context: .docker/php72_73 args: PHP_VERSION: '7.2' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '' php73: <<: *services_php54 @@ -99,34 +112,53 @@ services: context: .docker/php72_73 args: PHP_VERSION: '7.3' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '' php74: <<: *services_php54 build: - context: .docker/php74_82 + context: .docker/php74_83 args: PHP_VERSION: '7.4' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '' php80: <<: *services_php54 build: - context: .docker/php74_82 + context: .docker/php74_83 args: PHP_VERSION: '8.0' + MEMCACHE_VERSION: '8.0' + APCU_VERSION: '' php81: <<: *services_php54 build: - context: .docker/php74_82 + context: .docker/php74_83 args: PHP_VERSION: '8.1' + MEMCACHE_VERSION: '8.0' + APCU_VERSION: '' php82: <<: *services_php54 build: - context: .docker/php74_82 + context: .docker/php74_83 args: PHP_VERSION: '8.2' + MEMCACHE_VERSION: '8.0' + APCU_VERSION: '' + + php83: + <<: *services_php54 + build: + context: .docker/php74_83 + args: + PHP_VERSION: '8.3' + MEMCACHE_VERSION: '8.0' + APCU_VERSION: '' db: image: mysql:5.5.62 @@ -143,3 +175,6 @@ services: } | tee /docker-entrypoint-initdb.d/init.sql exec /usr/local/bin/docker-entrypoint.sh mysqld + + memcached: + image: memcached:1.6.13-alpine3.15 diff --git a/tests/bin/test b/tests/bin/test index 2df829884..201928b0e 100755 --- a/tests/bin/test +++ b/tests/bin/test @@ -1,76 +1,273 @@ #! /bin/sh -eu -# -# [] [] [] -# -# example: php70 -# One of highest (default), lowest -# -# Both arguments can be a space separated value. -# Example: "lowest highest" -# - -# Configuration -# -dependencyPreferences='highest' -skipPHPVersions='php8' - -# Commands -# -dcexec="docker-compose exec -u `id -u`:`id -g`" -composerUpdate='composer update --prefer-dist --optimize-autoloader' -doctrineTestSuite='run.php' - -# Parse arguments -# -phpVersions="${1-}" -dependencyPreferences="${2-${dependencyPreferences}}" -phpTestRuntime="${3-${doctrineTestSuite}}" - -script () -{ - echo - echo - echo $0 ${1} ${2} - echo - ${dcexec} ${1} php ${phpTestRuntime} -} - -scriptAll () -{ - for dependencyPreference in ${dependencyPreferences} - do - install_${dependencyPreference} - - for phpVersion in ${phpVersions} + +__DIR__=`dirname "$0"` +ROOT_DIR="${__DIR__}/../.." + +main () +{ + importEnvironmentVariablesFromDirectory "${ROOT_DIR}" + + configureWithArguments ${1+"$@"} + + startDockerComposeServices + + populatePHPVersions + + runTests +} + +printHelp () +{ + cat <...] + [--dependency-preference ...] + [--php-test-runtime ] + +Options: + --help Show this screen. + --php-versions Select specific php versions. [default: ${PHP_VERSIONS}] + Examples: + php53 + 'php53 php54' + --dependency-preference Select spectific dependency preference. [default: ${DEPENDENCY_PREFERENCES}] + Allows values: + - highest + - lowest + --php-test-runtime The endpoint command to run test. [default: ${PHP_TEST_RUNTIME}] + +Files: + There are a few configuration files to control certain aspects of operation. + + /.env + This is the default configuration file read on startup. + + /.env.local + This is the custom configuration file read on startup. + To be used to extends /.env with custom configuration. + +Examples: + + * How to execute all tests on all supported PHP versions and dependencies? + + $ test/bin/test + + * How to execute all tests on specific PHP version ? + + $ test/bin/test --php-versions 'php56 php74 php82' + + * How to execute all tests on lowest and highest dependency preference ? + + $ test/bin/test --dependency-preferences 'lowest highest' + + * How to customize the PHP test runtime ? + + $ test/bin/test --php-test-runtime index.php + + * When you finish your work day, do not forget to clean up your desk + + $ docker-compose down +EOF +} + +importEnvironmentVariablesFromDirectory () +{ + a_directory=${1} + + . "${a_directory}"/.env + + if test -r "${a_directory}"/.env.local; then + . "${a_directory}"/.env.local + else :; fi +} + +startDockerComposeServices () +{ + echo "+ ${DOCKER_COMPOSE} build" + ${DOCKER_COMPOSE} up -d --build --remove-orphans > /dev/null +} + +configureWithArguments () +{ + # Commands + # + DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec -u `id -u`:`id -g`" + COMPOSER_UPDATE='composer update --working-dir=/app --prefer-dist --no-suggest --optimize-autoloader' + + # Default Options + # + DEPENDENCY_PREFERENCES='highest' + PHP_VERSIONS='all' + PHP_TEST_RUNTIME='run.php' + hasHelpOption=false + + parseOperands ${1+"$@"} + + if ${hasHelpOption}; then + printHelp + + exit 0 + else :; fi +} + +populatePHPVersions () +{ + if test x'all' = x"${PHP_VERSIONS}"; then + PHP_VERSIONS=`fetchAllPHPVersions` + else :; fi +} + +fetchAllPHPVersions () +{ + ${DOCKER_COMPOSE} 2>/dev/null ps --services --filter status=running \ + | grep php \ + | sort +} + +runTests () +{ + for dependencyPreference in ${DEPENDENCY_PREFERENCES} do - script ${phpVersion} ${dependencyPreference} + for phpVersion in ${PHP_VERSIONS} + do + runTestsForOnePhpVersionAndOneDependencyPreference ${phpVersion} ${dependencyPreference} + done done - done } -fetchAllPHPVersions () +runTestsForOnePhpVersionAndOneDependencyPreference () { - docker-compose 2>/dev/null ps --services --filter status=running \ - | grep php \ - | sort \ - | grep -v ${skipPHPVersions} + a_phpVersion=${1} + a_dependencyPreference=${2} + + echo + echo + echo $0 ${a_phpVersion} ${a_dependencyPreference} + echo + + install_${a_dependencyPreference} ${a_phpVersion} + + ${DOCKER_COMPOSE_EXEC} ${a_phpVersion} php ${PHP_TEST_RUNTIME} } install_highest () { - ${dcexec} composer ${composerUpdate} + b_service=${1} + + ${DOCKER_COMPOSE_EXEC} ${b_service} ${COMPOSER_UPDATE} } install_lowest () { - ${dcexec} composer ${composerUpdate} --prefer-lowest + c_service=${1} + + ${DOCKER_COMPOSE_EXEC} ${c_service} ${COMPOSER_UPDATE} --prefer-lowest } -echo '+ docker-compose build' -docker-compose up -d --build --remove-orphans > /dev/null +parseOperands () +{ + parseOperands_init -test x"" != x"${phpVersions}" || { - phpVersions=`fetchAllPHPVersions` + for parseOperands_currentOperand + do + if parseOperands_previousOptionNeedsValue; then + parseOperands_assignValueToVariableToSet + + continue + else :; fi + + parseOperands_extractValueFromCurrentOperand + + case ${parseOperands_endOfOptions}${parseOperands_currentOperand} in #( + --) + parseOperands_endOfOptions='yes' + ;; #( + --help) + hasHelpOption=${optionValue} + ;; #( + --php-versions) + variableToSet=PHP_VERSIONS + ;; #( + --php-versions=*) + PHP_VERSIONS=${optionValue} + ;; #( + --dependency-preferences) + variableToSet=DEPENDENCY_PREFERENCES + ;; #( + --dependency-preferences=*) + DEPENDENCY_PREFERENCES=${optionValue} + ;; #( + --php-test-runtime) + variableToSet=PHP_TEST_RUNTIME + ;; #( + --php-test-runtime=*) + PHP_TEST_RUNTIME=${optionValue} + ;; #( + # --flag-option) + # hasFlagOption=${optionValue} + # ;; #( + # --value-option) + # variableToSet=valueOption + # ;; #( + # --value-option=*) + # valueOption=${optionValue} + # ;; #( + -*) + : + ;; #( + *) + parseOperands_argumentPosition=`expr 1 \+ ${parseOperands_argumentPosition}` + + case ${parseOperands_argumentPosition} in #( + # 1) + # firstArgument=${parseOperands_currentOperand} + # ;; #( + *) + : + ;; + esac + ;; + esac + done +} + +parseOperands_init () +{ + variableToSet= + optionValue= + + parseOperands_endOfOptions= + parseOperands_argumentPosition=0 + parseOperands_operandEnabledValue=':' +} + +parseOperands_assignValueToVariableToSet () +{ + eval ${variableToSet}=\"${parseOperands_currentOperand}\" + + variableToSet= +} + +parseOperands_previousOptionNeedsValue () +{ + test x != x"${variableToSet}" +} + +parseOperands_extractValueFromCurrentOperand () +{ + case ${parseOperands_currentOperand} in #( + ?*=?*) + optionValue=`expr X"${parseOperands_currentOperand}" : X'[^=]*=\(.*\)'` + ;; #( + ?*=) + optionValue= + ;; #( + *) + optionValue=${parseOperands_operandEnabledValue} + ;; + esac } -scriptAll +main ${1+"$@"} From 9ca9f4e3f104457e3c4ab8c39336001cedf49d03 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Sat, 20 Jan 2024 16:00:02 +0100 Subject: [PATCH 2/6] fix(test): download PHP extension from PECL without TLS --- .docker/php53/Dockerfile | 20 +++++++++++-- .docker/php54/Dockerfile | 35 +++++++++++++++++++--- .docker/php55_71/Dockerfile | 57 +++++++++++++++++++++++++++++++----- .docker/php72_73/Dockerfile | 50 +++++++++++++++++++++++++++----- .docker/php74_83/Dockerfile | 58 ++++++++++++++++++++++++++++++++----- 5 files changed, 189 insertions(+), 31 deletions(-) diff --git a/.docker/php53/Dockerfile b/.docker/php53/Dockerfile index 38bf19a67..daa7b9214 100644 --- a/.docker/php53/Dockerfile +++ b/.docker/php53/Dockerfile @@ -63,10 +63,24 @@ FROM php53 # RUN set -eux; \ \ - pecl install apc-3.1.13; \ - echo 'extension=apc.so' >> /usr/local/lib/php.ini; \ + packageName=APC; \ + packageVersion=3.1.13; \ \ - rm -r /tmp/pear; + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + echo "extension=apc.so" >> /usr/local/lib/php.ini; \ + \ + rm -r /tmp/pear; \ + :; # Install composer # diff --git a/.docker/php54/Dockerfile b/.docker/php54/Dockerfile index b330bcdb0..62a792b9a 100644 --- a/.docker/php54/Dockerfile +++ b/.docker/php54/Dockerfile @@ -25,14 +25,35 @@ RUN docker-php-ext-install mbstring # Install APC PHP extension # RUN set -eux; \ - pecl install apc-3.1.13; \ - docker-php-ext-enable apc; \ - rm -r /tmp/pear; + \ + packageName=APC; \ + packageVersion=3.1.13; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + echo "extension=apc.so" >> /usr/local/lib/php.ini; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ + if test x"3.0.8" = x"${MEMCACHE_VERSION}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ buildDeps=' \ libzip-dev \ '; \ @@ -41,7 +62,13 @@ RUN set -eux; \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ + curl --insecure -sSLfO https://pecl.php.net/get/memcache-${MEMCACHE_VERSION}.tgz; \ + echo "${packageSha256sum} memcache-${MEMCACHE_VERSION}.tgz" \ + | sha256sum -cw --status; \ + \ + pecl install memcache-${MEMCACHE_VERSION}.tgz; \ + rm memcache-${MEMCACHE_VERSION}.tgz; \ + \ docker-php-ext-enable memcache; \ \ apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ diff --git a/.docker/php55_71/Dockerfile b/.docker/php55_71/Dockerfile index 9438ad49f..0f2c57c14 100644 --- a/.docker/php55_71/Dockerfile +++ b/.docker/php55_71/Dockerfile @@ -28,17 +28,40 @@ RUN docker-php-ext-install mbstring ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + if test x"" = x"${APCU_VERSION}"; then \ + return 0; \ + else :; fi; \ + \ + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.11" = x"${packageVersion}"; then \ + packageSha256sum=454f302ec13a6047ca4c39e081217ce5a61bbea815aec9c1091fb849e70b4d00; \ + else :; fi; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ buildDeps=' \ libzip-dev \ '; \ @@ -47,8 +70,26 @@ RUN set -eux; \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ \ apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ diff --git a/.docker/php72_73/Dockerfile b/.docker/php72_73/Dockerfile index 8e8864668..42765befb 100644 --- a/.docker/php72_73/Dockerfile +++ b/.docker/php72_73/Dockerfile @@ -10,17 +10,36 @@ RUN docker-php-ext-install mbstring ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + if test x"" = x"${APCU_VERSION}"; then \ + return 0; \ + else :; fi; \ + \ + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ buildDeps=' \ libzip-dev \ '; \ @@ -29,8 +48,23 @@ RUN set -eux; \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ diff --git a/.docker/php74_83/Dockerfile b/.docker/php74_83/Dockerfile index 8e134233d..a55823563 100644 --- a/.docker/php74_83/Dockerfile +++ b/.docker/php74_83/Dockerfile @@ -22,17 +22,36 @@ RUN set -eux; \ ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + if test x"" = x"${APCU_VERSION}"; then \ + return 0; \ + else :; fi; \ + \ + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ buildDeps=' \ libzip-dev \ '; \ @@ -41,8 +60,31 @@ RUN set -eux; \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + if test x"8.0" = x"${packageVersion}"; then \ + packageSha256sum=defe33e6f7831d82b7283b95e14a531070531acbf21278f3f0d7050505cf3395; \ + else :; fi; \ + \ + if test x"8.2" = x"${packageVersion}"; then \ + packageSha256sum=b3f0640eacdeb9046c6c86a1546d7fb8a4e9f219e5d9a36a287e59b2dd8208e5; \ + else :; fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ \ apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ From c6907e5fd8809ae57339676fde9b9b8c321fa7c6 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Sat, 20 Jan 2024 17:37:15 +0100 Subject: [PATCH 3/6] fix(test): make php 5.3 consistent with others --- .docker/php53/Dockerfile | 95 +++++++++++++++++--- .docker/php54/Dockerfile | 40 ++++++--- .docker/php55_71/Dockerfile | 39 ++++---- .docker/php72_73/Dockerfile | 34 +++---- .docker/php74_83/Dockerfile | 32 ++++--- .github/workflows/continuous-integration.yml | 3 +- docker-compose.yml | 72 ++++++--------- tests/bin/test | 4 +- tests/run.php | 2 + 9 files changed, 206 insertions(+), 115 deletions(-) diff --git a/.docker/php53/Dockerfile b/.docker/php53/Dockerfile index daa7b9214..7357b4e48 100644 --- a/.docker/php53/Dockerfile +++ b/.docker/php53/Dockerfile @@ -12,11 +12,15 @@ RUN set -eux; \ # php 5.3 needs older autoconf RUN set -eux; \ + \ + buildDeps=' \ + autoconf2.13 \ + '; \ \ apt-get update; \ apt-get install -y --force-yes --no-upgrade --no-install-recommends \ curl \ - autoconf2.13 \ + $buildDeps \ ; \ rm -r /var/lib/apt/lists/*; \ \ @@ -37,23 +41,45 @@ RUN set -eux; \ ./buildconf --force; \ ./configure --disable-cgi \ $(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \ + --with-config-file-path=/usr/local/etc/php \ + --with-config-file-scan-dir=/usr/local/etc/php/conf.d \ + --with-libdir=lib/x86_64-linux-gnu \ --with-pdo-mysql \ --with-zlib \ + --enable-zip \ --enable-mbstring \ --with-openssl=/usr \ - --with-libdir=lib/x86_64-linux-gnu \ + --enable-mysqlnd \ + --with-curl \ + --with-readline \ + --enable-ftp \ ; \ make -j"$(nproc)"; \ make install; \ + install -d /usr/local/etc/php/conf.d; \ \ dpkg -r \ bison \ libbison-dev \ ; \ - apt-get purge -y --force-yes --auto-remove \ - autoconf2.13 \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ ; \ - rm -r /usr/src/php + rm -r /usr/src/php; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear; \ + :; + +RUN set -eux; \ + { \ + echo '#! /bin/sh -eu'; \ + echo ''; \ + echo 'echo "extension=${1}.so" > "/usr/local/etc/php/conf.d/docker-php-ext-${1}.ini";'; \ + } | tee /usr/local/bin/docker-php-ext-enable; \ + \ + chmod +x /usr/local/bin/docker-php-ext-enable; \ + :; CMD ["php", "-a"] @@ -61,14 +87,21 @@ FROM php53 # Install APC PHP extension # +ARG APC_VERSION RUN set -eux; \ \ - packageName=APC; \ - packageVersion=3.1.13; \ + packageName=apc; \ + packageVersion=${APC_VERSION}; \ + packageFile=APC-${packageVersion}.tgz; \ \ - packageFile=${packageName}-${packageVersion}.tgz; \ + if test x"3.1.13" = x"${packageVersion}"; then \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + else :; fi; \ \ - packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ @@ -77,11 +110,53 @@ RUN set -eux; \ pecl install ${packageFile}; \ rm ${packageFile}; \ \ - echo "extension=apc.so" >> /usr/local/lib/php.ini; \ + docker-php-ext-enable ${packageName}; \ \ rm -r /tmp/pear; \ :; +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + # Install composer # RUN set -eux; \ diff --git a/.docker/php54/Dockerfile b/.docker/php54/Dockerfile index 62a792b9a..e7b624265 100644 --- a/.docker/php54/Dockerfile +++ b/.docker/php54/Dockerfile @@ -24,14 +24,21 @@ RUN docker-php-ext-install mbstring # Install APC PHP extension # +ARG APC_VERSION RUN set -eux; \ \ - packageName=APC; \ - packageVersion=3.1.13; \ + packageName=apc; \ + packageVersion=${APC_VERSION}; \ + packageFile=APC-${packageVersion}.tgz; \ \ - packageFile=${packageName}-${packageVersion}.tgz; \ + if test x"3.1.13" = x"${packageVersion}"; then \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + else :; fi; \ \ - packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ @@ -40,7 +47,7 @@ RUN set -eux; \ pecl install ${packageFile}; \ rm ${packageFile}; \ \ - echo "extension=apc.so" >> /usr/local/lib/php.ini; \ + docker-php-ext-enable ${packageName}; \ \ rm -r /tmp/pear; \ :; @@ -50,10 +57,19 @@ RUN set -eux; \ ARG MEMCACHE_VERSION RUN set -eux; \ \ - if test x"3.0.8" = x"${MEMCACHE_VERSION}"; then \ - packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ buildDeps=' \ libzip-dev \ '; \ @@ -62,14 +78,14 @@ RUN set -eux; \ $buildDeps \ ; \ \ - curl --insecure -sSLfO https://pecl.php.net/get/memcache-${MEMCACHE_VERSION}.tgz; \ - echo "${packageSha256sum} memcache-${MEMCACHE_VERSION}.tgz" \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ \ - pecl install memcache-${MEMCACHE_VERSION}.tgz; \ - rm memcache-${MEMCACHE_VERSION}.tgz; \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ \ - docker-php-ext-enable memcache; \ + docker-php-ext-enable ${packageName}; \ \ apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ diff --git a/.docker/php55_71/Dockerfile b/.docker/php55_71/Dockerfile index 0f2c57c14..49f5740f4 100644 --- a/.docker/php55_71/Dockerfile +++ b/.docker/php55_71/Dockerfile @@ -27,14 +27,9 @@ RUN docker-php-ext-install mbstring # ARG APCU_VERSION RUN set -eux; \ - \ - if test x"" = x"${APCU_VERSION}"; then \ - return 0; \ - else :; fi; \ \ packageName=apcu; \ packageVersion=${APCU_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ if test x"4.0.11" = x"${packageVersion}"; then \ @@ -45,6 +40,11 @@ RUN set -eux; \ packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ @@ -61,27 +61,32 @@ RUN set -eux; \ # ARG MEMCACHE_VERSION RUN set -eux; \ - \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --force-yes --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ \ packageName=memcache; \ packageVersion=${MEMCACHE_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ - if test x"4.0.5.2" = x"${packageVersion}"; then \ - packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ - else :; fi; \ if test x"3.0.8" = x"${packageVersion}"; then \ packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ else :; fi; \ \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ diff --git a/.docker/php72_73/Dockerfile b/.docker/php72_73/Dockerfile index 42765befb..ebbaef7b3 100644 --- a/.docker/php72_73/Dockerfile +++ b/.docker/php72_73/Dockerfile @@ -9,20 +9,20 @@ RUN docker-php-ext-install mbstring # ARG APCU_VERSION RUN set -eux; \ - \ - if test x"" = x"${APCU_VERSION}"; then \ - return 0; \ - else :; fi; \ \ packageName=apcu; \ packageVersion=${APCU_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ if test x"5.1.23" = x"${packageVersion}"; then \ packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ @@ -39,24 +39,28 @@ RUN set -eux; \ # ARG MEMCACHE_VERSION RUN set -eux; \ - \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --force-yes --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ \ packageName=memcache; \ packageVersion=${MEMCACHE_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ if test x"4.0.5.2" = x"${packageVersion}"; then \ packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ @@ -66,7 +70,7 @@ RUN set -eux; \ \ docker-php-ext-enable ${packageName}; \ \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ ; \ apt-get clean; \ diff --git a/.docker/php74_83/Dockerfile b/.docker/php74_83/Dockerfile index a55823563..2336ef90d 100644 --- a/.docker/php74_83/Dockerfile +++ b/.docker/php74_83/Dockerfile @@ -21,20 +21,20 @@ RUN set -eux; \ # ARG APCU_VERSION RUN set -eux; \ - \ - if test x"" = x"${APCU_VERSION}"; then \ - return 0; \ - else :; fi; \ \ packageName=apcu; \ packageVersion=${APCU_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ if test x"5.1.23" = x"${packageVersion}"; then \ packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ @@ -51,18 +51,9 @@ RUN set -eux; \ # ARG MEMCACHE_VERSION RUN set -eux; \ - \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --force-yes --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ \ packageName=memcache; \ packageVersion=${MEMCACHE_VERSION}; \ - \ packageFile=${packageName}-${packageVersion}.tgz; \ \ if test x"4.0.5.2" = x"${packageVersion}"; then \ @@ -77,6 +68,19 @@ RUN set -eux; \ packageSha256sum=b3f0640eacdeb9046c6c86a1546d7fb8a4e9f219e5d9a36a287e59b2dd8208e5; \ else :; fi; \ \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ echo "${packageSha256sum} ${packageFile}" \ | sha256sum -cw --status; \ diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 26b4f3b23..b7a59af4e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -46,6 +46,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" + ini-values: apc.enable_cli=on,apc.use_request_time=off,memory_limit=-1,short_open_tag=off,magic_quotes_gpc=off,date.timezone="UTC" - name: Get composer cache directory id: composer-cache @@ -62,4 +63,4 @@ jobs: run: composer install --prefer-dist - name: Run Tests - run: cd tests && php run.php + run: php tests/run.php diff --git a/docker-compose.yml b/docker-compose.yml index b2466a08a..71a58ef70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,14 +4,19 @@ volumes: db_socket: services: - php53: - build: .docker/php53 - working_dir: /app/tests + php53: &services_php + build: + context: .docker/php53 + args: + MEMCACHE_VERSION: '3.0.8' + APC_VERSION: '3.1.13' + working_dir: /app volumes: - .:/app - db_socket:/var/run/mysqld environment: COMPOSER_HOME: /app/var/cache/composer + MEMCACHED_HOST: memcached entrypoint: - sh - -c @@ -23,46 +28,24 @@ services: echo 'magic_quotes_gpc = off' echo 'date.timezone = "UTC"' echo 'apc.enable_cli = on' - echo 'apc.use_request_time = 0' - } | tee -a /usr/local/lib/php.ini + echo 'apc.use_request_time = off' + } | tee -a /usr/local/etc/php/php.ini exec tail -f /dev/null depends_on: - db + - memcached - php54: &services_php54 + php54: + <<: *services_php build: context: .docker/php54 args: MEMCACHE_VERSION: '3.0.8' - environment: - MEMCACHED_HOST: memcached - COMPOSER_HOME: /app/var/cache/composer - working_dir: /app/tests - volumes: - - .:/app - - db_socket:/var/run/mysqld - entrypoint: - - sh - - -c - - | - { - echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' - echo 'memory_limit = -1' - echo 'short_open_tag = off' - echo 'magic_quotes_gpc = off' - echo 'date.timezone = "UTC"' - echo 'apc.enable_cli = on' - echo 'apc.use_request_time = 0' - } | tee -a /usr/local/etc/php/php.ini - - exec tail -f /dev/null - depends_on: - - db - - memcached + APC_VERSION: '3.1.13' php55: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -71,7 +54,7 @@ services: APCU_VERSION: '4.0.11' php56: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -80,7 +63,7 @@ services: APCU_VERSION: '4.0.11' php70: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -89,7 +72,7 @@ services: APCU_VERSION: '' php71: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -98,7 +81,7 @@ services: APCU_VERSION: '' php72: - <<: *services_php54 + <<: *services_php build: context: .docker/php72_73 args: @@ -107,7 +90,7 @@ services: APCU_VERSION: '' php73: - <<: *services_php54 + <<: *services_php build: context: .docker/php72_73 args: @@ -116,7 +99,7 @@ services: APCU_VERSION: '' php74: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -125,7 +108,7 @@ services: APCU_VERSION: '' php80: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -134,7 +117,7 @@ services: APCU_VERSION: '' php81: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -143,23 +126,24 @@ services: APCU_VERSION: '' php82: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: PHP_VERSION: '8.2' - MEMCACHE_VERSION: '8.0' + MEMCACHE_VERSION: '8.2' APCU_VERSION: '' php83: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: PHP_VERSION: '8.3' - MEMCACHE_VERSION: '8.0' + MEMCACHE_VERSION: '8.2' APCU_VERSION: '' + db: image: mysql:5.5.62 environment: diff --git a/tests/bin/test b/tests/bin/test index 201928b0e..435c35202 100755 --- a/tests/bin/test +++ b/tests/bin/test @@ -94,13 +94,13 @@ configureWithArguments () # Commands # DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec -u `id -u`:`id -g`" - COMPOSER_UPDATE='composer update --working-dir=/app --prefer-dist --no-suggest --optimize-autoloader' + COMPOSER_UPDATE='composer update --prefer-dist --no-suggest --optimize-autoloader' # Default Options # DEPENDENCY_PREFERENCES='highest' PHP_VERSIONS='all' - PHP_TEST_RUNTIME='run.php' + PHP_TEST_RUNTIME='tests/run.php' hasHelpOption=false parseOperands ${1+"$@"} diff --git a/tests/run.php b/tests/run.php index d1dd2c7ee..95df36135 100644 --- a/tests/run.php +++ b/tests/run.php @@ -1,5 +1,7 @@ Date: Sat, 20 Jan 2024 21:03:37 +0100 Subject: [PATCH 4/6] fix(test): execution without terminal Error: the input device is not a TTY --- tests/bin/test | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/bin/test b/tests/bin/test index 435c35202..2a5383e27 100755 --- a/tests/bin/test +++ b/tests/bin/test @@ -91,9 +91,11 @@ startDockerComposeServices () configureWithArguments () { + configureDockerComposeExecFlags + # Commands # - DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec -u `id -u`:`id -g`" + DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec ${dockerComposeExecFlags}" COMPOSER_UPDATE='composer update --prefer-dist --no-suggest --optimize-autoloader' # Default Options @@ -112,6 +114,30 @@ configureWithArguments () else :; fi } +configureDockerComposeExecFlags () +{ + dockerComposeExecFlags="-u `id -u`:`id -g`" + + if hasTty; then + : + else + dockerComposeExecFlags="${dockerComposeExecFlags} -T" + fi +} + +hasTty () +{ + test -t 0 || { + return 1 + } + + test -t 1 || { + return 1 + } + + return 0 +} + populatePHPVersions () { if test x'all' = x"${PHP_VERSIONS}"; then From b6204360360c5a76e4b31c401ffed3e36bf00614 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Mon, 8 Apr 2024 21:13:27 +0200 Subject: [PATCH 5/6] feat(test): start service of only targeted php versions --- tests/bin/test | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/bin/test b/tests/bin/test index 2a5383e27..4a68c0720 100755 --- a/tests/bin/test +++ b/tests/bin/test @@ -3,6 +3,8 @@ __DIR__=`dirname "$0"` ROOT_DIR="${__DIR__}/../.." +PHP_VERSIONS_SUPPORTED_PATTERN='(php74|php8)' + main () { importEnvironmentVariablesFromDirectory "${ROOT_DIR}" @@ -11,8 +13,6 @@ main () startDockerComposeServices - populatePHPVersions - runTests } @@ -28,7 +28,7 @@ Usage: Options: --help Show this screen. - --php-versions Select specific php versions. [default: ${PHP_VERSIONS}] + --php-versions Select specific php versions. [default: '`echo ${PHP_VERSIONS}`'] Examples: php53 'php53 php54' @@ -86,7 +86,7 @@ importEnvironmentVariablesFromDirectory () startDockerComposeServices () { echo "+ ${DOCKER_COMPOSE} build" - ${DOCKER_COMPOSE} up -d --build --remove-orphans > /dev/null + ${DOCKER_COMPOSE} up -d --build --remove-orphans ${PHP_VERSIONS} > /dev/null } configureWithArguments () @@ -105,6 +105,8 @@ configureWithArguments () PHP_TEST_RUNTIME='tests/run.php' hasHelpOption=false + populatePHPVersions + parseOperands ${1+"$@"} if ${hasHelpOption}; then @@ -141,13 +143,18 @@ hasTty () populatePHPVersions () { if test x'all' = x"${PHP_VERSIONS}"; then - PHP_VERSIONS=`fetchAllPHPVersions` + PHP_VERSIONS=`fetchSupportedPHPVersions` else :; fi } +fetchSupportedPHPVersions () +{ + fetchAllPHPVersions | grep -E "${PHP_VERSIONS_SUPPORTED_PATTERN}" +} + fetchAllPHPVersions () { - ${DOCKER_COMPOSE} 2>/dev/null ps --services --filter status=running \ + ${DOCKER_COMPOSE} 2>/dev/null ps --services \ | grep php \ | sort } From 2dbee52b3c2569889018b310555afc45ea858b1c Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Mon, 8 Apr 2024 22:12:37 +0200 Subject: [PATCH 6/6] feat: share mysql dsn on environment variable --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 71a58ef70..acc356597 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: environment: COMPOSER_HOME: /app/var/cache/composer MEMCACHED_HOST: memcached + MYSQL_DSN: 'mysql:unix_socket=/var/run/mysqld/mysql.sock;dbname=test;user=root' entrypoint: - sh - -c