Browse Source

Better Travis CI

NEW:
Cleaned up routines for better readability of both declaration and results.
PHP versions now really covered.
    The old code forced install of PHP and didn't use Travis provided versions.
    This resulted in the process not being executed with the declared PHP version.
Dropped MySQL in favor of MariaDB.
    This is now the FLOSS community standard.
    This should help avoid problems with buggy MySQL releases.
Fast finish enabled to show results faster.
Optimized tools installation with composer.
    The right version of the tool is installed for the PHP version under test.
New PHP linter to check for syntax errors.
    Parallelized for better speed.
Apache + PHP FPM for testing webservices.
    The previous mod_php configuration was not supported on Travis.
New global DEBUG environment variable to show verbose output with configuration files content.
IRC notification on #dolibarr@freenode for community awareness.

FIXES:
Bug in scripts preventing execution with environmentalized PHP.
Wrong detection of MAIN_URL_ROOT under specific circumstances.
    $_SERVER["DOCUMENT_ROOT"] empty and $_SERVER["SCRIPT_NAME"] populated.
Relative ignore directive in coding style ruleset to avoid bypassing test.
Unit test errors without an exit status.
    This prevented the CI from properly detecting and reporting the error.

TODOS:
PostgreSQL support.
    This one is tricky since we only have a MySQL dump and the syntax is not directly compatible.
SQLite support.
    Disabled in core at the moment.
Nginx + PHP FPM support.
    Test webservices on the second most popular webserver.
