diff --git a/.travis.yml b/.travis.yml index 7fd8a3d..e889b00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ php: services: - mysql + - docker addons: apt: @@ -31,6 +32,7 @@ script: - composer test # Run linters for the wp-dev-lib files. - composer install --working-dir="tests/composer" # Test Composer integration setup. - composer test --working-dir="tests/composer" # Test Composer integration pre-commit hook. + - docker-compose --file=docker/wp-dev-lib/docker-compose.test.yml run sut # Test the Docker image. - cd tests/composer && export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts # We need Bash shell which might not be available in Composer scripts. - source "$DEV_LIB_PATH/travis.install.sh" - source "$DEV_LIB_PATH/travis.script.sh" diff --git a/docker/wp-dev-lib/Dockerfile b/docker/wp-dev-lib/Dockerfile new file mode 100644 index 0000000..9f7ec3c --- /dev/null +++ b/docker/wp-dev-lib/Dockerfile @@ -0,0 +1,32 @@ +ARG WP_PHP_VERSION=7.4 +FROM wordpress:php${WP_PHP_VERSION}-fpm + +ENV DEBIAN_FRONTEND noninteractive + +# Development tooling dependencies. +RUN apt-get update \ + && apt-get install --yes --no-install-recommends \ + bash less subversion default-mysql-server default-mysql-client libxml2-utils rsync git zip unzip \ + nodejs npm curl \ + && npm install --global npm@latest \ + && rm -rf /var/lib/apt/lists/ + +# Setup xdebug. +RUN pecl install xdebug \ + && docker-php-ext-enable xdebug + +# Install Composer. +RUN curl -s https://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer + +# Keep a copy of our default test config. +COPY config/wp-tests-config.php /tmp/wp-dev-lib/wp-tests-config.php + +# Setup a custom entrypoint that bootstraps the environment. +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh + +VOLUME /tmp/wordpress + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["php-fpm"] diff --git a/docker/wp-dev-lib/config/wp-tests-config.php b/docker/wp-dev-lib/config/wp-tests-config.php new file mode 100644 index 0000000..9eba8a0 --- /dev/null +++ b/docker/wp-dev-lib/config/wp-tests-config.php @@ -0,0 +1,25 @@ +