Skip to content

Add Bitbucket Pipelines#118

Merged
gitlost merged 27 commits intowp-cli:masterfrom
tfirdaus:master
Feb 27, 2018
Merged

Add Bitbucket Pipelines#118
gitlost merged 27 commits intowp-cli:masterfrom
tfirdaus:master

Conversation

@tfirdaus
Copy link
Contributor

Adding Bitbucket Pipelines as one of the CI providers (Resolve #9), allowing users to specify bitbucket on the wp scaffold command. For examples:

Scaffold Plugin Test:

wp scaffold plugin-tests hello-world --ci=bitbucket

Scaffold Theme Test:

wp scaffold theme-tests p2child --ci=bitbucket

Example repositories with a working pipelines can be found at:

Copy link
Contributor

@gitlost gitlost left a comment

Choose a reason for hiding this comment

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

Thanks very much for the PR @tfirdaus and apologies tor the delay in reviewing. On (albeit very limited) testing by me it works great. Was wondering about the reference to tfirdaus/wp-docklines in the template though?

pipelines:
default:
- step:
image: tfirdaus/wp-docklines:php5.6-fpm-alpine
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to use something more neutral here (and passim) I think rather than your personal stuff! Is there a way to do that??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @gitlost
Thank you for reviewing the pull request.

Yes, that's possible. However, in the case of Bitbucket Pipelines, I'm afraid doing so might harm users sitting on the Free plan as Bitbucket only allocates 50 minutes of build per month on the Free plan. Bitbucket suggests creating our own Docker images that are ready to go as setting up dependencies and tools during the build will be time-consuming.

Here is what that says in one of their articles Tips for scripting tasks with Bitbucket Pipelines

Installing the dependencies necessary for your pipeline to run can be time-consuming. You could save a lot of running time by creating your own Docker image with the basic tools and packages required to build and test your application.

Hence the reason for those personal images 🙂

I'm open to suggestion; if including personal images is not allowed I'm more than happy to change it to a neutral image.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @tfirdaus !

Bitbucket suggests creating our own Docker images that are ready to go as setting up dependencies and tools during the build will be time-consuming.

Ah I see, ta. (Forgive my ignorance, I know next to nothing about Docker also and only just noticed your images here https://hub.docker.com/r/tfirdaus/wp-docklines/)

So perhaps the way to go in the future might be to register wp-cli or similar on Docker Hub and upload the images there. But in the meantime we could use your (oh so personal!) account.

Thanks for the feedback, would like to get input from @schlessera on it - though we're about to release WP-CLI 1.5.0 on Tuesday so may not be in touch immediately...

Copy link
Contributor Author

@tfirdaus tfirdaus Jan 28, 2018

Choose a reason for hiding this comment

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

Understood. I'm happy to transfer the Docker image ownership to WP-CLI official if that's necessary 🙂as the image might also be useful for GitlabCI or CircleCI scaffold command.

Copy link
Member

Choose a reason for hiding this comment

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

@tfirdaus I understand the reason why you added the (personal) image to the script. However, I don't want to include such a custom image in this script for the following reasons:

  • Providing an official WP-CLI image means that the WP-CLI maintainers need to indefinitely maintain this image. I consider this is out of scope for the WP-CLI project.
  • Providing your personal image is a potential security/trust issue. We would basically endorse an unknown black box image. I don't feel comfortable doing this, not because I don't trust you as a person, but because I think that this is just not a good idea in principle. We have no control over that image, so must assume it cannot be trusted.
  • The scaffolding tools are meant to provide a starting point. Having a basic BB Pipelines setup that has a limitation on the free plan is perfectly okay. It still helps people to get started quickly, and they are meant to do adjustments to fit their needs either way.

Given the above, would you be willing to change the PR so that it doesn't include a pre-built image, but rather compiles a minimum set of dependencies on the fly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood and that totally makes sense. I'll rewrite the Pipelines config to the minimum :) Thank you for your feedback @schlessera

@gitlost gitlost added command:scaffold-plugin-tests Related to 'scaffold plugin-tests' command command:scaffold-theme-tests Related to 'scaffold theme-tests' command labels Jan 27, 2018
@tfirdaus
Copy link
Contributor Author

@schlessera & @gitlost I apologize. I think I messed up the commits for this pull requests.
Should I close this PR and create a new one from another branch in the fork?

It appears there might be a compatibility issue with the test suite running on PHP 7.2. All tests went through except for PHP 7.2 https://travis-ci.org/tfirdaus/scaffold-command/builds/342950123. The error says:

Fatal error: Class PHPUnit_Util_Test may not inherit from final class (PHPUnit\Util\Test) in /tmp/behat-wordpress-tests-lib/includes/phpunit6-compat.php on line 18

@gitlost
Copy link
Contributor

gitlost commented Feb 18, 2018

Should I close this PR and create a new one from another branch in the fork?

It's fine as it is @tfirdaus, thanks.

It appears there might be a compatibility issue with the test suite running on PHP 7.2.

Yes, see https://core.trac.wordpress.org/ticket/43218 for the report. I think for the moment we can just explicitly use phpunit 6.5.6 for PHP 7.2 - will do a PR for this.

@tfirdaus
Copy link
Contributor Author

Thanks @gitlost 💯
I'll kick in another commit to trigger the build once #125 is merged :)

@schlessera
Copy link
Member

@tfirdaus We've include a work-around for now. Can you merge latest master? That should fix the tests.

@tfirdaus
Copy link
Contributor Author

Thanks @schlessera 👍 , I'll try to do it on this weekend :)

@tfirdaus
Copy link
Contributor Author

@gitlost and @schlessera thanks, The issue on PHP 7.2 is fixed. All tests are passed as it seems now 💯

@schlessera schlessera requested a review from a team February 25, 2018 09:29
Copy link
Contributor

@gitlost gitlost left a comment

Choose a reason for hiding this comment

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

Thanks @tfirdaus , just a nitpick regarding phpcs induced change.


if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL;
esc_html( "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" ) . PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think to get around the incorrect phpcs echo warning probably best to do

fwrite( STDERR, "Could not find '$_tests_dir/includes/functions.php', have you run bin/install-wp-tests.sh ?" . PHP_EOL );

here, as esc_html() not appropriate for shell output.

Copy link
Contributor Author

@tfirdaus tfirdaus Feb 26, 2018

Choose a reason for hiding this comment

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

Hi, @gitlost
As I recall I did not make this change 🙁.
I'm wondering if it was added when I messed up the commit (I'm not quiet certain on this).

I also think that using esc_html function does not make any sense, as it won't be loaded upon executing install-wp-tests.sh, and looking at the master (https://github.com/wp-cli/scaffold-command/blob/master/templates/plugin-bootstrap.mustache#L15), it should be just echo.

Do you think we can revert it back to echo?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay, it somehow got added in the melee here #118 (commits).

Do you think we can revert it back to echo?

Yes, that's the simplest thing to do, as contrary to what I said above phpcs doesn't seem to object to it anyway, so please just do that, thanks!

@gitlost gitlost merged commit 2a3fa7a into wp-cli:master Feb 27, 2018
@gitlost
Copy link
Contributor

gitlost commented Feb 27, 2018

Thanks @tfirdaus, good stuff! I suppose we could iterate on this to include the testing of different WP_VERSIONs like in plugin-travis.mustache#L25-L28 sometime in the future...

@tfirdaus
Copy link
Contributor Author

Definitely, I think we could do it in the future 👍
@gitlost & @schlessera, thank you for reviewing this PR.

danielbachhuber pushed a commit that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:scaffold-plugin-tests Related to 'scaffold plugin-tests' command command:scaffold-theme-tests Related to 'scaffold theme-tests' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants