From bbe7498de6b1590f3b806eb4400e5cfb5837cb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Fri, 11 Dec 2015 05:08:32 +0100 Subject: [PATCH] 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. --- .travis.yml | 426 ++++++++++++------ build/aps/configure.php | 2 +- build/generate_filecheck_xml.php | 2 +- build/travis-ci/apache.conf | 18 + composer.json.phpcs | 18 - dev/codesniffer/ruleset.xml | 12 +- dev/examples/create_invoice.php | 2 +- dev/examples/create_order.php | 2 +- dev/examples/create_product.php | 2 +- dev/examples/create_user.php | 2 +- dev/examples/get_contracts.php | 2 +- dev/initdata/generate-invoice.php | 2 +- dev/initdata/generate-order.php | 2 +- dev/initdata/generate-product.php | 2 +- dev/initdata/generate-proposal.php | 2 +- dev/initdata/generate-thirdparty.php | 2 +- dev/initdata/sftpget_and_loaddump.php | 2 +- dev/skeletons/build_api_class.php | 2 +- dev/skeletons/build_class_from_table.php | 2 +- dev/skeletons/build_webservice_from_class.php | 2 +- dev/skeletons/skeleton_script.php | 2 +- dev/translation/autotranslator.php | 2 +- dev/translation/sanity_check_en_langfiles.php | 2 +- dev/translation/strip_language_file.php | 2 +- htdocs/filefunc.inc.php | 6 +- .../accountancy/export-thirdpartyaccount.php | 3 +- scripts/bank/export-bank-receipts.php | 2 +- .../company/export-contacts-xls-example.php | 2 +- .../company/sync_contacts_dolibarr2ldap.php | 2 +- .../email_expire_services_to_customers.php | 2 +- ...ail_expire_services_to_representatives.php | 2 +- scripts/cron/cron_run_jobs.php | 2 +- scripts/emailings/mailing-send.php | 2 +- .../email_unpaid_invoices_to_customers.php | 2 +- ...ail_unpaid_invoices_to_representatives.php | 2 +- scripts/invoices/rebuild_merge_pdf.php | 2 +- .../members/sync_members_dolibarr2ldap.php | 2 +- .../members/sync_members_ldap2dolibarr.php | 2 +- scripts/product/migrate_picture_path.php | 2 +- scripts/user/sync_groups_dolibarr2ldap.php | 2 +- scripts/user/sync_groups_ldap2dolibarr.php | 2 +- scripts/user/sync_users_dolibarr2ldap.php | 2 +- scripts/user/sync_users_ldap2dolibarr.php | 2 +- scripts/withdrawals/build_withdrawal_file.php | 2 +- test/phpunit/AllTests.php | 8 +- test/phpunit/ContactTest.php | 2 +- test/phpunit/PricesTest.php | 2 +- test/phpunit/WebservicesProductsTest.php | 2 +- 48 files changed, 366 insertions(+), 207 deletions(-) create mode 100644 build/travis-ci/apache.conf delete mode 100644 composer.json.phpcs diff --git a/.travis.yml b/.travis.yml index 9956d9c58c8..a5330042b58 100644 --- a/.travis.yml +++ b/.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/ +sudo: required + +language: php + +php: +- '5.3' +- '5.4' +- '5.5' +- '5.6' +- '7.0' +- nightly + +addons: + 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 + +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: nightly + # FIXME + #- env: DB=postgresql + # TODO + #- env: DB=sqlite + notifications: email: on_success: never # [always|never|change] default: change on_failure: change # [always|never|change] default: always - -addons: - postgresql: "9.3" + irc: + channels: + - "chat.freenode.net#dolibarr" + on_success: change + on_failure: always + use_notice: true -services: - - memcached # will start memcached +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 -# This will tell travis to run phpunit -language: php -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 +install: +- | + echo "Updating Composer" + composer self-update + echo -matrix: - allow_failures: - - php: 7.0 +- | + echo "Installing Parallel Lint" + composer -n require jakub-onderka/php-parallel-lint ^0 + composer -n require jakub-onderka/php-console-highlighter ^0 + echo -env: - - DB=mysql -# - DB=postgres +- | + 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 -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 ' 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 +- | + 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 -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 +- | + 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 ' $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: -# - 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 - diff --git a/build/aps/configure.php b/build/aps/configure.php index f4bd03b5d9e..1b2565e3dc8 100755 --- a/build/aps/configure.php +++ b/build/aps/configure.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf new file mode 100644 index 00000000000..5ba713924f2 --- /dev/null +++ b/build/travis-ci/apache.conf @@ -0,0 +1,18 @@ + + DocumentRoot %TRAVIS_BUILD_DIR%/htdocs + + + Options FollowSymLinks MultiViews ExecCGI + AllowOverride All + Order deny,allow + Allow from all + + + # Wire up Apache to use Travis CI's php-fpm. + + 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 + + diff --git a/composer.json.phpcs b/composer.json.phpcs deleted file mode 100644 index 5f5ea2d1fdf..00000000000 --- a/composer.json.phpcs +++ /dev/null @@ -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" - } -} diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 321560ff6f9..64194c7b756 100644 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -3,12 +3,12 @@ Dolibarr coding standard. - */conf.php - */includes/* - */documents/* - */dev/vagrant/* - */custom/* - */nltechno* + build/html + documents + htdocs/custom + htdocs/includes + htdocs/conf.php + */nltechno* diff --git a/dev/examples/create_invoice.php b/dev/examples/create_invoice.php index d59655ef613..bd82d38d306 100755 --- a/dev/examples/create_invoice.php +++ b/dev/examples/create_invoice.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/examples/create_order.php b/dev/examples/create_order.php index d490d230b77..4575e9e28f3 100755 --- a/dev/examples/create_order.php +++ b/dev/examples/create_order.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/examples/create_product.php b/dev/examples/create_product.php index 6ecce081d45..61598ff59d9 100755 --- a/dev/examples/create_product.php +++ b/dev/examples/create_product.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/examples/create_user.php b/dev/examples/create_user.php index d6126af2cba..f745032f575 100755 --- a/dev/examples/create_user.php +++ b/dev/examples/create_user.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/examples/get_contracts.php b/dev/examples/get_contracts.php index d1be3d9d7bf..1262fe3eebd 100755 --- a/dev/examples/get_contracts.php +++ b/dev/examples/get_contracts.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 321cc6af06a..c1b2f2646a5 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index 6ba813c5135..082d5428c97 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) 2004-2007 Laurent Destailleur diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index 38c0e755db3..975fc1ba33d 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) 2004-2010 Laurent Destailleur diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 8e17e673b86..8d413a518c1 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) 2007 Laurent Destailleur diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index 9d928db6ac0..d6e9d4c9393 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) 2006-2013 Laurent Destailleur diff --git a/dev/initdata/sftpget_and_loaddump.php b/dev/initdata/sftpget_and_loaddump.php index 72a33cf197c..64c5ddeb24d 100755 --- a/dev/initdata/sftpget_and_loaddump.php +++ b/dev/initdata/sftpget_and_loaddump.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/skeletons/build_api_class.php b/dev/skeletons/build_api_class.php index 4ed122c95d8..6263eabcd6e 100755 --- a/dev/skeletons/build_api_class.php +++ b/dev/skeletons/build_api_class.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 803a6c8b8f5..4de319dabc9 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/skeletons/build_webservice_from_class.php b/dev/skeletons/build_webservice_from_class.php index ee8772a8a44..c91347a424d 100755 --- a/dev/skeletons/build_webservice_from_class.php +++ b/dev/skeletons/build_webservice_from_class.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/skeletons/skeleton_script.php b/dev/skeletons/skeleton_script.php index 35904c9bfd3..5eb1565d4a3 100644 --- a/dev/skeletons/skeleton_script.php +++ b/dev/skeletons/skeleton_script.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) ---Put here your own copyright and developer email--- diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php index 7fe21adfd73..58314a23b9e 100755 --- a/dev/translation/autotranslator.php +++ b/dev/translation/autotranslator.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index f54c179ac09..5eb92509eb1 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (c) 2015 Laurent Destailleur diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index d612ff66abf..647b571c788 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 7abc17b49cd..534ef2587bc 100644 --- a/htdocs/filefunc.inc.php +++ b/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=''; diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 0613df19501..05236aabf7e 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -1,4 +1,5 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 91b1140d1a1..98ec3dd84cd 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/company/export-contacts-xls-example.php b/scripts/company/export-contacts-xls-example.php index f9469848c31..5fd7806a26c 100755 --- a/scripts/company/export-contacts-xls-example.php +++ b/scripts/company/export-contacts-xls-example.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 2223cd1ca8f..900cdbc35ed 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 8f2fef6a9d6..0f5c91817db 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 44ccb4c7e97..ad7ccebcba7 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 81b1955d35f..e163f41e9fc 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 0b5e66f49da..02e9db2e0ce 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 2870766ff21..e134d693d74 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 6fbcdb59538..6727dc5cab7 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index bfe16330b79..a0c393d01c2 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index b6a27250557..2319a10a0fd 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index a03e2549006..9d3cba8452f 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php * Copyright (C) 2015 Jean Heimburger diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index d751c5ed90c..e661a85beb5 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index b48a4af974e..45b960878ab 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 91ad440e9b2..dd5e3d18de4 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 48917cc1042..9a04f81c557 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index cb01c3f6678..1a8c673c5f9 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index d7bd828527f..96e48a7264d 100644 --- a/test/phpunit/AllTests.php +++ b/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)) { diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index d9532417fc2..cb0f37875b3 100755 --- a/test/phpunit/ContactTest.php +++ b/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)) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index bb8c90d5f1c..5e0169f9b36 100755 --- a/test/phpunit/PricesTest.php +++ b/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); } /** diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index a751faddb4b..fecc58a65e1 100755 --- a/test/phpunit/WebservicesProductsTest.php +++ b/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); } /**