.travis.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. language: php
  2. cache:
  3. bundler: true
  4. directories:
  5. - $HOME/tmp/drush
  6. - $HOME/.bundle
  7. apt: true
  8. php:
  9. - 5.4
  10. - 5.5
  11. env:
  12. - PATH=$PATH:/home/travis/.composer/vendor/bin
  13. # This will create the database
  14. mysql:
  15. database: drupal
  16. username: root
  17. encoding: utf8
  18. # To be able to run a webbrowser
  19. # If we need anything more powerful
  20. # than e.g. phantomjs
  21. before_install:
  22. - "export DISPLAY=:99.0"
  23. - "sh -e /etc/init.d/xvfb start"
  24. install:
  25. # Grab Drush
  26. - composer global require drush/drush:dev-master --prefer-source
  27. - cd /home/travis/.composer/vendor/drush/drush && cd -
  28. # Make sure we don't fail when checking out projects
  29. - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
  30. # LAMP package installation (mysql is already started)
  31. - sudo apt-get update
  32. - sudo apt-get install apache2 libapache2-mod-fastcgi
  33. # enable php-fpm, travis does not support any other method with php and apache
  34. - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
  35. - sudo a2enmod rewrite actions fastcgi alias
  36. - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
  37. - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
  38. # Make sure the apache root is in our wanted directory
  39. - echo "$(curl -fsSL https://gist.githubusercontent.com/nickveenhof/11386315/raw/b8abaf9304fe12b5cc7752d39c29c1edae8ac2e6/gistfile1.txt)" | sed -e "s,PATH,$TRAVIS_BUILD_DIR/../drupal,g" | sudo tee /etc/apache2/sites-available/default > /dev/null
  40. # Set sendmail so drush doesn't throw an error during site install.
  41. - echo "sendmail_path='true'" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'`
  42. # Forward the errors to the syslog so we can print them
  43. - echo "error_log=syslog" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'`
  44. # Get latest drupal 8 core
  45. - cd $TRAVIS_BUILD_DIR/..
  46. - git clone --depth 1 --branch 8.0.x http://git.drupal.org/project/drupal.git
  47. # Restart apache and test it
  48. - sudo service apache2 restart
  49. - curl -v "http://localhost"
  50. # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore.
  51. #- composer global require drupal/coder:\>7
  52. before_script:
  53. - cd $TRAVIS_BUILD_DIR/../drupal
  54. # Update drupal core
  55. - git pull origin 8.0.x
  56. # Install the site
  57. - drush -v site-install minimal --db-url=mysql://root:@localhost/drupal --yes
  58. - drush en --yes simpletest
  59. - drush cr
  60. - phpenv rehash
  61. script:
  62. # go to our Drupal module directory
  63. - mkdir $TRAVIS_BUILD_DIR/../drupal/modules/token
  64. - cp -R $TRAVIS_BUILD_DIR/* $TRAVIS_BUILD_DIR/../drupal/modules/token/
  65. # go to our Drupal main directory
  66. - cd $TRAVIS_BUILD_DIR/../drupal
  67. - ls -la $TRAVIS_BUILD_DIR/../drupal/sites/default
  68. # Run the tests
  69. - php core/scripts/run-tests.sh --verbose --color --concurrency 4 --php `which php` --url http://localhost "token" | tee /tmp/test.txt; TEST_EXIT=${PIPESTATUS[0]}
  70. - echo $TEST_EXIT
  71. # Check if we had fails in the run-tests.sh script
  72. # Exit with the inverted value, because if there are no fails found, it will exit with 1 and for us that\
  73. # is a good thing so invert it to 0. Travis has some issues with the exclamation mark in front so we have to fiddle a
  74. # bit.
  75. # Also make the grep case insensitive and fail on run-tests.sh regular fails as well on fatal errors.
  76. - TEST_OUTPUT=$(! egrep -i "([0-9]+ fails)|(PHP Fatal error)|([0-9]+ exceptions)" /tmp/test.txt > /dev/null)$?
  77. - echo $TEST_OUTPUT
  78. - cd $TRAVIS_BUILD_DIR/../drupal/core
  79. - ./vendor/bin/phpunit --verbose --debug ../modules/token/; TEST_PHPUNIT=$?
  80. - echo $TEST_PHPUNIT
  81. # if the TEST_EXIT status is 0 AND the TEST_OUTPUT status is also 0 it means we succeeded, in all other cases we
  82. # failed.
  83. # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore.
  84. #- /home/travis/.composer/vendor/bin/phpcs --standard=/home/travis/.composer/vendor/drupal/coder/coder_sniffer/Drupal --extensions=php,inc,test,module,install --ignore=css/ $TRAVIS_BUILD_DIR/../drupal/modules/search_api
  85. - php -i | grep 'php.ini'
  86. - sudo cat /var/log/apache2/error.log
  87. - sudo cat /var/log/syslog | grep 'php' | cat # Suppress grep exit status 1
  88. # Exit the build
  89. - if [ $TEST_EXIT -eq 0 ] && [ $TEST_OUTPUT -eq 0 ] && [ $TEST_PHPUNIT -eq 0 ]; then exit 0; else exit 1; fi