Run dev/* checks.
    We have a nice collection of scripts we could leverage.
Check Javascript.
Check CSS.
Check SQL.
Raphaël Doursenaud 9 years ago
parent
commit
bbe7498de6
48 changed files with 370 additions and 211 deletions
  1. 294 140
      .travis.yml
  2. 1 1
      build/aps/configure.php
  3. 1 1
      build/generate_filecheck_xml.php
  4. 18 0
      build/travis-ci/apache.conf
  5. 0 18
      composer.json.phpcs
  6. 6 6
      dev/codesniffer/ruleset.xml
  7. 1 1
      dev/examples/create_invoice.php
  8. 1 1
      dev/examples/create_order.php
  9. 1 1
      dev/examples/create_product.php
  10. 1 1
      dev/examples/create_user.php
  11. 1 1
      dev/examples/get_contracts.php
  12. 1 1
      dev/initdata/generate-invoice.php
  13. 1 1
      dev/initdata/generate-order.php
  14. 1 1
      dev/initdata/generate-product.php
  15. 1 1
      dev/initdata/generate-proposal.php
  16. 1 1
      dev/initdata/generate-thirdparty.php
  17. 1 1
      dev/initdata/sftpget_and_loaddump.php
  18. 1 1
      dev/skeletons/build_api_class.php
  19. 1 1
      dev/skeletons/build_class_from_table.php
  20. 1 1
      dev/skeletons/build_webservice_from_class.php
  21. 1 1
      dev/skeletons/skeleton_script.php
  22. 1 1
      dev/translation/autotranslator.php
  23. 1 1
      dev/translation/sanity_check_en_langfiles.php
  24. 1 1
      dev/translation/strip_language_file.php
  25. 5 1
      htdocs/filefunc.inc.php
  26. 2 1
      scripts/accountancy/export-thirdpartyaccount.php
  27. 1 1
      scripts/bank/export-bank-receipts.php
  28. 1 1
      scripts/company/export-contacts-xls-example.php
  29. 1 1
      scripts/company/sync_contacts_dolibarr2ldap.php
  30. 1 1
      scripts/contracts/email_expire_services_to_customers.php
  31. 1 1
      scripts/contracts/email_expire_services_to_representatives.php
  32. 1 1
      scripts/cron/cron_run_jobs.php
  33. 1 1
      scripts/emailings/mailing-send.php
  34. 1 1
      scripts/invoices/email_unpaid_invoices_to_customers.php
  35. 1 1
      scripts/invoices/email_unpaid_invoices_to_representatives.php
  36. 1 1
      scripts/invoices/rebuild_merge_pdf.php
  37. 1 1
      scripts/members/sync_members_dolibarr2ldap.php
  38. 1 1
      scripts/members/sync_members_ldap2dolibarr.php
  39. 1 1
      scripts/product/migrate_picture_path.php
  40. 1 1
      scripts/user/sync_groups_dolibarr2ldap.php
  41. 1 1
      scripts/user/sync_groups_ldap2dolibarr.php
  42. 1 1
      scripts/user/sync_users_dolibarr2ldap.php
  43. 1 1
      scripts/user/sync_users_ldap2dolibarr.php
  44. 1 1
      scripts/withdrawals/build_withdrawal_file.php
  45. 4 4
      test/phpunit/AllTests.php
  46. 1 1
      test/phpunit/ContactTest.php
  47. 1 1
      test/phpunit/PricesTest.php
  48. 1 1
      test/phpunit/WebservicesProductsTest.php

+ 294 - 140
.travis.yml

@@ -1,154 +1,308 @@
 # This script is used by Travis CI to run automatically Continuous test integration
 # from Dolibarr GitHub repository.
-# Command run is phpunit
 # For syntax, see http://about.travis-ci.org/docs/user/languages/php/
 
-notifications:
-  email:
-    on_success: never # [always|never|change] default: change
-    on_failure: change # [always|never|change] default: always
-    
+sudo: required
+
+language: php
+
+php:
+- '5.3'
+- '5.4'
+- '5.5'
+- '5.6'
+- '7.0'
+- nightly
+
 addons:
-  postgresql: "9.3"
+  mariadb: '10.0'
+  # FIXME: find a way to import a MySQL dump into PostgreSQL
+  #postgresql: '9.3'
+  apt:
+    packages:
+    # We need a webserver to test the webservices
+    # Let's install Apache with.
+    - apache2
+    # mod_php is not supported by Travis. Add fcgi. We install FPM later on.
+    - libapache2-mod-fastcgi
 
+# Start on every boot
 services:
- - memcached # will start memcached
+- memcached
 
-# This will tell travis to run phpunit
-language: php
-php:
- - 5.3
- - 5.4
- - 5.5 
- - 5.6
- - 7.0
+env:
+  global:
+  # Set to true for very verbose output
+  - DEBUG=false
+  matrix:
+  # MariaDB overrides MySQL installation so it's not possible to test both yet
+  #- DB=mysql
+  - DB=mariadb
+  # FIXME: find a way to import a MySQL dump into PostgreSQL
+  #- DB=postgresql
+  # TODO
+  #- DB=sqlite
+  # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP
+  #- WS=apache
+  # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test
+  #- WS=nginx
 
 matrix:
+  fast_finish: true
   allow_failures:
-    - php: 7.0
+  - php: '7.0'
+  - php: nightly
+  # FIXME
+  #- env: DB=postgresql
+  # TODO
+  #- env: DB=sqlite
 
-env:
- - DB=mysql
-# - DB=postgres  
-
-before_script: 
- - echo Start travis
- - echo Current dir is `pwd`
- - echo Home dir is `echo ~`
- - export PHPV=`phpenv version-name`
- - echo PHP version $PHPV 
-# - echo Update composer
-# - ~/.phpenv/versions/$(phpenv version-name)/bin/composer.phar self-update 
- - echo PHPUnit version
- - which phpunit
- - phpunit --version
- - echo Install phpcs then show installed rules
- - cp composer.json composer.json.old
- - cp composer.json.phpcs composer.json
- - composer self-update
- - composer require squizlabs/php_codesniffer:"^2.0.0"
- - composer install
- - phpenv rehash
- - htdocs/includes/squizlabs/php_codesniffer/scripts/phpcs --version
- - htdocs/includes/squizlabs/php_codesniffer/scripts/phpcs -i
-# - which phpcs
-# - phpcs --version
-# - phpcs -i
- - echo Create dir $(pwd)/htdocs/documents
- - sudo mkdir -p $(pwd)/htdocs/documents/admin/temp;
- - sudo touch $(pwd)/htdocs/documents/dolibarr.log;
- - sudo chmod a+rwx /home; sudo chmod a+rwx /home/travis; sudo chmod -R a+rwx /home/travis/build;
- - sudo chmod -R a+rwx $(pwd);
- - sudo chown -R www-data:travis $(pwd)/htdocs/documents;
- - find $(pwd)/htdocs/documents -type d -exec ls -alt {} \;
- - echo Edit php.ini file
- - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-# - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- - sh -c "if [ '$PHPV' = '5.3' ]; then echo 'extension = apc.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- - sh -c "if [ '$PHPV' = '5.4' ]; then echo 'extension = apc.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- - sh -c "if [ '$PHPV' = '5.3' ]; then echo 'zend_extension_ts = xdebug.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- - sh -c "if [ '$PHPV' = '5.4' ]; then echo 'zend_extension_ts = xdebug.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- - cat ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- - echo Mysql version
-# INSTALL MYSQL 5.6
-# (https://github.com/piwik/piwik/commit/20bd2e1c24e5d673dce3feb256204ad48c29f160)
-# TODO: Remove when mysql 5.6 is provided by travis.
-# Otherwise, our migrations will raise a syntax error.
-# - "sudo apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5"
-# - "sudo apt-get autoremove"
-# - "sudo apt-get install libaio1"
-# - "wget -O mysql-5.6.14.deb http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-x86_64.deb/from/http://cdn.mysql.com/"
-# - "sudo dpkg -i mysql-5.6.14.deb"
-# - "sudo cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server"
-# - "sudo ln -s /opt/mysql/server-5.6/bin/* /usr/bin/"
-# - "sudo sed -i'' 's/table_cache/table_open_cache/' /etc/mysql/my.cnf"
-# - "sudo sed -i'' 's/log_slow_queries/slow_query_log/' /etc/mysql/my.cnf"
-# - "sudo sed -i'' 's/basedir[^=]\\+=.*$/basedir = \\/opt\\/mysql\\/server-5.6/' /etc/mysql/my.cnf"
-# - "sudo /etc/init.d/mysql.server start"
-# /END MYSQL 5.6- mysql --version
- - mysql --version
- - mysql -e "SELECT VERSION();"
- - echo Init database
- - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS myapp_test;' -U postgres; fi"
- - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE myapp_test;' -U postgres; fi"
- - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'DROP DATABASE IF EXISTS myapp_test;'; fi"
- - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS myapp_test;'; fi"
- - sh -c "if [ '$DB' = 'mysql' ]; then mysql -D myapp_test < $(pwd)/dev/initdata/mysqldump_dolibarr_3.5.0.sql; fi"
- - echo Create config file htdocs/conf/conf.php
- - echo '<?php ' > htdocs/conf/conf.php
- - sh -c "if [ '$DB' = 'pgsql' ]; then echo '$'dolibarr_main_db_type=\'pgsql\'';' >> htdocs/conf/conf.php; fi"
- - sh -c "if [ '$DB' = 'mysql' ]; then echo '$'dolibarr_main_db_type=\'mysqli\'';' >> htdocs/conf/conf.php; fi"
- - echo '$'dolibarr_main_url_root=\'http://localhost/\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_document_root=\'$(pwd)/htdocs\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_data_root=\'$(pwd)/htdocs/documents\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_db_host=\'localhost\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_db_name=\'myapp_test\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_db_user=\'travis\'';' >> htdocs/conf/conf.php
- - echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> htdocs/conf/conf.php
- - echo '?>' >> htdocs/conf/conf.php
- - echo Show conf.php content
- - cat htdocs/conf/conf.php
- - echo Install apache server
- - sudo apt-get update
- - sudo apt-get install -y --force-yes apache2 libapache2-mod-php5 php5-curl php5-mysql php5-pgsql php5-intl
- - sudo sed -i -e "s,/var/www,$(pwd)/htdocs,g" /etc/apache2/sites-available/default
- - echo Show default virtual host
- - sudo cat /etc/apache2/sites-available/default
- - sudo /etc/init.d/apache2 restart
- - wget http://localhost/
- - sudo cat /etc/apache2/envvars
- - sudo cat /var/log/apache2/error.log
- - cat index.html
-
-
-
-script: 
- - cd htdocs/install
- - date
-# - php upgrade.php 3.4.0 3.5.0 ignoredbversion > upgrade340350.log
-# - php upgrade2.php 3.4.0 3.5.0 ignoredbversion > upgrade340350-2.log
- - php upgrade.php 3.5.0 3.6.0 ignoredbversion > upgrade350360.log
- - php upgrade2.php 3.5.0 3.6.0 ignoredbversion > upgrade350360-2.log
- - php upgrade.php 3.6.0 3.7.0 ignoredbversion > upgrade360370.log
- - php upgrade2.php 3.6.0 3.7.0 ignoredbversion > upgrade360370-2.log
- - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log
-# - cat upgrade370380.log
- - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log
- - php upgrade.php 3.8.0 3.9.0 ignoredbversion > upgrade380390.log
-# - cat upgrade380390.log
- - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log
-# - cat upgrade380390-2.log
- - cd ../..
- - date
- - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php
- - date
-# - phpcs -p --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/dev/vagrant/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php 2>&1
- - htdocs/includes/squizlabs/php_codesniffer/scripts/phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/htdocs/conf/conf.php,/build/html/,/dev/vagrant/,/documents/,/includes/,/test/report/ . 2>&1
- - date
+notifications:
+  email:
+    on_success: never # [always|never|change] default: change
+    on_failure: change # [always|never|change] default: always
+  irc:
+    channels:
+    - "chat.freenode.net#dolibarr"
+    on_success: change
+    on_failure: always
+    use_notice: true
 
-after_script:
-# - echo Output dolibarr log file; cat $(pwd)/htdocs/documents/dolibarr.log
- - echo Output apache log file; sudo cat /var/log/apache2/error.log
- - echo End travis
+before_install:
+- |
+  echo "Disabling Xdebug for composer"
+  export PHP_VERSION_NAME=$(phpenv version-name)
+  cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini
+  phpenv config-rm xdebug.ini
+  echo
+
+install:
+- |
+  echo "Updating Composer"
+  composer self-update
+  echo
+
+- |
+  echo "Installing Parallel Lint"
+  composer -n require jakub-onderka/php-parallel-lint ^0
+  composer -n require jakub-onderka/php-console-highlighter ^0
+  echo
+
+- |
+  echo "Installing PHP Unit"
+  if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then
+    composer -n require phpunit/phpunit ^4
+  fi
+  if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
+    composer -n require phpunit/phpunit ^5
+  fi
+  echo
+
+- |
+  echo "Installing PHP CodeSniffer"
+  composer require squizlabs/php_codesniffer ^2
+  echo
 
+- |
+  echo "Adding Composer binaries to the path"
+  export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH"
+  echo
+
+before_script:
+- |
+  echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit"
+  phpenv config-add /tmp/xdebug.ini
+  echo
+
+- |
+  echo "Setting up PHP"
+  echo
+  echo "Set timezone"
+  echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+  if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then
+    echo
+    echo "Enabling APC for PHP <= 5.4"
+    #   Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6!
+    echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+    echo
+    echo "Enabling Memcached for PHP <= 5.4"
+    #   Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0 and nightly!
+    echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+  fi
+  phpenv rehash
+  echo
+
+- |
+  if [ "$DEBUG" = true ]; then
+    echo "Debugging informations"
+    # Check PHP
+    php -i
+    # Check PHP CodeSniffer installation
+    which phpcs
+    phpcs --version
+    phpcs -i
+    # Check PHPUnit installation
+    which phpunit
+    phpunit --version
+    # Check MySQL
+    mysql --version
+    mysql -e "SELECT VERSION();"
+    echo
+  fi
+
+- |
+  echo "Setting up database"
+  if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then
+    echo "MySQL"
+    mysql -e 'DROP DATABASE IF EXISTS travis;'
+    mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
+    mysql -D travis < dev/initdata/mysqldump_dolibarr_3.5.0.sql
+  fi
+  # FIXME: find a way to import a MySQL dump into PostgreSQL
+  #if [ "$DB" = 'postgresql' ]; then
+  #  pgsql travis < dev/initdata/mysqldump_dolibarr_3.5.0.sql
+  #fi
+  # TODO: SQLite
+  echo
+
+- |
+  echo "Setting up Dolibarr"
+  export CONF_FILE=htdocs/conf/conf.php
+  echo '<?php ' > $CONF_FILE
+  echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE
+  echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE
+  echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE
+  echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE
+  echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE
+  echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE
+  if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then
+    echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE
+  fi
+  # FIXME
+  #if [ "$DB" = 'postgresql' ]; then
+  #  echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE
+  #fi
+  # TODO: SQLite
+  echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
+  echo
+
+- |
+  if [ "$DEBUG" = true ]; then
+    echo "Debugging informations"
+    cat $CONF_FILE
+    echo
+  fi
+
+- |
+  echo "Create documents directory and set permissions"
+  # and admin/temp subdirectory needed for unit tests
+  mkdir -p documents/admin/temp
+  echo
+
+- |
+  echo "Setting up Apache + FPM"
+  # enable php-fpm
+  cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf
+  if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
+    # Copy the included pool
+    cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf
+  fi
+  if [ "$DEBUG" = true ]; then
+    cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf
+  fi
+  sudo a2enmod rewrite actions fastcgi alias
+  echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+  if [ "$DEBUG" = true ]; then
+    cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+  fi
+  ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm
+  # configure apache virtual hosts
+  sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default
+  sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default
+  if [ "$DEBUG" = true ]; then
+    sudo cat /etc/apache2/sites-available/default
+  fi
+  sudo service apache2 restart
+  echo
+
+script:
+- |
+  echo "Checking webserver availability"
+  # Ensure we catch errors
+  set -e
+  wget http://127.0.0.1
+  if [ "$DEBUG" = true ]; then
+    cat index.html
+  fi
+  set +e
+  echo
+
+- |
+  echo "Checking PHP syntax errors"
+  # Ensure we catch errors
+  set -e
+  parallel-lint --exclude htdocs/includes --blame .
+  set +e
+  echo
+
+# TODO: dev/* checks
+
+- |
+  echo "Checking coding style"
+  # Ensure we catch errors
+  set -e
+  # Exclusions are defined in the ruleset.xml file
+  phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/codesniffer/ruleset.xml --encoding=utf-8 .
+  set +e
+  echo
+
+# TODO: Check Javascript (jshint?)
+
+# TODO: Check CSS (csslint?)
+
+# TODO: check SQL syntax (pgsanity?)
+
+- |
+  echo "Upgrading Dolibarr"
+  # Ensure we catch errors
+  set -e
+  cd htdocs/install
+  php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log
+  php upgrade2.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360-2.log
+  php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log
+  php upgrade2.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370-2.log
+  php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log
+  php upgrade2.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380-2.log
+  php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log
+  php upgrade2.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390-2.log
+  cd -
+  set +e
+  echo
+
+- |
+  echo "Unit testing"
+  # Ensure we catch errors
+  set -e
+  phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php
+  set +e
+  echo
+
+after_success:
+
+after_failure:
+- |
+  if [ "$DEBUG" = true ]; then
+    echo "Debugging informations"
+    # Upgrade log files
+    cat *.log
+    # Dolibarr log file
+    cat documents/dolibarr.log
+    # Apache log file
+    sudo cat /var/log/apache2/error.log
+    # MariaDB log file
+    sudo cat /var/log/mysql/error.log
+    # TODO: PostgreSQL log file
+    echo
+  fi
+
+after_script:

+ 1 - 1
build/aps/configure.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*-----------------------------------------------------
  *

+ 1 - 1
build/generate_filecheck_xml.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2015 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 18 - 0
build/travis-ci/apache.conf

@@ -0,0 +1,18 @@
+<VirtualHost *:80>
+  DocumentRoot %TRAVIS_BUILD_DIR%/htdocs
+
+  <Directory "%TRAVIS_BUILD_DIR%/htdocs">
+    Options FollowSymLinks MultiViews ExecCGI
+    AllowOverride All
+    Order deny,allow
+    Allow from all
+  </Directory>
+
+  # Wire up Apache to use Travis CI's php-fpm.
+  <IfModule mod_fastcgi.c>
+    AddHandler php5-fcgi .php
+    Action php5-fcgi /php5-fcgi
+    Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
+    FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
+  </IfModule>
+</VirtualHost>

+ 0 - 18
composer.json.phpcs

@@ -1,18 +0,0 @@
-{
-    "name": "dolibarr/dolibarr",
-    "type": "project",
-    "description": "Dolibarr ERP & CRM is a modern and easy to use web software to manage your business",
-    "keywords": ["erp","crm","invoice","sme","proposal","order","stock"],
-    "homepage": "http://www.dolibarr.org",
-    "license": "GPL-3.0+",
-    "support": {
-        "issues": "https://github.com/Dolibarr/dolibarr/issues",
-        "forum": "http://www.dolibarr.org/forum",
-        "wiki": "http://wiki.dolibarr.org",
-        "irc": "irc://chat.freenode.net/dolibarr",
-        "source": "https://github.com/Dolibarr/dolibarr"
-    },
-    "config": {
-        "vendor-dir": "htdocs/includes"
-    }
-}

+ 6 - 6
dev/codesniffer/ruleset.xml

@@ -3,12 +3,12 @@
 <ruleset name="Dolibarr">
 	<description>Dolibarr coding standard.</description>
 
-	<exclude-pattern>*/conf.php</exclude-pattern>
-	<exclude-pattern>*/includes/*</exclude-pattern>
-	<exclude-pattern>*/documents/*</exclude-pattern>
-	<exclude-pattern>*/dev/vagrant/*</exclude-pattern>
-	<exclude-pattern>*/custom/*</exclude-pattern>
-	<exclude-pattern>*/nltechno*</exclude-pattern>
+	<exclude-pattern type="relative">build/html</exclude-pattern>
+	<exclude-pattern type="relative">documents</exclude-pattern>
+	<exclude-pattern type="relative">htdocs/custom</exclude-pattern>
+	<exclude-pattern type="relative">htdocs/includes</exclude-pattern>
+	<exclude-pattern type="relative">htdocs/conf.php</exclude-pattern>
+	<exclude-pattern type="relative">*/nltechno*</exclude-pattern>
 
 		<!-- List of all tests -->
 

