[WordPress] ワードプレスのプラグインの circleci を構成する方法

スポンサーリンク

質問

私のプロジェクト は、ワードプレスのプラグイン。継続的インテグレーションの circleci を使用しています

は、phpunit の私のテストを実行できるように私の circle.yml ファイルを設定ましょう。私は CI 環境にワードプレスなどをインストールする 次の使用例 を次します。ここでは、何が私のため動作しません:

## Customize test commands
test:

  pre:
    # download wordpress for wp-cli to use
    - curl -s https://wordpress.org/latest.tar.gz > /tmp/wordpress.tar.gz
    - tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /tmp/wordpress
    - curl -s https://raw.github.com/markoheijnen/wp-mysqli/master/db.php > /tmp/wordpress/wp-content/db.php

    # Create DB. No password is required for the MySQL user `ubuntu`
    - mysql -u ubuntu -e "create database wordpress"

    # Download WordPress into `wordpress` directory
    - ./vendor/wp-cli/wp-cli/bin/wp core download --allow-root --path=wordpress

    # Generate `wp-config.php` file
    - ./vendor/wp-cli/wp-cli/bin/wp core config --allow-root --dbname=wordpress --dbuser=ubuntu --dbhost=localhost --path=wordpress

    # Install WordPress
    - ./vendor/wp-cli/wp-cli/bin/wp core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@example.com --url=http://wp-github-pipeline.dev:8080 --title=WordPress --path=wordpress

    # Clone Pipeline plugin from GitHub
    - git clone git@github.com:TransitScreen/wp-github-pipeline.git wordpress/wp-content/plugins/wp-github-pipeline

    #install dependencies
    - cd wordpress/wp-content/plugins/wp-github-pipeline
    - composer install

    # And use WP-CLI to activate it
    # ERROR HAPPENS HERE!!
    - ./vendor/wp-cli/wp-cli/bin/wp plugin activate wp-github-pipeline --path=wordpress

  override:
    - phpunit # use PHPunit for testing

これは上記のコメントに記載されているエラー:

PHP Fatal error:  Cannot redeclare cli\render() (previously declared in phar:///home/ubuntu/wp-github-pipeline/wp-cli.phar/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /home/ubuntu/wp-github-pipeline/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28

Fatal error: Cannot redeclare cli\render() (previously declared in phar:///home/ubuntu/wp-github-pipeline/wp-cli.phar/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /home/ubuntu/wp-github-pipeline/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28 ./wp-cli.phar plugin activate wp-github-pipeline --path=wordpress r

答え

ここですどのような最終的に得た、 この から適応:

## Customize the test machine
machine:
  timezone:
      America/New_York # Set the timezone

    # Version of ruby to use
  php:
    version:
      5.6.5

  environment:
    WP_VERSION: latest
    CIRCLE_ENV: test
    WP_MULTISITE: 0 
    WP_CORE_DIR: /home/ubuntu/wordpress-develop 
    WP_TESTS_DIR: /home/ubuntu/wordpress-develop/tests/phpunit 
    plugin_loc: /home/ubuntu/$CIRCLE_PROJECT_REPONAME 
    plugin_slug: $CIRCLE_PROJECT_REPONAME 
    plugin_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug 
    plugin_tests_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug/tests



## Customize dependencies
dependencies:
  pre:
    #enable xdebug.  LINE 1/2 to uncomment if you want to run a code coverage report.
    # - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini
    #setup WP install
    - git clone git://develop.git.wordpress.org/ $WP_CORE_DIR;
    - cd $WP_CORE_DIR && cp wp-tests-config-sample.php wp-tests-config.php && sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php && sed -i "s/yourusernamehere/root/" wp-tests-config.php && sed -i "s/yourpasswordhere//" wp-tests-config.php;
    # move plugin into tests/src
    - mv $plugin_loc $plugin_dir;
    # set up database
    - mysql -e 'CREATE DATABASE wordpress_test;' -uroot;
    # setup phpunit
    - wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && mv phpunit.phar /home/ubuntu/.phpenv/shims/phpunit

  override:
    - touch composer.json
    - ls

## tests override
test:
  override:
    # comment out the below line to run a code coverage report.
    - cd $plugin_tests_dir; cd ..; pwd; composer install; ls; phpunit
    ## LINE 2/2 to uncomment if you want to run a code coverage report.
    # - cd $plugin_tests_dir; phpunit --coverage-html $CIRCLE_ARTIFACTS

http://stackoverflow.com/questions/32150388/how-to-configure-circleci-for-wordpress-plugin

スポンサーリンク

Leave a Reply