use ubuntu focal as default container for local tests; WIP allow testing with php...
authorgggeek <giunta.gaetano@gmail.com>
Wed, 23 Nov 2022 11:33:28 +0000 (11:33 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 23 Nov 2022 11:33:28 +0000 (11:33 +0000)
README.md
composer.json
tests/PolyfillTestCase.php
tests/ci/Dockerfile
tests/ci/docker/entrypoint.sh
tests/ci/setup/setup_apache.sh
tests/ci/setup/setup_php.sh
tests/ci/vm.sh

index 64d829c..1f0779d 100644 (file)
--- 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.
 
index 3a241a5..8bcc6ed 100644 (file)
@@ -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": "*",
index 24957fa..4de58f1 100644 (file)
@@ -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';
index d8c4443..792d787 100644 (file)
@@ -1,4 +1,4 @@
-ARG UBUNTU_VERSION=bionic
+ARG UBUNTU_VERSION=focal
 
 FROM ubuntu:${UBUNTU_VERSION}
 
index 4677393..bb3c826 100644 (file)
@@ -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
 
index bdba955..1e012e0 100755 (executable)
@@ -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
 
index 5e245bd..70fb378 100755 (executable)
@@ -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
index 4f72208..ac6ff87 100755 (executable)
@@ -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
 "
 }