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

Work around Travis CI issue with _s download certificate #182

Merged
merged 4 commits into from
Oct 26, 2018
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: 10 additions & 5 deletions features/scaffold.feature
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ Feature: WordPress code scaffolding
Given I run `wp theme path`
And save STDOUT as {THEME_DIR}

When I run `wp scaffold _s starter-theme`
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
When I try `wp scaffold _s starter-theme`
Then STDOUT should contain:
"""
Success: Created theme 'Starter-theme'.
Expand All @@ -351,7 +352,8 @@ Feature: WordPress code scaffolding
Given I run `wp theme path`
And save STDOUT as {THEME_DIR}

When I run `wp scaffold _s starter-theme --sassify`
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
When I try `wp scaffold _s starter-theme --sassify`
Then STDOUT should contain:
"""
Success: Created theme 'Starter-theme'.
Expand All @@ -363,7 +365,8 @@ Feature: WordPress code scaffolding
Given I run `wp theme path`
And save STDOUT as {THEME_DIR}

When I run `wp scaffold _s starter-theme --woocommerce`
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
When I try `wp scaffold _s starter-theme --woocommerce`
Then STDOUT should contain:
"""
Success: Created theme 'Starter-theme'.
Expand All @@ -373,7 +376,8 @@ Feature: WordPress code scaffolding

Scenario: Scaffold starter code for a theme and activate it
Given a WP install
When I run `wp scaffold _s starter-theme --activate`
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
When I try `wp scaffold _s starter-theme --activate`
Then STDOUT should contain:
"""
Success: Switched to 'Starter-theme' theme.
Expand Down Expand Up @@ -488,7 +492,8 @@ Feature: WordPress code scaffolding

Scenario: Scaffold starter code for a theme and network enable it
Given a WP multisite install
When I run `wp scaffold _s starter-theme --enable-network`
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
When I try `wp scaffold _s starter-theme --enable-network`
Then STDOUT should contain:
"""
Success: Network enabled the 'Starter-theme' theme.
Expand Down
18 changes: 15 additions & 3 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,25 @@ public function _s( $args, $assoc_args ) {
$body['underscoresme_woocommerce'] = 1;
}

$tmpfname = wp_tempnam( $url );
$response = wp_remote_post( $url, array(
$tmpfname = wp_tempnam( $url );
$post_args = array(
'timeout' => $timeout,
'body' => $body,
'stream' => true,
'filename' => $tmpfname,
) );
);

$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