forked from delcroip/dolibarr_project_timesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
361 lines (348 loc) · 12.3 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# This script is used by Travis CI to run automatically Continuous test integration
# from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
# We use dist: trusty to have php 5.4+ available
dist: trusty
sudo: required
language: php
# Start on every boot
services:
- memcached
addons:
mariadb: '10.0'
postgresql: '9.3'
apt:
sources:
# To use the last version of pgloader, we add repo of postgresql
- postgresql
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
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
# We need pgloader for import mysql database into pgsql
- pgloader
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- nightly
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
- 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: nightly
- php: '7.3'
# We exclude some combinations not usefull to save Travis CPU
exclude:
- php: '5.5'
env: DB=mariadb
- php: '5.6'
env: DB=mariadb
- php: '7.0'
env: DB=mariadb
- php: '7.1'
env: DB=mariadb
- 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: '7.3'
env: DB=postgresql
- php: nightly
env: DB=postgresql
notifications:
email:
on_success: never # [always|never|change] default: change
on_failure: never # [always|never|change] default: always
irc:
channels:
- "chat.freenode.net#dolibarrtimesheet"
on_success: change
on_failure: always
use_notice: true
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
- |
if [ "$DB" = 'postgresql' ]; then
echo "Check pgloader version"
pgloader --version
echo
fi
install:
- |
echo "Downloading dolibarr"
#wget -O dolibarr.tgz https://github.com/Dolibarr/dolibarr/archive/develop.zip
git clone --depth 1 -b develop https://github.com/Dolibarr/dolibarr.git /tmp/dolibarr
rsync -r /tmp/dolibarr/dev/ $TRAVIS_BUILD_DIR/dev
rsync -r /tmp/dolibarr/build/ $TRAVIS_BUILD_DIR/build
rsync -r /tmp/dolibarr/include/ $TRAVIS_BUILD_DIR/include
echo
- |
echo "Updating Composer"
rm $TRAVIS_BUILD_DIR/composer.json
rm $TRAVIS_BUILD_DIR/composer.lock
composer self-update
composer -n init
composer -n config vendor-dir htdocs/includes
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.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" = '7.1' ]; then
composer -n require phpunit/phpunit ^5
fi
if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require phpunit/phpunit ^5
fi
echo
- |
echo "Installing PHP CodeSniffer"
composer -n require squizlabs/php_codesniffer ^3
echo
- |
echo "Adding path of binaries tools installed by composer 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.4' ]; then
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly!
echo
echo "Enabling Memcached for PHP <= 5.4"
echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
fi
phpenv rehash
echo
- |
echo "Versions information"
# Check PHP
echo "PHP version"
php -i | head -
# Check PHP CodeSniffer installation
echo "PHPCS version"
which phpcs
phpcs --version | head -
phpcs -i | head -
# Check PHPUnit installation
echo "PHPUnit version"
which phpunit
phpunit --version | head -
# Check Apache version
echo "Apache version"
apache2 -v | head -
# Check MariaDb
echo "MariaDb version"
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
echo
- |
echo "Setting up database"
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 [email protected];'
mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_8.0.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
#pgloader mysql://root:[email protected]/dolibarr_9 postgresql://dolibarrowner:[email protected]/dolibarr_dev
echo pgloader mysql://[email protected]/travis postgresql:///travis
pgloader mysql://[email protected]/travis postgresql:///travis
echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis
echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis
#echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis
#echo 'select * from information_schema.table_constraints;' | psql travis
#echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis
fi
# TODO: SQLite
echo
- |
export CONF_FILE=htdocs/conf/conf.php
echo "Setting up Dolibarr $CONF_FILE"
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
echo '$'dolibarr_main_db_port=\'3306\'';' >> $CONF_FILE
fi
if [ "$DB" = 'postgresql' ]; then
echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_port=\'5432\'';' >> $CONF_FILE
fi
# TODO: SQLite
echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
cat $CONF_FILE
echo
- |
echo "Create documents directory and set permissions"
# and admin/temp subdirectory needed for unit tests
mkdir -p $TRAVIS_BUILD_DIR/documents/admin/temp
sudo chmod -R a+rwx $TRAVIS_BUILD_DIR/documents
echo "***** First line of dolibarr.log" > $TRAVIS_BUILD_DIR/documents/dolibarr.log
echo
- echo "Setting up Apache + FPM"
- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-fastcgi
# enable php-fpm php-sql
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- |
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
# Copy the included pool
sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
fi
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
# configure apache virtual hosts for precise
#- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
#- sudo cat /etc/apache2/sites-available/default
# configure apache virtual hosts for trusty
- sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
- sudo cat /etc/apache2/sites-available/000-default.conf
- sudo service apache2 restart
script:
- |
echo "Checking webserver availability by a wget -O - http://127.0.0.1"
# Ensure we stop on error with set -e
set +e
# The wget should return a page with line '<meta name="generator" content="Dolibarr installer">
wget -O - http://127.0.0.1 > test.html
head test.html
sudo cat /var/log/apache2/travis_error_log
set +e
echo
- |
echo "Checking PHP syntax errors"
# Ensure we catch errors
set -e
#parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude htdocs/includes --blame .
set +e
echo
- |
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/setup/codesniffer/ruleset.xml --encoding=utf-8 .
phpcs -s -p -d memory_limit=-1 --colors --tab-width=4 --ignore=/htdocs/timesheet/core/js --ignore=htdocs/includes --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .
set +e
echo
# TODO: Check Javascript (jshint?)
# TODO: Check CSS (csslint?)
- |
echo "Upgrading Dolibarr"
# Ensure we catch errors. Set this to +e if you want to go to the end to see log files.
rsync -r /tmp/dolibarr/ $TRAVIS_BUILD_DIR
//remove the dev include
rm $TRAVIS_BUILD_DIR/htdocs/timesheet/core/lib/dev.inc.php
set +e
cd htdocs/install
# Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING,MODULE_TIMESHEET > $TRAVIS_BUILD_DIR/enablemodule.log
echo $?
cd -
set +e
echo
#cat /tmp/dolibarr_install.log
cat $TRAVIS_BUILD_DIR/enablemodule.log
- |
echo "Unit testing"
# Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
set -e
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php
phpunitresult=$?
echo "Phpunit return code = $phpunitresult"
set +e
after_script:
- |
echo "After script - Output lines of dolibarr.log"
ls $TRAVIS_BUILD_DIR/documents
#cat $TRAVIS_BUILD_DIR/documents/dolibarr.log
sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log
after_success:
- |
echo Success
after_failure:
- |
echo Failure detected, so we show samples of log to help diagnose
# This part of code is executed only if previous command that fails are enclosed with set +e
# Upgrade log files
for ficlog in `ls $TRAVIS_BUILD_DIR/*.log`
do
echo "Debugging informations for file $ficlog"
#cat $ficlog
done
# Apache log file
echo "Debugging informations for file apache error.log"
sudo cat /var/log/apache2/travis_error_log
if [ "$DEBUG" = true ]; then
# Dolibarr log file
echo "Debugging informations for file dolibarr.log (latest 50 lines)"
tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log
# MariaDB log file
echo "Debugging informations for file mysql error.log"
sudo tail -n 50 /var/log/mysql/error.log
# TODO: PostgreSQL log file
echo
fi