.travis.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Travis CI configuration file.
  2. # @link https://travis-ci.org/
  3. # For use with the Twenty Sixteen WordPress theme
  4. # @link https://github.com/WordPress/twentysixteen/
  5. # Declare project language and PHP versions to test against.
  6. # @link http://about.travis-ci.org/docs/user/languages/php/
  7. language: php
  8. # Declare versions of PHP to use. Use one decimal max.
  9. php:
  10. - "7.0"
  11. - "5.6"
  12. - "5.5"
  13. - "5.4"
  14. - "5.3"
  15. # Current $required_php_version for WordPress: 5.2.4
  16. - "5.2"
  17. # Ditch sudo and use containers.
  18. # @link http://docs.travis-ci.com/user/migrating-from-legacy/#Why-migrate-to-container-based-infrastructure%3F
  19. # @link http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
  20. sudo: false
  21. # Declare which versions of WordPress to test against.
  22. # Also declare whether or not to test in Multisite.
  23. env:
  24. # Trunk (current version in development is 4.4)
  25. # @link https://github.com/WordPress/WordPress
  26. - WP_VERSION=master WP_MULTISITE=0
  27. # Use this to prepare your build for testing.
  28. # e.g. copy database configurations, environment variables, etc.
  29. # Failures in this section will result in build status 'errored'.
  30. before_script:
  31. # Set up WordPress installation.
  32. - export WP_DEVELOP_DIR=/tmp/wordpress/
  33. - mkdir -p $WP_DEVELOP_DIR
  34. # Use the Git mirror of WordPress.
  35. - git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_DEVELOP_DIR
  36. # Set up Twenty Sixteen theme information.
  37. - theme_slug=$(basename $(pwd))
  38. - theme_dir=$WP_DEVELOP_DIR/src/wp-content/themes/$theme_slug
  39. - cd ..
  40. - mv $theme_slug $theme_dir
  41. # Set up WordPress configuration.
  42. - cd $WP_DEVELOP_DIR
  43. - echo $WP_DEVELOP_DIR
  44. - cp wp-tests-config-sample.php wp-tests-config.php
  45. - sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
  46. - sed -i "s/yourusernamehere/root/" wp-tests-config.php
  47. - sed -i "s/yourpasswordhere//" wp-tests-config.php
  48. # Create WordPress database.
  49. - mysql -e 'CREATE DATABASE wordpress_test;' -uroot
  50. # Install CodeSniffer for WordPress Coding Standards checks.
  51. - mkdir php-codesniffer && curl -L https://github.com/squizlabs/PHP_CodeSniffer/archive/master.tar.gz | tar xz --strip-components=1 -C php-codesniffer
  52. # Install WordPress Coding Standards.
  53. - mkdir wordpress-coding-standards && curl -L https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/master.tar.gz | tar xz --strip-components=1 -C wordpress-coding-standards
  54. # Hop into CodeSniffer directory.
  55. - cd php-codesniffer
  56. # Set install path for WordPress Coding Standards
  57. # @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
  58. - scripts/phpcs --config-set installed_paths ../wordpress-coding-standards
  59. # Hop into themes directory.
  60. - cd $theme_dir
  61. # After CodeSniffer install you should refresh your path.
  62. - phpenv rehash
  63. # Install JSCS: JavaScript Code Style checker
  64. # @link http://jscs.info/
  65. - npm install -g jscs
  66. # Install JSHint, a JavaScript Code Quality Tool
  67. # @link http://jshint.com/docs/
  68. - npm install -g jshint
  69. - wget https://develop.svn.wordpress.org/trunk/.jshintrc
  70. # Run test script commands.
  71. # Default is specific to project language.
  72. # All commands must exit with code 0 on success. Anything else is considered failure.
  73. script:
  74. # Search theme for PHP syntax errors.
  75. - find . \( -name '*.php' \) -exec php -lf {} \;
  76. # Run the theme through JSHint
  77. - jshint .
  78. # Run the theme through JavaScript Code Style checker
  79. - jscs .
  80. # WordPress Coding Standards
  81. # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
  82. # @link http://pear.php.net/package/PHP_CodeSniffer/
  83. # -p flag: Show progress of the run.
  84. # -s flag: Show sniff codes in all reports.
  85. # -v flag: Print verbose output.
  86. # -n flag: Do not print warnings (shortcut for --warning-severity=0)
  87. # --standard: Use WordPress as the standard.
  88. # --extensions: Only sniff PHP files.
  89. - $WP_DEVELOP_DIR/php-codesniffer/scripts/phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php