Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Travis CI from wp scaffold plugin-tests #325

Merged
merged 1 commit into from
Nov 16, 2023
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
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ The following files are always generated:
The following files are also included unless the `--skip-tests` is used:

* `phpunit.xml.dist` is the configuration file for PHPUnit.
* `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite.
* `tests/test-sample.php` is a sample file containing test cases.
Expand Down Expand Up @@ -234,9 +234,8 @@ The following files are also included unless the `--skip-tests` is used:
[--ci=<provider>]
Choose a configuration file for a continuous integration provider.
---
default: travis
default: circle
options:
- travis
- circle
- gitlab
---
Expand Down Expand Up @@ -269,7 +268,7 @@ wp scaffold plugin-tests [<plugin>] [--dir=<dirname>] [--ci=<provider>] [--force
The following files are generated by default:

* `phpunit.xml.dist` is the configuration file for PHPUnit.
* `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite.
* `tests/test-sample.php` is a sample file containing the actual tests.
Expand All @@ -293,9 +292,8 @@ variable.
[--ci=<provider>]
Choose a configuration file for a continuous integration provider.
---
default: travis
default: circle
options:
- travis
- circle
- gitlab
- bitbucket
Expand Down Expand Up @@ -408,7 +406,7 @@ wp scaffold theme-tests [<theme>] [--dir=<dirname>] [--ci=<provider>] [--force]
The following files are generated by default:

* `phpunit.xml.dist` is the configuration file for PHPUnit.
* `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* `tests/bootstrap.php` is the file that makes the current theme active when running the test suite.
* `tests/test-sample.php` is a sample file containing the actual tests.
Expand All @@ -432,9 +430,8 @@ variable.
[--ci=<provider>]
Choose a configuration file for a continuous integration provider.
---
default: travis
default: circle
options:
- travis
- circle
- gitlab
- bitbucket
Expand Down
61 changes: 21 additions & 40 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,29 @@ Feature: Scaffold plugin unit tests
"""
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:
"""
script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs
fi
"""
And the {PLUGIN_DIR}/hello-world/.travis.yml file should contain:
"""
matrix:
include:
- php: 7.4
env: WP_VERSION=latest
- php: 7.3
env: WP_VERSION=latest
- php: 7.2
env: WP_VERSION=latest
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.5
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
- php: 5.6
env: WP_TRAVISCI=phpcs
And the {PLUGIN_DIR}/hello-world/.circleci/config.yml file should contain:
"""
jobs:
php56-build:
<<: *php_job
docker:
- image: circleci/php:5.6
- image: *mysql_image
"""
And the {PLUGIN_DIR}/hello-world/.circleci/config.yml file should contain:
"""
workflows:
version: 2
main:
jobs:
- php56-build
- php70-build
- php71-build
- php72-build
- php73-build
- php74-build
"""

When I run `wp eval "if ( is_executable( '{PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
Expand All @@ -93,7 +78,6 @@ 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 not exist
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
Expand Down Expand Up @@ -133,7 +117,6 @@ 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 not exist
And the {PLUGIN_DIR}/.circleci/config.yml file should contain:
"""
Expand Down Expand Up @@ -167,7 +150,6 @@ Feature: Scaffold plugin unit tests

When I run `wp scaffold plugin-tests hello-world --ci=gitlab`
Then STDOUT should not be empty
And the {PLUGIN_DIR}/.travis.yml file should not exist
And the {PLUGIN_DIR}/.gitlab-ci.yml file should contain:
"""
MYSQL_DATABASE
Expand All @@ -182,7 +164,6 @@ Feature: Scaffold plugin unit tests

When I run `wp scaffold plugin-tests hello-world --ci=bitbucket`
Then STDOUT should not be empty
And the {PLUGIN_DIR}/.travis.yml file should not exist
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
pipelines:
Expand Down
59 changes: 21 additions & 38 deletions features/scaffold-theme-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,29 @@ Feature: Scaffold theme unit tests
<exclude>./tests/test-sample.php</exclude>
"""
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:
"""
script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs
fi
"""
And the {THEME_DIR}/p2child/.travis.yml file should contain:
"""
matrix:
include:
- php: 7.4
env: WP_VERSION=latest
- php: 7.3
env: WP_VERSION=latest
- php: 7.2
env: WP_VERSION=latest
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
- php: 5.6
env: WP_TRAVISCI=phpcs
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
jobs:
php56-build:
<<: *php_job
docker:
- image: circleci/php:5.6
- image: *mysql_image
"""
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
workflows:
version: 2
main:
jobs:
- php56-build
- php70-build
- php71-build
- php72-build
- php73-build
- php74-build
"""

