From dfbc2814e78d9c91f122b172096546ec63975d47 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 15 Dec 2015 21:10:53 +0100 Subject: [PATCH 01/14] Fix: Add an empty field for list of parent account - This value can be null --- htdocs/accountancy/admin/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index ad6ca01b6ca..0608fcdb73e 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -145,13 +145,13 @@ if ($action == 'create') print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . '
' . $langs->trans("Label") . '
' . $langs->trans("Accountparent") . ''; - print $htmlacc->select_account($accounting->account_parent, 'account_parent'); + print $htmlacc->select_account($accounting->account_parent, 'account_parent', 1); print '
' . $langs->trans("Pcgtype") . ''; @@ -195,13 +195,13 @@ else if ($id) print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . '
' . $langs->trans("Label") . '
' . $langs->trans("Accountparent") . ''; - print $htmlacc->select_account($accounting->account_parent, 'account_parent'); + print $htmlacc->select_account($accounting->account_parent, 'account_parent', 1); print '
' . $langs->trans("Pcgtype") . ''; From cb7f29b332e95df302a68ffc765643f56af30610 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 16 Dec 2015 13:32:44 +0100 Subject: [PATCH 02/14] Fix: PHP 7 - Fatal error: 'break' not in the 'loop' or 'switch' context --- htdocs/includes/adodbtime/adodb-time.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/adodbtime/adodb-time.inc.php b/htdocs/includes/adodbtime/adodb-time.inc.php index 1be5f4cd607..88d05d2f2b1 100644 --- a/htdocs/includes/adodbtime/adodb-time.inc.php +++ b/htdocs/includes/adodbtime/adodb-time.inc.php @@ -1006,7 +1006,7 @@ function adodb_tz_offset($gmt,$isphp5) return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); else return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); - break; + //break; } From e6ec797af8e90ff5ec60135122cdc8561003f425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 17 Dec 2015 10:21:44 +0100 Subject: [PATCH 03/14] FIX #4242 Allow disabling dashes in documents --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_proforma.modules.php | 2 +- htdocs/core/modules/expedition/doc/pdf_merou.modules.php | 2 +- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php | 2 +- htdocs/core/modules/project/pdf/pdf_baleine.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 2 +- htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 2f569f1e47f..acb2114c351 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -419,7 +419,7 @@ class pdf_einstein extends ModelePDFCommandes $this->tva[$vatrate] += $tvaligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index cf5a562e2ef..fc880b91a6e 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -418,7 +418,7 @@ class pdf_proforma extends ModelePDFCommandes $this->tva[$vatrate] += $tvaligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 8fab26f211c..e19ef0a2c49 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -265,7 +265,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 12fd723bf9b..cd8ddaf0a57 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -272,7 +272,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e8ea460fb9b..eb8e43b6f7c 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -420,7 +420,7 @@ class pdf_crabe extends ModelePDFFactures $this->tva[$vatrate] += $tvaligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index ba58279c8ec..4e0dbbacae5 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -377,7 +377,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index d8f2d744e78..90dd563c620 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -228,7 +228,7 @@ class pdf_baleine extends ModelePDFProjects $nexY = $pdf->GetY(); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d7d4b3150cf..8f24283448b 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -476,7 +476,7 @@ class pdf_azur extends ModelePDFPropales if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index e45f45cb79b..e5e3284e99a 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -386,7 +386,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->localtax2[$localtax2rate]+=$localtax2ligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 5376d7fcd27..3379ae18b14 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -410,7 +410,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); From 02e053acc63916dc203ac16282210b40cbd0d44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 17 Dec 2015 10:26:27 +0100 Subject: [PATCH 04/14] FIX #4242 Allow disabling dashes in documents 3.7 specific fix since document files have moved --- htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 2 +- htdocs/core/modules/project/doc/pdf_baleine.modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 365fbef4cdf..340882a3e5a 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -395,7 +395,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index db0017a2e98..c40b8bb93a1 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -242,7 +242,7 @@ class pdf_baleine extends ModelePDFProjects $nexY = $pdf->GetY(); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); From 21f7271e5177316d3ed7779dbafae20ae49d5a00 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 17 Dec 2015 12:36:43 +0100 Subject: [PATCH 05/14] FIX: Not deleting contrats on element_element table --- htdocs/contrat/class/contrat.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 3e4605a8f2c..39acbe6a7df 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -861,6 +862,13 @@ class Contrat extends CommonObject } } + if (! $error) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } + if (! $error) { // Delete contratdet_log From aa7e74f4c866d8dcf8d3dbb976bbeb4cfbcf7d00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 18:29:33 +0100 Subject: [PATCH 06/14] Try to fix travis error using the new setup --- .travis.yml | 390 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 292 insertions(+), 98 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c5833ccfdb..db2842fdb6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,114 +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 - -services: - - memcached # will start memcached + irc: + channels: + - "chat.freenode.net#dolibarr" + on_success: change + on_failure: always + use_notice: true -# This will tell travis to run phpunit -language: php -php: -# - "5.2" is not supported because pyrus to install PHP_Codesniffer is not available - - "5.3" - - "5.4" - - "5.5" +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 -env: - - DB=mysql -# - DB=postgres +install: +- | + echo "Updating Composer" + composer self-update + 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 - - phpunit --version - - echo Install phpcs then show installed rules - - pyrus install pear/PHP_CodeSniffer - - phpenv rehash - - 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 - - mysql --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/ - - cat index.html +- | + 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 -script: - - cd htdocs/install - - date -# - php upgrade.php 3.4.0 3.5.0 ignoredbversion > upgrade.log -# - php upgrade2.php 3.4.0 3.5.0 ignoredbversion > upgrade2.log - - php upgrade.php 3.5.0 3.6.0 ignoredbversion >> upgrade.log - - php upgrade2.php 3.5.0 3.6.0 ignoredbversion >> upgrade2.log - - php upgrade.php 3.6.0 3.7.0 ignoredbversion >> upgrade.log -# - cat upgrade360370.log - - php upgrade2.php 3.6.0 3.7.0 ignoredbversion >> upgrade2.log -# - cat upgrade2.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 - - 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 "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 ' $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 - From 480111c6b19ccd6ade97b4250ba23a2aedc54ef1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 18:31:51 +0100 Subject: [PATCH 07/14] Try to fix travis error using new setup --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index db2842fdb6b..f2a00b582f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -271,10 +271,10 @@ script: 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 + # 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 From 056ab6368029a681cbfa40222a3f2ef81559fb9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 18:46:35 +0100 Subject: [PATCH 08/14] Try to fix travis error using new setup --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2a00b582f0..547de1fbf68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -238,11 +238,11 @@ script: echo - | - echo "Checking PHP syntax errors" + #echo "Checking PHP syntax errors" # Ensure we catch errors - set -e - parallel-lint --exclude htdocs/includes --blame . - set +e + #set -e + #parallel-lint --exclude htdocs/includes --blame . + #set +e echo # TODO: dev/* checks From 0dc4130a17ecba7e2811404c7511b9972948331e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 18:59:20 +0100 Subject: [PATCH 09/14] Add debug --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 547de1fbf68..632fa56ebc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ services: env: global: # Set to true for very verbose output - - DEBUG=false + - DEBUG=true matrix: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mysql From 064fad136e60c741527f4f9eb048b73bdee11dac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 19:28:17 +0100 Subject: [PATCH 10/14] Try to solve travis pb --- composer.json | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index f0de86ce7ea..40b5099203a 100644 --- a/composer.json +++ b/composer.json @@ -6,26 +6,34 @@ "homepage": "http://www.dolibarr.org", "license": "GPL-3.0+", "support": { - "issues": "https://doliforge.org/projects/dolibarr", + "issues": "https://github.com/Dolibarr/dolibarr/issues", "forum": "http://www.dolibarr.org/forum", - "wiki": "http://wiki.dolibarr.org" + "wiki": "http://wiki.dolibarr.org", + "irc": "irc://chat.freenode.net/dolibarr", + "source": "https://github.com/Dolibarr/dolibarr" }, "require": { "php": ">=5.3.0", - "ext-gd": "*", "ext-curl": "*" }, "suggest": { - "ext-mysqli": "*", - "ext-pgsql": "*", - "ext-mssql": "*", - "ext-pdo_sqlite": "*", - "ext-imagick": "*", - "ext-mcrypt": "*", - "ext-openssl": "*", - "ext-mbstring": "*", - "ext-soap": "*", - "ext-zip": "*", - "ext-xml": "*" + "ext-mysqlnd": "To use with MySQL or MariaDB", + "ext-mysqli": "To use with MySQL or MariaDB", + "ext-pgsql": "To use with PostgreSQL", + "ext-mssql": "To use with MSSQL (experimental)", + "ext-pdo_sqlite": "To use with SQLite (experimental)", + "ext-gd": "Image manipulation (Required but maybe built-in PHP)", + "ext-imagick": "Image manipulation (TCPDF)", + "ext-mcrypt": "(Required but maybe built-in PHP)", + "ext-openssl": "Secure connections (Emails, SOAP…)", + "ext-mbstring": "Handle non UTF-8 databases", + "ext-soap": "Native SOAP", + "ext-zip": "ODT and Excel support", + "ext-xml": "Excel support", + "firephp/firephp-core": "Logging to Firebug console support", + "raven/raven": "Sentry logging server support" + }, + "config": { + "vendor-dir": "htdocs/includes" } } From 11042fe49969ff0038dfaee70141776a433bd0b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 19:54:54 +0100 Subject: [PATCH 11/14] Restore data missin help debug --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 632fa56ebc9..fb94d7cbcb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,6 +109,10 @@ install: echo before_script: + - echo Start travis + - echo Current dir is `pwd` + - echo Home dir is `echo ~` + - | echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" phpenv config-add /tmp/xdebug.ini @@ -238,11 +242,11 @@ script: echo - | - #echo "Checking PHP syntax errors" + echo "Checking PHP syntax errors" # Ensure we catch errors - #set -e - #parallel-lint --exclude htdocs/includes --blame . - #set +e + set -e + parallel-lint --exclude htdocs/includes --blame . + set +e echo # TODO: dev/* checks From 61df71cc6450f1c5f32cb551eaacd54728018709 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 19:57:09 +0100 Subject: [PATCH 12/14] Fix travis --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb94d7cbcb4..505c4aade29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,9 +109,10 @@ install: echo before_script: - - echo Start travis - - echo Current dir is `pwd` - - echo Home dir is `echo ~` +- | + echo Start travis + echo Current dir is `pwd` + echo Home dir is `echo ~` - | echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" From b47dc8a394ac172db821d723fe17e24bed7b80ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 20:10:11 +0100 Subject: [PATCH 13/14] Fix to use new travis setup --- .travis.yml | 1 + build/travis-ci/apache.conf | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 build/travis-ci/apache.conf diff --git a/.travis.yml b/.travis.yml index 505c4aade29..6a6802af911 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,6 +113,7 @@ before_script: echo Start travis echo Current dir is `pwd` echo Home dir is `echo ~` + echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR - | echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" 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 + + From c1c0fa88c22dd5e0d2ee586ba95d550b08046620 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Dec 2015 20:56:27 +0100 Subject: [PATCH 14/14] Fix for new travis setup --- .travis.yml | 383 +++++++++++++++++++++++++++--------- build/travis-ci/apache.conf | 18 ++ 2 files changed, 310 insertions(+), 91 deletions(-) create mode 100644 build/travis-ci/apache.conf diff --git a/.travis.yml b/.travis.yml index 9c7f18481f5..10f1d41a404 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,107 +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=true + 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 - -services: - - memcached # will start memcached + irc: + channels: + - "chat.freenode.net#dolibarr" + on_success: change + on_failure: always + use_notice: true -# This will tell travis to run phpunit -language: php -php: -# - "5.2" is not supported because pyrus to install PHP_Codesniffer is not available - - "5.3" - - "5.4" - - "5.5" +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 -env: - - DB=mysql -# - DB=postgres +install: +- | + echo "Updating Composer" + composer self-update + 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 - - phpunit --version - - echo Install phpcs then show installed rules - - pyrus install pear/PHP_CodeSniffer - - phpenv rehash - - 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 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.4.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/ - - cat index.html +- | + 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 -script: - - cd htdocs/install - - php upgrade.php 3.4.0 3.5.0 > upgrade.log - - php upgrade2.php 3.4.0 3.5.0 > upgrade2.log - - php upgrade.php 3.5.0 3.6.0 >> upgrade.log - - php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log -# - cat upgrade.log -# - cat upgrade2.log - - cd ../.. - - 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 - - phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/dev/vagrant/,/documents/,/includes/,/test/report/ . 2>&1 - - date - - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php +- | + echo "Adding Composer binaries to the path" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" + echo + +before_script: +- | + echo Start travis + echo Current dir is `pwd` + echo Home dir is `echo ~` + echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR + +- | + 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 ' $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 + 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/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 + +