Created
August 22, 2015 00:12
-
-
Save emersonthis/ec20ee518430fc60ca0a to your computer and use it in GitHub Desktop.
Example cicle.yml file for unit testing a Wordpress plugin with wp-cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Customize the test machine | |
machine: | |
timezone: | |
America/New_York # Set the timezone | |
# Version of ruby to use | |
php: | |
version: | |
5.6.5 | |
environment: | |
WP_VERSION: latest | |
CIRCLE_ENV: test | |
WP_MULTISITE: 0 | |
WP_CORE_DIR: /home/ubuntu/wordpress-develop | |
WP_TESTS_DIR: /home/ubuntu/wordpress-develop/tests/phpunit | |
plugin_loc: /home/ubuntu/$CIRCLE_PROJECT_REPONAME | |
plugin_slug: $CIRCLE_PROJECT_REPONAME | |
plugin_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug | |
plugin_tests_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug/tests | |
## Customize dependencies | |
dependencies: | |
pre: | |
#enable xdebug. LINE 1/2 to uncomment if you want to run a code coverage report. | |
# - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini | |
#setup WP install | |
- git clone git://develop.git.wordpress.org/ $WP_CORE_DIR; | |
- cd $WP_CORE_DIR && cp wp-tests-config-sample.php wp-tests-config.php && sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php && sed -i "s/yourusernamehere/root/" wp-tests-config.php && sed -i "s/yourpasswordhere//" wp-tests-config.php; | |
# move plugin into tests/src | |
- mv $plugin_loc $plugin_dir; | |
# set up database | |
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot; | |
# setup phpunit | |
- wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && mv phpunit.phar /home/ubuntu/.phpenv/shims/phpunit | |
override: | |
# Circleci build fails if no composer.json found | |
- touch composer.json | |
## tests override | |
test: | |
override: | |
# comment out the below line to run a code coverage report. | |
- cd $plugin_tests_dir; cd ..; pwd; composer install; ls; phpunit | |
## LINE 2/2 to uncomment if you want to run a code coverage report. | |
# - cd $plugin_tests_dir; phpunit --coverage-html $CIRCLE_ARTIFACTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from this. I hacked the last line a bit to match my directory structure.