Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Bitbucket Pipelines

Thoriq Firdaus edited this page Dec 18, 2020 · 4 revisions

It is possible to use WP-Docklines in your Bitbucket Pipelines configuration.

Integrated CI/CD for Bitbucket Cloud that's trivial to set up, automating your code from test to production.

Below is an example of a Bitbucket Pipelines configuration to test your plugin or theme on PHP 7.3 and PHP 7.4 using PHPUnit and validate the code standard using PHP Code Sniffer combined with the WordPress Coding Standards.

pipelines:
  default:
    - step:
        image: tfirdaus/wp-docklines:php7.3-fpm-alpine
        name: "PHP 7.3"
        script:
          ## Install project dependencies (PHPCS/PHPUnit) through Composer
          - composer install
          
          ## Run PHPCS
          - vendor/bin/phpcs
          
          ## Run PHPUnit
          - bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
          - vendor/bin/phpunit
        services:
          - database
        services:
          - database

    - step:
        image: tfirdaus/wp-docklines:php7.4-fpm-alpine
        name: "PHP 7.4"
        script:
          ## Install project dependencies (PHPCS/PHPUnit) through Composer
          - composer install
          
          ## Run PHPCS
          - vendor/bin/phpcs
          
          ## Run PHPUnit
          - bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
          - vendor/bin/phpunit
        services:
          - database

definitions:
  services:
    database:
      image: mysql:latest
      environment:
        MYSQL_DATABASE: 'wordpress_tests'
        MYSQL_ROOT_PASSWORD: 'root'

The above configuration assumes that you've generated files needed, such as the bin/install-wp-tests.sh for running PHPUnit tests in your plugin or theme with the WP-CLI scaffold command.

Using WP-CLI

I've made a Pull Request to include Bitbucket Pipeline as the CI provider. The PR has now been merged and possibly be available in the next major release of WP-CLI. You will then be able to run the following command to generate the bitbucket-pipelines.yml, albeit it will be generated with the plain PHP Docker image.

wp scaffold plugin-tests --ci=bitbucket

For further details on the configuration, please refer to the following official references:

References

Clone this wiki locally