|
| 1 | +# @file |
| 2 | +# .travis.yml - Drupal for Travis CI Integration |
| 3 | +# |
| 4 | +# Template provided by https://github.com/LionsAd/drupal_ti. |
| 5 | +# |
| 6 | +# Based for simpletest upon: |
| 7 | +# https://github.com/sonnym/travis-ci-drupal-module-example |
| 8 | + |
1 | 9 | language: php |
2 | | -cache: |
3 | | - bundler: true |
4 | | - directories: |
5 | | - - $HOME/tmp/drush |
6 | | - - $HOME/.bundle |
7 | | - apt: true |
| 10 | + |
| 11 | +sudo: false |
8 | 12 |
|
9 | 13 | php: |
10 | | - - 5.4 |
11 | 14 | - 5.5 |
| 15 | + - 5.6 |
| 16 | + - 7 |
| 17 | + - hhvm |
| 18 | + |
| 19 | +matrix: |
| 20 | + fast_finish: true |
| 21 | + allow_failures: |
| 22 | + - php: 7 |
| 23 | + - php: hhvm |
12 | 24 |
|
13 | 25 | env: |
14 | | - - PATH=$PATH:/home/travis/.composer/vendor/bin |
| 26 | + global: |
| 27 | + # add composer's global bin directory to the path |
| 28 | + # see: https://github.com/drush-ops/drush#install---composer |
| 29 | + - PATH="$PATH:$HOME/.composer/vendor/bin" |
| 30 | + |
| 31 | + # Configuration variables. |
| 32 | + - DRUPAL_TI_MODULE_NAME="file_entity" |
| 33 | + - DRUPAL_TI_SIMPLETEST_GROUP="file_entity" |
| 34 | + |
| 35 | + # Define runners and environment vars to include before and after the |
| 36 | + # main runners / environment vars. |
| 37 | + #- DRUPAL_TI_SCRIPT_DIR_BEFORE="./.drupal_ti/before" |
| 38 | + #- DRUPAL_TI_SCRIPT_DIR_AFTER="./drupal_ti/after" |
| 39 | + |
| 40 | + # The environment to use, supported are: drupal-7, drupal-8 |
| 41 | + - DRUPAL_TI_ENVIRONMENT="drupal-8" |
| 42 | + |
| 43 | + # Drupal specific variables. |
| 44 | + - DRUPAL_TI_DB="drupal_travis_db" |
| 45 | + - DRUPAL_TI_DB_URL="mysql://root:@127.0.0.1/drupal_travis_db" |
| 46 | + # Note: Do not add a trailing slash here. |
| 47 | + - DRUPAL_TI_WEBSERVER_URL="http://127.0.0.1" |
| 48 | + - DRUPAL_TI_WEBSERVER_PORT="8080" |
| 49 | + |
| 50 | + # Simpletest specific commandline arguments, the DRUPAL_TI_SIMPLETEST_GROUP is appended at the end. |
| 51 | + - DRUPAL_TI_SIMPLETEST_ARGS="--verbose --color --concurrency 4 --url $DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT" |
| 52 | + |
| 53 | + # === Behat specific variables. |
| 54 | + # This is relative to $TRAVIS_BUILD_DIR |
| 55 | + - DRUPAL_TI_BEHAT_DIR="./tests/behat" |
| 56 | + # These arguments are passed to the bin/behat command. |
| 57 | + - DRUPAL_TI_BEHAT_ARGS="" |
| 58 | + # Specify the filename of the behat.yml with the $DRUPAL_TI_DRUPAL_DIR variables. |
| 59 | + - DRUPAL_TI_BEHAT_YML="behat.yml.dist" |
| 60 | + # This is used to setup Xvfb. |
| 61 | + - DRUPAL_TI_BEHAT_SCREENSIZE_COLOR="1280x1024x16" |
| 62 | + # The version of seleniumthat should be used. |
| 63 | + - DRUPAL_TI_BEHAT_SELENIUM_VERSION="2.44" |
| 64 | + # Set DRUPAL_TI_BEHAT_DRIVER to "selenium" to use "firefox" or "chrome" here. |
| 65 | + - DRUPAL_TI_BEHAT_DRIVER="phantomjs" |
| 66 | + - DRUPAL_TI_BEHAT_BROWSER="firefox" |
| 67 | + |
| 68 | + # PHPUnit specific commandline arguments. |
| 69 | + - DRUPAL_TI_PHPUNIT_ARGS="--verbose --debug" |
| 70 | + # Specifying the phpunit-core src/ directory is useful when e.g. a vendor/ |
| 71 | + # directory is present in the module directory, which phpunit would then |
| 72 | + # try to find tests in. This option is relative to $TRAVIS_BUILD_DIR. |
| 73 | + #- DRUPAL_TI_PHPUNIT_CORE_SRC_DIRECTORY="./tests/src" |
| 74 | + |
| 75 | + # Code coverage via coveralls.io |
| 76 | + - DRUPAL_TI_COVERAGE="satooshi/php-coveralls:0.6.*" |
| 77 | + # This needs to match your .coveralls.yml file. |
| 78 | + - DRUPAL_TI_COVERAGE_FILE="build/logs/clover.xml" |
| 79 | + |
| 80 | + # Debug options |
| 81 | + #- DRUPAL_TI_DEBUG="-x -v" |
| 82 | + # Set to "all" to output all files, set to e.g. "xvfb selenium" or "selenium", |
| 83 | + # etc. to only output those channels. |
| 84 | + #- DRUPAL_TI_DEBUG_FILE_OUTPUT="selenium xvfb webserver" |
| 85 | + |
| 86 | + matrix: |
| 87 | + # [[[ SELECT ANY OR MORE OPTIONS ]]] |
| 88 | + #- DRUPAL_TI_RUNNERS="phpunit" |
| 89 | + #- DRUPAL_TI_RUNNERS="simpletest" |
| 90 | + #- DRUPAL_TI_RUNNERS="behat" |
| 91 | + - DRUPAL_TI_RUNNERS="phpunit-core simpletest" |
15 | 92 |
|
16 | 93 | # This will create the database |
17 | 94 | mysql: |
18 | | - database: drupal |
| 95 | + database: drupal_travis_db |
19 | 96 | username: root |
20 | 97 | encoding: utf8 |
21 | 98 |
|
22 | 99 | # To be able to run a webbrowser |
23 | 100 | # If we need anything more powerful |
24 | 101 | # than e.g. phantomjs |
25 | 102 | before_install: |
26 | | - - "export DISPLAY=:99.0" |
27 | | - - "sh -e /etc/init.d/xvfb start" |
| 103 | + - composer self-update |
| 104 | + - composer global require "lionsad/drupal_ti:1.*" |
| 105 | + - drupal-ti before_install |
28 | 106 |
|
29 | 107 | install: |
30 | | - # Grab Drush |
31 | | - - composer global require drush/drush:dev-master --prefer-source |
32 | | - - cd /home/travis/.composer/vendor/drush/drush && cd - |
33 | | - # Make sure we don't fail when checking out projects |
34 | | - - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config |
35 | | - # LAMP package installation (mysql is already started) |
36 | | - - sudo apt-get update |
37 | | - - sudo apt-get install apache2 libapache2-mod-fastcgi |
38 | | - # enable php-fpm, travis does not support any other method with php and apache |
39 | | - - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf |
40 | | - - sudo a2enmod rewrite actions fastcgi alias |
41 | | - - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini |
42 | | - - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm |
43 | | - # Make sure the apache root is in our wanted directory |
44 | | - - 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 |
45 | | - # Set sendmail so drush doesn't throw an error during site install. |
46 | | - - echo "sendmail_path='true'" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'` |
47 | | - # Forward the errors to the syslog so we can print them |
48 | | - - echo "error_log=syslog" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'` |
49 | | - # Get latest drupal 8 core |
50 | | - - cd $TRAVIS_BUILD_DIR/.. |
51 | | - - git clone --depth 1 --branch 8.0.x http://git.drupal.org/project/drupal.git |
52 | | - - cd drupal/modules |
53 | | - - git clone --depth 1 --branch 8.x-1.x https://github.com/md-systems/pathauto.git |
54 | | - - git clone --depth 1 --branch 8.x-1.x http://git.drupal.org/project/token.git |
55 | | - # Restart apache and test it |
56 | | - - sudo service apache2 restart |
57 | | - - curl -v "http://localhost" |
58 | | - # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore. |
59 | | - #- composer global require drupal/coder:\>7 |
| 108 | + - drupal-ti install |
60 | 109 |
|
61 | 110 | before_script: |
62 | | - - cd $TRAVIS_BUILD_DIR/../drupal |
63 | | - # Update drupal core |
64 | | - - git pull origin 8.0.x |
65 | | - # Install the site |
66 | | - - drush -v site-install minimal --db-url=mysql://root:@localhost/drupal --yes |
67 | | - - drush en --yes simpletest |
68 | | - - drush cr |
69 | | - - phpenv rehash |
| 111 | + - drupal-ti --include .travis-before-script.sh |
| 112 | + - drupal-ti before_script |
70 | 113 |
|
71 | 114 | script: |
72 | | - # go to our Drupal module directory |
73 | | - - mkdir $TRAVIS_BUILD_DIR/../drupal/modules/file_entity |
74 | | - - cp -R $TRAVIS_BUILD_DIR/* $TRAVIS_BUILD_DIR/../drupal/modules/file_entity/ |
75 | | - # go to our Drupal main directory |
76 | | - - cd $TRAVIS_BUILD_DIR/../drupal |
77 | | - - ls -la $TRAVIS_BUILD_DIR/../drupal/sites/default |
78 | | - # Run the tests |
79 | | - - php core/scripts/run-tests.sh --verbose --color --concurrency 4 --php `which php` --url http://localhost "file_entity" | tee /tmp/test.txt; TEST_EXIT=${PIPESTATUS[0]} |
80 | | - - echo $TEST_EXIT |
81 | | - # Check if we had fails in the run-tests.sh script |
82 | | - # Exit with the inverted value, because if there are no fails found, it will exit with 1 and for us that\ |
83 | | - # 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 |
84 | | - # bit. |
85 | | - # Also make the grep case insensitive and fail on run-tests.sh regular fails as well on fatal errors. |
86 | | - - TEST_OUTPUT=$(! egrep -i "([0-9]+ fails)|(PHP Fatal error)|([0-9]+ exceptions)" /tmp/test.txt > /dev/null)$? |
87 | | - - echo $TEST_OUTPUT |
88 | | - - cd $TRAVIS_BUILD_DIR/../drupal/core |
89 | | - - ./vendor/bin/phpunit --verbose --debug ../modules/file_entity/; TEST_PHPUNIT=$? |
90 | | - - echo $TEST_PHPUNIT |
91 | | - # if the TEST_EXIT status is 0 AND the TEST_OUTPUT status is also 0 it means we succeeded, in all other cases we |
92 | | - # failed. |
93 | | - # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore. |
94 | | - #- /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 |
95 | | - - php -i | grep 'php.ini' |
96 | | - - sudo cat /var/log/apache2/error.log |
97 | | - - sudo cat /var/log/syslog | grep 'php' | cat # Suppress grep exit status 1 |
98 | | - # Exit the build |
99 | | - - if [ $TEST_EXIT -eq 0 ] && [ $TEST_OUTPUT -eq 0 ] && [ $TEST_PHPUNIT -eq 0 ]; then exit 0; else exit 1; fi |
| 115 | + - drupal-ti script |
| 116 | + |
| 117 | +after_script: |
| 118 | + - drupal-ti after_script |
0 commit comments