+ 1 - 1
dev/examples/create_invoice.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/examples/create_order.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/examples/create_product.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/examples/create_user.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/examples/get_contracts.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/initdata/generate-invoice.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  *

+ 1 - 1
dev/initdata/generate-order.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
dev/initdata/generate-product.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
dev/initdata/generate-proposal.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2007 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
dev/initdata/generate-thirdparty.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2006-2013 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
dev/initdata/sftpget_and_loaddump.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2012 Laurent Destailleur	<eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/skeletons/build_api_class.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2015   Jean-François Ferry <jfefe@aternatik.fr>
  *

+ 1 - 1
dev/skeletons/build_class_from_table.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2008-2014 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/skeletons/build_webservice_from_class.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/skeletons/skeleton_script.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2007-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) ---Put here your own copyright and developer email---

+ 1 - 1
dev/translation/autotranslator.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2009-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
  *

+ 1 - 1
dev/translation/sanity_check_en_langfiles.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (c) 2015 Tommaso Basilici    <t.basilici@19.coop>
  * Copyright (c) 2015 Laurent Destailleur <eldy@destailleur.fr>

+ 1 - 1
dev/translation/strip_language_file.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2014 by FromDual GmbH, licensed under GPL v2
  * Copyright (C) 2014 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 5 - 1
