Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.editorconfig
.travis.yml
behat.yml
circle.yml
.circleci/config.yml
bitbucket-pipelines.yml
bin/
features/
Expand Down
63 changes: 39 additions & 24 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Feature: Scaffold plugin unit tests
And the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist
And the {PLUGIN_DIR}/hello-world/phpcs.xml.dist file should exist
And the {PLUGIN_DIR}/hello-world/circle.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.circleci directory should not exist
And the {PLUGIN_DIR}/hello-world/bitbucket-pipelines.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.gitlab-ci.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.travis.yml file should contain:
Expand All @@ -62,7 +63,7 @@ Feature: Scaffold plugin unit tests
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.4
env: WP_VERSION=4.5
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
Expand All @@ -86,9 +87,22 @@ Feature: Scaffold plugin unit tests
When I run `wp plugin path hello-world --dir`
Then save STDOUT as {PLUGIN_DIR}
And the {PLUGIN_DIR}/.travis.yml file should not exist
And the {PLUGIN_DIR}/circle.yml file should contain:
And the {PLUGIN_DIR}/circle.yml file should not exist
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
version: 5.6.22
version: 2
"""
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
php56-build
"""
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
php70-build
"""
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
php71-build
"""

Scenario: Scaffold plugin tests with Circle as the provider, part two
Expand All @@ -101,27 +115,28 @@ Feature: Scaffold plugin unit tests
When I run `wp scaffold plugin-tests hello-world --ci=circle`
Then STDOUT should not be empty
And the {PLUGIN_DIR}/.travis.yml file should not exist
And the {PLUGIN_DIR}/circle.yml file should contain:
"""
version: 5.6.22
"""
And the {PLUGIN_DIR}/circle.yml file should contain:
"""
- |
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 4.4
phpunit
WP_MULTISITE=1 phpunit
- |
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 latest
phpunit
WP_MULTISITE=1 phpunit
- |
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 trunk
phpunit
WP_MULTISITE=1 phpunit
And the {PLUGIN_DIR}/circle.yml file should not exist
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
version: 2
"""
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 4.5 $SKIP_DB_CREATE
phpunit
WP_MULTISITE=1 phpunit
SKIP_DB_CREATE=true
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest $SKIP_DB_CREATE
phpunit
WP_MULTISITE=1 phpunit
SKIP_DB_CREATE=true
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 trunk $SKIP_DB_CREATE
phpunit
WP_MULTISITE=1 phpunit
SKIP_DB_CREATE=true
"""

Scenario: Scaffold plugin tests with Gitlab as the provider
Expand Down
18 changes: 16 additions & 2 deletions features/scaffold-theme-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Feature: Scaffold theme unit tests
And the {THEME_DIR}/p2child/phpunit.xml.dist file should exist
And the {THEME_DIR}/p2child/phpcs.xml.dist file should exist
And the {THEME_DIR}/p2child/circle.yml file should not exist
And the {THEME_DIR}/p2child/.circleci directory should not exist
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should not exist
And the {THEME_DIR}/p2child/.gitlab-ci.yml file should not exist
And the {THEME_DIR}/p2child/.travis.yml file should contain:
Expand Down Expand Up @@ -125,9 +126,22 @@ Feature: Scaffold theme unit tests
When I run `wp scaffold theme-tests p2child --ci=circle`
Then STDOUT should not be empty
And the {THEME_DIR}/p2child/.travis.yml file should not exist
And the {THEME_DIR}/p2child/circle.yml file should contain:
And the {THEME_DIR}/p2child/circle.yml file should not exist
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
version: 2
"""
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
php56-build
"""
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
php70-build
"""
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
version: 5.6.22
php71-build
"""

Scenario: Scaffold theme tests with Gitlab as the provider
Expand Down
2 changes: 1 addition & 1 deletion features/scaffold.feature
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ Feature: WordPress code scaffolding
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.4
env: WP_VERSION=4.5
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
Expand Down
2 changes: 1 addition & 1 deletion src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
if ( 'travis' === $assoc_args['ci'] ) {
$files_to_create["{$target_dir}/.travis.yml"] = self::mustache_render( 'plugin-travis.mustache', compact( 'wp_versions_to_test' ) );
} else if ( 'circle' === $assoc_args['ci'] ) {
$files_to_create["{$target_dir}/circle.yml"] = self::mustache_render( 'plugin-circle.mustache', compact( 'wp_versions_to_test' ) );
$files_to_create["{$target_dir}/.circleci/config.yml"] = self::mustache_render( 'plugin-circle.mustache', compact( 'wp_versions_to_test' ) );
} else if ( 'gitlab' === $assoc_args['ci'] ) {
$files_to_create["{$target_dir}/.gitlab-ci.yml"] = self::mustache_render( 'plugin-gitlab.mustache' );
} else if ( 'bitbucket' === $assoc_args['ci'] ) {
Expand Down
147 changes: 110 additions & 37 deletions templates/plugin-circle.mustache
Original file line number Diff line number Diff line change
@@ -1,39 +1,112 @@
machine:
php:
version: 5.6.22
environment:
WP_TESTS_DIR: /tmp/wordpress-tests-lib
WP_CORE_DIR: /tmp/wordpress/
PATH: $HOME/.composer/vendor/bin:$PATH
workflows:
version: 2
main:
jobs:
- php56-build
- php70-build
- php71-build

dependencies:
pre:
- sudo apt-get update; sudo apt-get install subversion
version: 2
jobs:
php56-build:
docker:
- image: circleci/php:5.6
- image: circleci/mysql:5.7
environment:
- WP_TESTS_DIR: "/tmp/wordpress-tests-lib"
- WP_CORE_DIR: "/tmp/wordpress/"
steps:
- checkout
- run:
name: "Setup Environment Variables"
command: |
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV
source /home/circleci/.bashrc
- run:
name: "Install Dependencies"
command: |
sudo apt-get update && sudo apt-get install subversion
sudo docker-php-ext-install mysqli
sudo sh -c "printf '\ndeb http://ftp.us.debian.org/debian sid main\n' >> /etc/apt/sources.list"
sudo apt-get update && sudo apt-get install mysql-client-5.7
- run:
name: "Run Tests"
command: |
composer global require "phpunit/phpunit=5.7.*"
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
phpcs
SKIP_DB_CREATE=false
{{#wp_versions_to_test}}
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 {{.}} $SKIP_DB_CREATE
phpunit
WP_MULTISITE=1 phpunit
SKIP_DB_CREATE=true
{{/wp_versions_to_test}}

test:
pre:
- composer global require "phpunit/phpunit=5.7.*"
- |
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
override:
- phpcs
{{#wp_versions_to_test}}
- |
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 {{.}}
phpunit
WP_MULTISITE=1 phpunit
{{/wp_versions_to_test}}
- |
phpenv global 7.0.17
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 latest
phpunit
WP_MULTISITE=1 phpunit
- |
phpenv global 7.1.3
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 latest
phpunit
WP_MULTISITE=1 phpunit
php70-build:
docker:
- image: circleci/php:7.0
- image: circleci/mysql:5.7
environment:
- WP_TESTS_DIR: "/tmp/wordpress-tests-lib"
- WP_CORE_DIR: "/tmp/wordpress/"
steps:
- checkout
- run:
name: "Setup Environment Variables"
command: |
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV
source /home/circleci/.bashrc
- run:
name: "Install Dependencies"
command: |
sudo apt-get update && sudo apt-get install subversion
sudo docker-php-ext-install mysqli
sudo sh -c "printf '\ndeb http://ftp.us.debian.org/debian sid main\n' >> /etc/apt/sources.list"
sudo apt-get update && sudo apt-get install mysql-client-5.7
- run:
name: "Run Tests"
command: |
composer global require "phpunit/phpunit=5.7.*"
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
phpcs
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
phpunit
WP_MULTISITE=1 phpunit

php71-build:
docker:
- image: circleci/php:7.1
- image: circleci/mysql:5.7
environment:
- WP_TESTS_DIR: "/tmp/wordpress-tests-lib"
- WP_CORE_DIR: "/tmp/wordpress/"
steps:
- checkout
- run:
name: "Setup Environment Variables"
command: |
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV
source /home/circleci/.bashrc
- run:
name: "Install Dependencies"
command: |
sudo apt-get update && sudo apt-get install subversion
sudo docker-php-ext-install mysqli
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing the MySQLi extension seemed to do the trick. Tests ran perfectly for me with this new config.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @travislopes , stole that from #118. Not sure about the way it's installing mysql-client-5.7 (which is missing from circleci docker image), seems kludgey...

sudo sh -c "printf '\ndeb http://ftp.us.debian.org/debian sid main\n' >> /etc/apt/sources.list"
sudo apt-get update && sudo apt-get install mysql-client-5.7
- run:
name: "Run Tests"
command: |
composer global require "phpunit/phpunit=5.7.*"
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
phpcs
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
phpunit
WP_MULTISITE=1 phpunit
2 changes: 1 addition & 1 deletion templates/plugin-distignore.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Thumbs.db
behat.yml
bitbucket-pipelines.yml
bin
circle.yml
.circleci/config.yml
composer.json
composer.lock
Gruntfile.js
Expand Down
2 changes: 1 addition & 1 deletion templates/plugin-readme.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: (this should be a list of wordpress.org userid's)
Donate link: https://example.com/
Tags: comments, spam
Requires at least: 4.4
Requires at least: 4.5
Tested up to: {{plugin_tested_up_to}}
Stable tag: 0.1.0
License: GPLv2 or later
Expand Down