From c735653180965a040d1356def8722ae0789b3b8d Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 13:49:12 +0200 Subject: [PATCH 1/3] add postgresql to test + add test on installation process --- .travis.yml | 69 +++++++++++++++++++++++++++++++++------- htdocs/install/step1.php | 1 + htdocs/install/step2.php | 9 ++++++ 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10a2b6e8347..a4d6dbc92d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,16 +64,6 @@ matrix: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '5.4' - env: DB=postgresql - - php: '5.5' - env: DB=postgresql - - php: '5.6' - env: DB=postgresql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - php: hhvm env: DB=postgresql - php: nightly @@ -201,7 +191,7 @@ before_script: mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql fi if [ "$DB" = 'postgresql' ]; then #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -298,6 +288,63 @@ script: # TODO: Check CSS (csslint?) +- | + export INSTALL_FORCED_FILE=htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + fi + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE + # TODO: SQLite + #cat $INSTALL_FORCED_FILE + echo "Installation test" + cd htdocs/install + php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log + php step2.php set >> $TRAVIS_BUILD_DIR/install.log + if [ "$?" -ne "0" ]; then + echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" + exit 1 + fi + cd ../.. + rm $INSTALL_FORCED_FILE + #cat $TRAVIS_BUILD_DIR/install.log + set +e + echo + + - | + echo "Setting up database to test migrations" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + fi + # TODO: SQLite + echo + - | echo "Upgrading Dolibarr" # Ensure we catch errors diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 838ef34afa3..add57f5d853 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -82,6 +82,7 @@ if (@file_exists($forcedfile)) { // If forced install is enabled, let's replace post values. These are empty because form fields are disabled. if ($force_install_noedit) { $main_dir = detect_dolibarr_main_document_root(); + if (!empty($argv[1])) $main_dir = $argv[1]; // override when executing the script in command line if (!empty($force_install_main_data_root)) { $main_data_dir = $force_install_main_data_root; } else { diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 44661c191d7..e0e7d71c25d 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -65,6 +65,8 @@ if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.fo if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; + // test for travis + if (!empty($argv[1]) && $argv[1] == "set") $action = "set"; } dolibarr_install_syslog("--- step2: entering step2.php page"); @@ -620,8 +622,15 @@ else print 'Parameter action=set not defined'; } +$ret=0; +if (! $ok && isset($argv[1])) $ret=1; +dol_syslog("Exit ".$ret); + dolibarr_install_syslog("--- step2: end"); pFooter($ok?0:1,$setuplang); if (isset($db) && is_object($db)) $db->close(); + +// Return code if ran from command line +if ($ret) exit($ret); From 9a080a5d62b34dfef364f4d9cf44c350fca398df Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 13:53:44 +0200 Subject: [PATCH 2/3] add sourceline for fastcgi --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a4d6dbc92d2..99bdd8f083f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ addons: - apache2 # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - libapache2-mod-fastcgi + - sourceline: 'deb http://http.us.debian.org/debian main non-free' # We need pgloader for import mysql database into pgsql - pgloader From c8b035659cb21e2c7dd0f72cca6dd9bae5a7ce67 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 14:04:22 +0200 Subject: [PATCH 3/3] add sourceline for fastcgi on the right place --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 99bdd8f083f..9c7f562de23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,13 +21,13 @@ addons: - postgresql - sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' + - sourceline: 'deb http://http.us.debian.org/debian main non-free' 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 - - sourceline: 'deb http://http.us.debian.org/debian main non-free' # We need pgloader for import mysql database into pgsql - pgloader