htdocs/filefunc.inc.php

@@ -166,7 +166,11 @@ define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);			// Filesystem core
 $tmp='';
 $found=0;
 $real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root));	// A) Value found into config file, to say where are store htdocs files. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
-$pathroot=$_SERVER["DOCUMENT_ROOT"];															// B) Value reported by web server setup, to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
+if (!empty($_SERVER["DOCUMENT_ROOT"])) {
+	$pathroot = $_SERVER["DOCUMENT_ROOT"];                                                      // B) Value reported by web server setup, to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
+} else {
+	$pathroot = 'BOGUS';
+}
 $paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"]));								// C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
 // Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
 $concatpath='';

+ 2 - 1
scripts/accountancy/export-thirdpartyaccount.php

@@ -1,4 +1,5 @@
-<?PHP
+#!/usr/bin/env php
+<?php
 /* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
  * Copyright (C) 2013-2014 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2014	   Florian Henry		<florian.henry@open-concept.pro>

+ 1 - 1
scripts/bank/export-bank-receipts.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2013 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
scripts/company/export-contacts-xls-example.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/company/sync_contacts_dolibarr2ldap.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/contracts/email_expire_services_to_customers.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005		Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/contracts/email_expire_services_to_representatives.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005		Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/cron/cron_run_jobs.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2012   Nicolas Villa aka Boyquotes http://informetic.fr
  * Copyright (C) 2013   Florian Henry <forian.henry@open-concept.pro

+ 1 - 1
scripts/emailings/mailing-send.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/invoices/email_unpaid_invoices_to_customers.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005		Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/invoices/email_unpaid_invoices_to_representatives.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005		Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/invoices/rebuild_merge_pdf.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2009-2012 Laurent Destailleur  <eldy@users.sourceforge.net>

+ 1 - 1
scripts/members/sync_members_dolibarr2ldap.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/members/sync_members_ldap2dolibarr.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/product/migrate_picture_path.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /* Copyright (C) 2007-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2015 Jean Heimburger  <http://tiaris.eu>

+ 1 - 1
scripts/user/sync_groups_dolibarr2ldap.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/user/sync_groups_ldap2dolibarr.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/user/sync_users_dolibarr2ldap.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/user/sync_users_ldap2dolibarr.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 1 - 1
scripts/withdrawals/build_withdrawal_file.php

@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
  * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ 4 - 4
test/phpunit/AllTests.php

@@ -36,17 +36,17 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
 if ($langs->defaultlang != 'en_US')
 {
     print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n";
-    exit;
+    exit(1);
 }
 if (empty($conf->adherent->enabled))
 {
-	print "Error: Module member must be enabled to have significatn results.\n";
-	exit;
+	print "Error: Module member must be enabled to have significant results.\n";
+	exit(1);
 }
 if (! empty($conf->ldap->enabled))
 {
     print "Error: LDAP module should not be enabled.\n";
-    exit;
+    exit(1);
 }
 if (! empty($conf->google->enabled))
 {

+ 1 - 1
test/phpunit/ContactTest.php

@@ -33,7 +33,7 @@ $langs->load("dict");
 if ($langs->defaultlang != 'en_US')
 {
 	print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n";
-	exit;
+	exit(1);
 }
 
 if (empty($user->id))

+ 1 - 1
test/phpunit/PricesTest.php

@@ -42,7 +42,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
 if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT))
 {
     print "Parameter MAIN_ROUNDING_RULE_TOT must be set to 0 or not set.\n";
-    exit;
+    exit(1);
 }
 
 /**

+ 1 - 1
test/phpunit/WebservicesProductsTest.php

@@ -43,7 +43,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
 if (empty($conf->service->enabled))
 {
 	print "Error: Module service must be enabled.\n";
-	exit;
+	exit(1);
 }
 
 /**