WordPress Testing and Build Container - With PHP, Nodejs & Grunt
3.1K
So in my workflow I use the following:
For this to work under gitlab and gitlab-ci I need a docker which would essentially have the following:
In this attempt, I am creating a docker which would have the following installed by default, so that I don't have to everytime.
PHP-7.0Nodejs and npmGrunt-CLI installed globally.Bower installed globally.Gitvim wget zip unzip subversion mysql-client libmcrypt-dev libmysqlclient-dev zip unzip openssh-client gettextPHPUnit - PHAR Install.Composer - PHAR Install.WP-CLI setup for WordPress unit testing: ( /usr/local/bin/wp )
WP_CORE_DIRWP_TESTS_DIRFor WP_UnitTest the following environment variables are set:
WP_CORE_DIR "/tmp/wordpress/"WP_TESTS_DIR "/tmp/wordpress-tests-lib"WP_VERSION "4.8"WP_TESTS_TAG "tags/4.8"So if you have used WP-CLI to scaffold your PHP_UnitTest (which you should), you are covered. The install will run to only setup the databse variables and the test-config file.
.gitlab-ci.yml configuration# Our base image
image: wpquark/wptest-php-nodejs-grunt:latest
# mysql service
services:
- mysql
# Select what we should cache
cache:
paths:
- vendor/
- node_modules/
before_script:
# Install npm dependencies
- npm install
# Install composer
- composer install
# Install WordPress PHPUnit Test
- bash bin/install-wp-tests.sh wordpress_test root mysql mysql $WP_VERSION
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: wordpress_tests
MYSQL_ROOT_PASSWORD: mysql
WP_MULTISITE: "0"
# We test on php7
# default job
default-job:
tags:
- wordpress
script:
- grunt
except:
- tags
# release job on tag
release-job:
tags:
- wordpress
script:
- grunt release
artifacts:
paths:
- build/wpq-social-press.zip
only:
- tags
The above is just a sample. In real world, we use multiple stages with test > build > deploy (staging > production) strategy. Check gitlab documentation for information on that.
Content type
Image
Digest
Size
729.7 MB
Last updated
about 9 years ago
docker pull wpquark/wptest-php-nodejs-grunt