diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 112425e..a1e3f1e 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: wp_version: ['6.0', '6.1', '6.2', '6.3', '6.4', '6.5', '6.6', '6.7', '6.8'] - php_version: ['8.0', '8.1', '8.2', '8.3'] + php_version: ['7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout @@ -41,6 +41,6 @@ jobs: push: ${{ github.ref == 'refs/heads/master' }} tags: | humanmade/plugin-tester:wp-${{ matrix.wp_version }}-php${{ matrix.php_version }} - ${{ matrix.php_version == '8.0' && format('humanmade/plugin-tester:wp-{0}', matrix.wp_version) || '' }} - ${{ matrix.php_version == '8.0' && matrix.wp_version == '6.8' && 'humanmade/plugin-tester:latest' || '' }} + ${{ matrix.php_version == '7.4' && format('humanmade/plugin-tester:wp-{0}', matrix.wp_version) || '' }} + ${{ matrix.php_version == '7.4' && matrix.wp_version == '6.8' && 'humanmade/plugin-tester:latest' || '' }} diff --git a/Dockerfile.php7.4 b/Dockerfile.php7.4 new file mode 100644 index 0000000..8e707cd --- /dev/null +++ b/Dockerfile.php7.4 @@ -0,0 +1,51 @@ +FROM public.ecr.aws/docker/library/alpine:3.13 + +ARG WP_VERSION + +RUN apk add -u --no-cache \ + composer \ + curl \ + git \ + imagemagick \ + mysql \ + mysql-client \ + php7 \ + php7-curl \ + php7-dom \ + php7-exif \ + php7-mysqli \ + php7-pecl-imagick \ + php7-simplexml \ + php7-tokenizer \ + php7-xml \ + php7-xmlwriter + +RUN apk add --no-cache php7-pear php7-dev gcc musl-dev make \ + && pecl7 install pcov && echo extension=pcov.so > /etc/php7/conf.d/pcov.ini \ + && apk del php7-pear php7-dev gcc musl-dev make + +# Create php symlink to php7 +RUN ln -sf /usr/bin/php7 /usr/bin/php + +RUN curl -fsSL -o /tmp/wordpress.tar.gz https://wordpress.org/wordpress-${WP_VERSION}.tar.gz \ + && mkdir /wordpress \ + && tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /wordpress \ + && rm /tmp/wordpress.tar.gz + +RUN curl -fsSL -o /tmp/wp-phpunit.tar.gz https://github.com/wp-phpunit/wp-phpunit/archive/${WP_VERSION}.0.tar.gz \ + && mkdir /wp-phpunit \ + && tar --strip-components=1 -zxmf /tmp/wp-phpunit.tar.gz -C /wp-phpunit \ + && rm /tmp/wp-phpunit.tar.gz + +RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql +RUN sh -c 'mysqld_safe --datadir=/var/lib/mysql &' && sleep 4 && mysql -u root -e "CREATE DATABASE wordpress" + +ENV WP_DEVELOP_DIR=/wp-phpunit +ENV WP_PHPUNIT__TESTS_CONFIG=/wp-tests-config.php + +VOLUME ["/code"] +WORKDIR /code +COPY ./docker-entrypoint.sh /entrypoint.sh +COPY ./wp-tests-config.php /wp-tests-config.php +RUN chmod 755 /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 07a5f1b..dae4249 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Simple Docker image for running unit tests for WordPress plugins. -**Supports multiple PHP versions:** 8.0, 8.1, 8.2, 8.3 +**Supports multiple PHP versions:** 7.4, 8.0, 8.1, 8.2, 8.3 To run the tests for your plugin, run this in your plugin directory: @@ -19,18 +19,18 @@ docker run --rm -v "$PWD:/code" humanmade/plugin-tester:wp-6.8-php8.3 ``` Available tags follow the pattern `wp-{version}-php{version}`, e.g.: -- `humanmade/plugin-tester:wp-6.8-php8.3` +- `humanmade/plugin-tester:wp-6.8-php7.4` - `humanmade/plugin-tester:wp-6.7-php8.2` - `humanmade/plugin-tester:wp-6.6-php8.1` - etc. -WordPress-only tags are also available (defaulting to PHP 8.0): +WordPress-only tags are also available (defaulting to PHP 7.4): - `humanmade/plugin-tester:wp-6.8` - `humanmade/plugin-tester:wp-6.7` - `humanmade/plugin-tester:wp-6.6` - etc. -The `latest` tag uses the newest WordPress version with PHP 8.0. +The `latest` tag uses the newest WordPress version with PHP 7.4. You will need `phpunit/phpunit` specified as a Composer dependency of your plugin. Additional arguments can be passed to PHPUnit on the CLI directly, e.g.: