More tidying.
[yaffs-website] / web / modules / contrib / token / .travis.yml
1 language: php
2 cache:
3   bundler: true
4   directories:
5     - $HOME/tmp/drush
6     - $HOME/.bundle
7   apt: true
8
9 php:
10   - 5.4
11   - 5.5
12
13 env:
14   - PATH=$PATH:/home/travis/.composer/vendor/bin
15
16 # This will create the database
17 mysql:
18   database: drupal
19   username: root
20   encoding: utf8
21
22 # To be able to run a webbrowser
23 # If we need anything more powerful
24 # than e.g. phantomjs
25 before_install:
26   - "export DISPLAY=:99.0"
27   - "sh -e /etc/init.d/xvfb start"
28
29 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   # Restart apache and test it
53   - sudo service apache2 restart
54   - curl -v "http://localhost"
55   # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore.
56   #- composer global require drupal/coder:\>7
57
58 before_script:
59   - cd $TRAVIS_BUILD_DIR/../drupal
60   # Update drupal core
61   - git pull origin 8.0.x
62   # Install the site
63   - drush -v site-install minimal --db-url=mysql://root:@localhost/drupal --yes
64   - drush en --yes simpletest
65   - drush cr
66   - phpenv rehash
67
68 script:
69   # go to our Drupal module directory
70   - mkdir $TRAVIS_BUILD_DIR/../drupal/modules/token
71   - cp -R $TRAVIS_BUILD_DIR/* $TRAVIS_BUILD_DIR/../drupal/modules/token/
72   # go to our Drupal main directory
73   - cd $TRAVIS_BUILD_DIR/../drupal
74   - ls -la $TRAVIS_BUILD_DIR/../drupal/sites/default
75   # Run the tests
76   - 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]}
77   - echo $TEST_EXIT
78   # Check if we had fails in the run-tests.sh script
79   # Exit with the inverted value, because if there are no fails found, it will exit with 1 and for us that\
80   # 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
81   # bit.
82   # Also make the grep case insensitive and fail on run-tests.sh regular fails as well on fatal errors.
83   - TEST_OUTPUT=$(! egrep -i "([0-9]+ fails)|(PHP Fatal error)|([0-9]+ exceptions)" /tmp/test.txt > /dev/null)$?
84   - echo $TEST_OUTPUT
85   - cd $TRAVIS_BUILD_DIR/../drupal/core
86   - ./vendor/bin/phpunit --verbose --debug ../modules/token/; TEST_PHPUNIT=$?
87   - echo $TEST_PHPUNIT
88   # if the TEST_EXIT status is 0 AND the TEST_OUTPUT status is also 0 it means we succeeded, in all other cases we
89   # failed.
90   # Re-enable when trying to get CodeSniffer doesn't return a 403 anymore.
91   #- /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
92   - php -i | grep 'php.ini'
93   - sudo cat /var/log/apache2/error.log
94   - sudo cat /var/log/syslog | grep 'php' | cat # Suppress grep exit status 1
95   # Exit the build
96   - if [ $TEST_EXIT -eq 0 ] && [ $TEST_OUTPUT -eq 0 ] && [ $TEST_PHPUNIT -eq 0 ]; then exit 0; else exit 1; fi