From 75d1098db8144f57090335f82bbea742cae8153e Mon Sep 17 00:00:00 2001 From: gggeek Date: Wed, 23 Nov 2022 11:33:28 +0000 Subject: [PATCH] use ubuntu focal as default container for local tests; WIP allow testing with php 5.4 and 5.5 --- README.md | 2 +- composer.json | 4 +-- tests/PolyfillTestCase.php | 2 +- tests/ci/Dockerfile | 2 +- tests/ci/docker/entrypoint.sh | 3 ++ tests/ci/setup/setup_apache.sh | 5 +-- tests/ci/setup/setup_php.sh | 65 +++++++++++++++++++++++++--------- tests/ci/vm.sh | 4 +-- 8 files changed, 62 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 64d829ce..1f0779d3 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The full sequence of operations is: # and, once you have finished all testing related work: ./tests/ci/vm.sh cleanup -By default tests are run using php 7.2 in a Container based on Ubuntu 18 Bionic. +By default, tests are run using php 7.4 in a Container based on Ubuntu 20 Focal. You can change the version of PHP and Ubuntu in use by setting the environment variables PHP_VERSION and UBUNTU_VERSION before building the Container. diff --git a/composer.json b/composer.json index 3a241a5d..8bcc6edf 100644 --- a/composer.json +++ b/composer.json @@ -8,9 +8,9 @@ "php": "^5.3.0 || ^7.0 || ^8.0", "ext-xml": "*" }, - "_comment::tests": "The dev packages below require a minimum of php 5.6, even though we support php 5.3. Can we manage to do better?", + "_comment::tests": "The dev packages below require a minimum of php 5.4, even though we support php 5.3. Can we manage to do better?", "require-dev": { - "phpunit/phpunit": "^5.0 || ^8.5.14", + "phpunit/phpunit": "^4.8 || ^5.0 || ^8.5.14", "phpunit/phpunit-selenium": "*", "yoast/phpunit-polyfills": "*", "ext-curl": "*", diff --git a/tests/PolyfillTestCase.php b/tests/PolyfillTestCase.php index 24957faa..4de58f1b 100644 --- a/tests/PolyfillTestCase.php +++ b/tests/PolyfillTestCase.php @@ -14,7 +14,7 @@ if ( class_exists( 'PHPUnit_Runner_BaseTestRunner' ) === true class_alias( 'PHPUnit_Runner_BaseTestRunner', 'PHPUnit\Runner\BaseTestRunner' ); } -if (class_exists(PHPUnit_Version::class) === false || version_compare(PHPUnit_Version::id(), '8.0.0', '<')) { +if (class_exists('PHPUnit_Version') === false || version_compare(PHPUnit_Version::id(), '8.0.0', '<')) { include_once __DIR__ . '/PolyfillTestCase7.php'; } else { include_once __DIR__ . '/PolyfillTestCase8.php'; diff --git a/tests/ci/Dockerfile b/tests/ci/Dockerfile index d8c44431..792d7876 100644 --- a/tests/ci/Dockerfile +++ b/tests/ci/Dockerfile @@ -1,4 +1,4 @@ -ARG UBUNTU_VERSION=bionic +ARG UBUNTU_VERSION=focal FROM ubuntu:${UBUNTU_VERSION} diff --git a/tests/ci/docker/entrypoint.sh b/tests/ci/docker/entrypoint.sh index 46773930..bb3c826c 100644 --- a/tests/ci/docker/entrypoint.sh +++ b/tests/ci/docker/entrypoint.sh @@ -38,6 +38,9 @@ fi if [ $(stat -c '%u' "${CONTAINER_USER_HOME}") != "${CONTAINER_USER_UID}" -o $(stat -c '%g' "${CONTAINER_USER_HOME}") != "${CONTAINER_USER_GID}" ]; then chown "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}" chown -R "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}"/.* + if [ -d /usr/local/php ]; then + chown -R "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" /usr/local/php + fi fi # @todo do the same chmod for ${TESTS_ROOT_DIR}, if it's not within CONTAINER_USER_HOME diff --git a/tests/ci/setup/setup_apache.sh b/tests/ci/setup/setup_apache.sh index bdba9550..1e012e0a 100755 --- a/tests/ci/setup/setup_apache.sh +++ b/tests/ci/setup/setup_apache.sh @@ -15,8 +15,9 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 a2enmod rewrite proxy_fcgi setenvif ssl http2 # in case mod-php was enabled (this is the case at least on GHA's ubuntu with php 5.x and shivammathur/setup-php) -# @todo silence errors in a smarter way -rm /etc/apache2/mods-enabled/php* || true +if [ -n "$(ls /etc/apache2/mods-enabled/php* 2>/dev/null)" ]; then + rm /etc/apache2/mods-enabled/php* +fi # configure apache virtual hosts diff --git a/tests/ci/setup/setup_php.sh b/tests/ci/setup/setup_php.sh index 5e245bd4..70fb3780 100755 --- a/tests/ci/setup/setup_php.sh +++ b/tests/ci/setup/setup_php.sh @@ -14,7 +14,11 @@ configure_php_ini() { echo "always_populate_raw_post_data = -1" >> "${1}" # we disable xdebug for speed for both cli and web mode - phpdismod xdebug + if which phpdesmod >/dev/null 2>/dev/null; then + phpdismod xdebug + elif [ -f /usr/local/php/$PHP_VERSION/etc/conf.d/20-xdebug.ini ]; then + mv /usr/local/php/$PHP_VERSION/etc/conf.d/20-xdebug.ini /usr/local/php/$PHP_VERSION/etc/conf.d/20-xdebug.ini.bak + fi } # install php @@ -44,25 +48,54 @@ else fi done - DEBIAN_FRONTEND=noninteractive apt-get install -y language-pack-en-base software-properties-common - LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php - apt-get update - - DEBIAN_FRONTEND=noninteractive apt-get install -y \ - php${PHP_VERSION} \ - php${PHP_VERSION}-cli \ - php${PHP_VERSION}-dom \ - php${PHP_VERSION}-curl \ - php${PHP_VERSION}-fpm \ - php${PHP_VERSION}-mbstring \ - php${PHP_VERSION}-xdebug - - update-alternatives --set php /usr/bin/php${PHP_VERSION} + if [ "${PHP_VERSION}" = 5.3 -o "${PHP_VERSION}" = 5.4 -o "${PHP_VERSION}" = 5.5 ]; then + # NB: this set of packages has only been tested on Focal so far + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + enchant \ + imagemagick \ + libc-client2007e \ + libcurl3-gnutls \ + libmcrypt4 \ + libodbc1 \ + libpq5 \ + libqdbm14 \ + libtinfo5 \ + libxpm4 \ + libxslt1.1 \ + mysql-common \ + zstd + if [ ! -d /usr/include/php ]; then mkdir -p /usr/include/php; fi + + set +e + curl -sSL https://github.com/shivammathur/php5-ubuntu/releases/latest/download/install.sh | bash -s "${PHP_VERSION}" + # we have to do this as the init script we get for starting/stopping php-fpm seems to be faulty... + pkill php-fpm + else + DEBIAN_FRONTEND=noninteractive apt-get install -y language-pack-en-base software-properties-common + LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php + apt-get update + + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + php${PHP_VERSION} \ + php${PHP_VERSION}-cli \ + php${PHP_VERSION}-dom \ + php${PHP_VERSION}-curl \ + php${PHP_VERSION}-fpm \ + php${PHP_VERSION}-mbstring \ + php${PHP_VERSION}-xdebug + + update-alternatives --set php /usr/bin/php${PHP_VERSION} + fi fi PHPVER=$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2>/dev/null) -configure_php_ini /etc/php/${PHPVER}/fpm/php.ini +if [ -d /etc/php/${PHPVER}/fpm ]; then + configure_php_ini /etc/php/${PHPVER}/fpm/php.ini +elif [ -f /usr/local/php/${PHPVER}/etc/php.ini ]; then + configure_php_ini /usr/local/php/${PHPVER}/etc/php.ini +fi # use a nice name for the php-fpm service, so that it does not depend on php version running. Try to make that work # both for docker and VMs diff --git a/tests/ci/vm.sh b/tests/ci/vm.sh index 4f72208b..ac6ff873 100755 --- a/tests/ci/vm.sh +++ b/tests/ci/vm.sh @@ -9,7 +9,7 @@ ACTION="${1}" # Valid values: 'default', 5.6, 7.0 .. 7.4, 8.0 .. 8.1 export PHP_VERSION=${PHP_VERSION:-default} # Valid values: precise (12), trusty (14), xenial (16), bionic (18), focal (20), jammy (22) -export UBUNTU_VERSION=${UBUNTU_VERSION:-bionic} +export UBUNTU_VERSION=${UBUNTU_VERSION:-focal} CONTAINER_USER=docker CONTAINER_BUILD_DIR="/home/${CONTAINER_USER}/build" @@ -42,7 +42,7 @@ Options: Environment variables: to be set before the 'build' action PHP_VERSION default value: 'default', ie. the stock php version from the Ubuntu version in use. Other possible values: 5.6, 7.0 .. 8.1 - UBUNTU_VERSION default value: bionic. Other possible values: xenial, focal, jammy + UBUNTU_VERSION default value: focal. Other possible values: xenial, bionic, jammy " } -- 2.47.0