When I run `wp eval "if ( is_executable( '{THEME_DIR}/p2child/bin/install-wp-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
Expand Down Expand Up @@ -133,7 +119,6 @@ Feature: Scaffold theme unit tests
Scenario: Scaffold theme tests with Circle as the provider
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 not exist
And the {THEME_DIR}/p2child/.circleci/config.yml file should contain:
"""
Expand Down Expand Up @@ -167,7 +152,6 @@ Feature: Scaffold theme unit tests
Scenario: Scaffold theme tests with Gitlab as the provider
When I run `wp scaffold theme-tests p2child --ci=gitlab`
Then STDOUT should not be empty
And the {THEME_DIR}/p2child/.travis.yml file should not exist
And the {THEME_DIR}/p2child/.gitlab-ci.yml file should contain:
"""
MYSQL_DATABASE
Expand All @@ -176,7 +160,6 @@ Feature: Scaffold theme unit tests
Scenario: Scaffold theme tests with Bitbucket Pipelines as the provider
When I run `wp scaffold theme-tests p2child --ci=bitbucket`
Then STDOUT should not be empty
And the {THEME_DIR}/p2child/.travis.yml file should not exist
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
pipelines:
Expand Down
38 changes: 14 additions & 24 deletions features/scaffold.feature
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ Feature: WordPress code scaffolding
https://wp-cli.org
https://wp-cli.org
n
travis
circle
Y
n
n
Expand Down Expand Up @@ -473,29 +473,19 @@ Feature: WordPress code scaffolding
When I run `wp scaffold plugin hello-world`
Then STDOUT should not be empty
And the {PLUGIN_DIR}/hello-world/readme.txt file should exist
And the {PLUGIN_DIR}/hello-world/.travis.yml file should exist
And the {PLUGIN_DIR}/hello-world/.travis.yml file should contain:
"""
matrix:
include:
- php: 7.4
env: WP_VERSION=latest
- php: 7.3
env: WP_VERSION=latest
- php: 7.2
env: WP_VERSION=latest
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.5
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
- php: 5.6
env: WP_TRAVISCI=phpcs
And the {PLUGIN_DIR}/hello-world/.circleci/config.yml file should exist
And the {PLUGIN_DIR}/hello-world/.circleci/config.yml file should contain:
"""
workflows:
version: 2
main:
jobs:
- php56-build
- php70-build
- php71-build
- php72-build
- php73-build
- php74-build
"""

@require-php-5.6 @require-wp-4.6
Expand Down
30 changes: 7 additions & 23 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,6 @@ public function underscores( $args, $assoc_args ) {

$response = wp_remote_post( $url, $post_args );

// Workaround to get scaffolding to work within Travis CI.
// See https://github.com/wp-cli/scaffold-command/issues/181
if ( is_wp_error( $response )
&& false !== strpos( $response->get_error_message(), 'gnutls_handshake() failed' )
) {
// Certificate problem, falling back to unsecured request instead.
$alt_url = str_replace( 'https://', 'http://', $url );
WP_CLI::warning( "Secured request to {$url} failed, using {$alt_url} as a fallback." );
$response = wp_remote_post( $alt_url, $post_args );
}

if ( is_wp_error( $response ) ) {
WP_CLI::error( $response );
}
Expand Down Expand Up @@ -580,7 +569,7 @@ private function get_output_path( $assoc_args, $subdir ) {
* The following files are also included unless the `--skip-tests` is used:
*
* * `phpunit.xml.dist` is the configuration file for PHPUnit.
* * `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* * `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* * `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite.
* * `tests/test-sample.php` is a sample file containing test cases.
Expand Down Expand Up @@ -615,9 +604,8 @@ private function get_output_path( $assoc_args, $subdir ) {
* [--ci=<provider>]
* : Choose a configuration file for a continuous integration provider.
* ---
* default: travis
* default: circle
* options:
* - travis
* - circle
* - gitlab
* ---
Expand Down Expand Up @@ -716,7 +704,7 @@ public function plugin( $args, $assoc_args ) {
* The following files are generated by default:
*
* * `phpunit.xml.dist` is the configuration file for PHPUnit.
* * `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* * `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* * `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite.
* * `tests/test-sample.php` is a sample file containing the actual tests.
Expand All @@ -740,9 +728,8 @@ public function plugin( $args, $assoc_args ) {
* [--ci=<provider>]
* : Choose a configuration file for a continuous integration provider.
* ---
* default: travis
* default: circle
* options:
* - travis
* - circle
* - gitlab
* - bitbucket
Expand All @@ -769,7 +756,7 @@ public function plugin_tests( $args, $assoc_args ) {
* The following files are generated by default:
*
* * `phpunit.xml.dist` is the configuration file for PHPUnit.
* * `.travis.yml` is the configuration file for Travis CI. Use `--ci=<provider>` to select a different service.
* * `.circleci/config.yml` is the configuration file for CircleCI. Use `--ci=<provider>` to select a different service.
* * `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
* * `tests/bootstrap.php` is the file that makes the current theme active when running the test suite.
* * `tests/test-sample.php` is a sample file containing the actual tests.
Expand All @@ -793,9 +780,8 @@ public function plugin_tests( $args, $assoc_args ) {
* [--ci=<provider>]
* : Choose a configuration file for a continuous integration provider.
* ---
* default: travis
* default: circle
* options:
* - travis
* - circle
* - gitlab
* - bitbucket
Expand Down Expand Up @@ -890,9 +876,7 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
"{$tests_dir}/bootstrap.php" => self::mustache_render( "{$type}-bootstrap.mustache", $template_data ),
"{$tests_dir}/test-sample.php" => self::mustache_render( "{$type}-test-sample.mustache", $template_data ),
];
if ( 'travis' === $assoc_args['ci'] ) {
$files_to_create[ "{$target_dir}/.travis.yml" ] = self::mustache_render( 'plugin-travis.mustache', compact( 'wp_versions_to_test' ) );
} elseif ( 'circle' === $assoc_args['ci'] ) {
if ( 'circle' === $assoc_args['ci'] ) {
$files_to_create[ "{$target_dir}/.circleci/config.yml" ] = self::mustache_render( 'plugin-circle.mustache', compact( 'wp_versions_to_test' ) );
} elseif ( 'gitlab' === $assoc_args['ci'] ) {
$files_to_create[ "{$target_dir}/.gitlab-ci.yml" ] = self::mustache_render( 'plugin-gitlab.mustache' );
Expand Down
Loading
Loading