forked from Easya-Solutions/dolibarr
-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (327 loc) · 17.6 KB
/
github_ci_php71_pgsql.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
name: GitHub CI PHP 7.1 Postgres
on:
push:
branches:
- develop
- 1*
- 2*
pull_request:
types: [opened]
permissions:
contents: read
jobs:
github_ci_php71_pgsql:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 32574:3306
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# git clone dolibarr into GITHUB_WORKSPACE = /home/runner/work/dolibarr/dolibarr
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Version PHP
run: |
php -i | head -
- name: Install packages for PHP 7.1
run: |
sudo composer self-update 2.2.18
sudo chmod -R a+rwx /home/runner
composer -n config -g vendor-dir htdocs/includes
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y pgloader memcached
sudo apt install apache2 php7.1 php7.1-cli php7.1-curl php7.1-mysql php7.1-pgsql php7.1-gd php7.1-imap php7.1-intl php7.1-ldap php7.1-xml php7.1-mbstring php7.1-xml php7.1-zip libapache2-mod-php7.1
sudo update-alternatives --set php /usr/bin/php7.1
php -i | head -
cd $GITHUB_WORKSPACE
ls $GITHUB_WORKSPACE
composer -n require --ignore-platform-reqs phpunit/phpunit ^7.5 \
php-parallel-lint/php-parallel-lint ^1 \
php-parallel-lint/php-console-highlighter ^0 \
php-parallel-lint/php-var-dump-check ~0.4 \
squizlabs/php_codesniffer ^3
#For php7.3
#composer -n require phpunit/phpunit ^7.5 \
# php-parallel-lint/php-parallel-lint ^1.2 \
# php-parallel-lint/php-console-highlighter ^0 \
# php-parallel-lint/php-var-dump-check ~0.4 \
# squizlabs/php_codesniffer ^3
sudo rm -fr htdocs/includes/phpunit/php-code-coverage/src/Report/Html
- name: Adding path of binaries tools installed by composer to the PATH
run: |
export PATH="$GITHUB_WORKSPACE/htdocs/includes/bin:$PATH"
echo $PATH
# We must have a directory bin created by the previous composer call
ls $GITHUB_WORKSPACE/htdocs/includes/bin
- name: Version information
run: |
composer -V
# Check Parallel-lint version
echo "Parallel-lint version"
htdocs/includes/bin/parallel-lint -V
# Check PHP CodeSniffer version
echo "PHPCS version"
htdocs/includes/bin/phpcs --version | head -
htdocs/includes/bin/phpcs -i | head -
# Check PHP Vardump check version
echo "PHP Vardump check version"
htdocs/includes/bin/var-dump-check --version
# Check PHPUnit version
echo "PHPUnit version"
htdocs/includes/bin/phpunit --version | head -
# Check Apache version
echo "Apache version"
apache2 -v | head -
# Check Database
echo "Database version"
mysql --version | head -
psql --version
echo "Check pgloader version"
pgloader --version
- name: Create database
run: |
pwd
echo GITHUB_WORKSPACE = $GITHUB_WORKSPACE
sudo apt-get install -y mysql-client
mysql --version | head -
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SELECT VERSION();" | head -
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SHOW DATABASES"
echo "Drop and create database"
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'DROP DATABASE IF EXISTS travis;'
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8';"
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password';"
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'GRANT ALL PRIVILEGES ON travis.* TO [email protected];'
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'FLUSH PRIVILEGES;'
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis -e "UPDATE llx_const set value = '0666' WHERE name = 'MAIN_UMASK';"
#psql -c 'create database travis;' -U postgres
#psql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
#pgloader mysql://root:[email protected]:32574/dolibarr_src postgresql://dolibarrowner:[email protected]/dolibarr_dest
ps fauxww | grep postgres
ls /etc/postgresql/14/main/
sudo chmod -R a+rwx /etc/postgresql/14/main/pg_hba.conf
sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/14/main/pg_hba.conf
sudo cat /etc/postgresql/14/main/pg_hba.conf
sudo /etc/init.d/postgresql restart
psql postgresql://postgres:[email protected]:5432 -l -A
psql postgresql://postgres:[email protected]:5432 -c 'create database travis;'
sudo mkdir -p /tmp/pgloader
sudo chmod -R a+rwx /tmp/pgloader/
echo sudo pgloader mysql://root:[email protected]:32574/travis postgresql://postgres:[email protected]:5432/travis
sudo pgloader mysql://root:[email protected]:32574/travis postgresql://postgres:[email protected]:5432/travis
echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql postgresql://postgres:[email protected]:5432/travis
echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql postgresql://postgres:[email protected]:5432/travis
# Create pgsql compatibility functions
psql postgresql://postgres:[email protected]:5432/travis < htdocs/install/pgsql/functions/functions.sql
- name: Generate Dolibarr conf file
run: |
export CONF_FILE=$GITHUB_WORKSPACE/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=\'/var/www/html\'';' >> $CONF_FILE
echo '$'dolibarr_main_data_root=\'/var/www/html/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=\'root\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_pass=\'password\'';' >> $CONF_FILE
echo '$'dolibarr_main_instance_unique_id=\'travis1234567890\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_port=\'32574\'';' >> $CONF_FILE
echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
cat $CONF_FILE
- name: Generate install.forced.php file to test installation
run: |
export INSTALL_FORCED_FILE=$GITHUB_WORKSPACE/htdocs/install/install.forced.php
echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation"
# Ensure we catch errors
set +e
echo '<?php' > $INSTALL_FORCED_FILE
echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE
#echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE
echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE
echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE
echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE
echo '$'force_install_databaselogin=\'root\'';' >> $INSTALL_FORCED_FILE
echo '$'force_install_databasepass=\'password\'';' >> $INSTALL_FORCED_FILE
#echo '$'force_install_port=\'32574\'';' >> $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=\'/var/www/html\'';' >> $INSTALL_FORCED_FILE
cat $INSTALL_FORCED_FILE
- name: Create document directory
run: |
echo "Create documents directory and set permissions"
# and admin/temp subdirectory needed for unit tests
sudo mkdir -p /var/www/html/documents/admin/temp
sudo chmod -R a+rwx /var/www/html/documents
sudo echo "***** First line of dolibarr.log" > /var/www/html/documents/dolibarr.log
sudo chmod a+rwx /var/www/html/documents/dolibarr.log
- name: Copy app into /var/www
run: |
sudo cp -r $GITHUB_WORKSPACE/htdocs/. /var/www/html
sudo mv /var/www/html/index.html /var/www/html/index.disabled.html
sudo ln -fs /var/www/html /var/www/htdocs
sudo cp -r $GITHUB_WORKSPACE/test/. /var/www/test
sudo cp -r $GITHUB_WORKSPACE/dev/. /var/www/dev
sudo cp -r $GITHUB_WORKSPACE/scripts/. /var/www/scripts
- name: Setup Apache
run: |
pwd
whoami
# install apache web server
a2query -s
a2query -m
ls /etc/apache2/sites-available
#sudo cp -f $GITHUB_WORKSPACE/build/travis-ci/apache-githubaction.conf /etc/apache2/sites-available/000-default.conf
#sudo sed -e "s?%GITHUB_WORKSPACE%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
a2ensite 000-default
a2enmod php7.1
ls /etc/apache2/sites-enabled
sudo adduser $(whoami) www-data
sudo adduser $(whoami) root
sudo adduser root www-data
sudo chown -R www-data:www-data /etc/apache2/sites-available/
sudo chmod -R 777 /etc/apache2/sites-available/
sudo chown -R www-data:www-data /var/www/html/
ls -l /var/www/html
#ls -l /var/www/html/conf
#ls -l /var/www/html/install/
set +e
sudo cat /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart
curl -I localhost
- name: Chech Apache availability
run: |
echo "Checking webserver availability by a wget -O - --debug http://127.0.0.1"
# Ensure we stop on error with set -e
set +e
ls /var/log/apache2
#wget -O - --debug http://127.0.0.1/robots.txt
# The wget should return a page with line '<meta name="generator" content="Dolibarr installer">
wget -O - --debug http://127.0.0.1 > $GITHUB_WORKSPACE/test.html 2>&1
head -n 200 $GITHUB_WORKSPACE/test.html
echo Logs are...
#sudo cat /tmp/install.log
sudo cat /var/log/apache2/access.log
sudo cat /var/log/apache2/error.log
sudo cat /var/log/apache2/other_vhosts_access.log
set +e
- name: Upgrading Dolibarr
run: |
# Ensure we catch errors. Set this to +e if you want to go to the end to see log files.
set -e
sudo chmod -R a+rwx $GITHUB_WORKSPACE
sudo chmod -R a+rwx /var/www
ls -l /var/www
cd /var/www/html/install
echo Execute upgrade, upgrade2 and step5 for each major version
php upgrade.php 3.5.0 3.6.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade350360.log
php upgrade2.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-2.log
php step5.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-3.log
php upgrade.php 3.6.0 3.7.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade360370.log
php upgrade2.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-2.log
php step5.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-3.log
php upgrade.php 3.7.0 3.8.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade370380.log
php upgrade2.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-2.log
php step5.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-3.log
php upgrade.php 3.8.0 3.9.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade380390.log
php upgrade2.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-2.log
php step5.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-3.log
php upgrade.php 3.9.0 4.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade390400.log
php upgrade2.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-2.log
php step5.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-3.log
php upgrade.php 4.0.0 5.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade400500.log
php upgrade2.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-2.log
php step5.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-3.log
php upgrade.php 5.0.0 6.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade500600.log
php upgrade2.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-2.log
php step5.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-3.log
php upgrade.php 6.0.0 7.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade600700.log
php upgrade2.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-2.log
php step5.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-3.log
php upgrade.php 7.0.0 8.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade700800.log
php upgrade2.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-2.log
php step5.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-3.log
php upgrade.php 8.0.0 9.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade800900.log
php upgrade2.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-2.log
php step5.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-3.log
php upgrade.php 9.0.0 10.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade9001000.log
php upgrade2.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-2.log
php step5.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-3.log
php upgrade.php 10.0.0 11.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade10001100.log
php upgrade2.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-2.log
php step5.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-3.log
php upgrade.php 11.0.0 12.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade11001200.log
php upgrade2.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-2.log
php step5.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-3.log
php upgrade.php 12.0.0 13.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade12001300.log
php upgrade2.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-2.log
php step5.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-3.log
php upgrade.php 13.0.0 14.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade13001400.log
php upgrade2.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-2.log
php step5.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-3.log
php upgrade.php 14.0.0 15.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade14001500.log
php upgrade2.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-2.log
php step5.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-3.log
php upgrade.php 15.0.0 16.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade15001600.log
php upgrade2.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-2.log
php step5.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-3.log
php upgrade.php 16.0.0 17.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade16001700.log
php upgrade2.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-2.log
php step5.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-3.log
- name: Result of migration scripts
if: always()
run: |
ls -alrt $GITHUB_WORKSPACE/
echo Show content of last file
cat "$(ls -rt $GITHUB_WORKSPACE/ | tail -n1)"
- name: Enabling new modules
run: |
# Enable modules not enabled into original dump
set -e
cd /var/www/html/install
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_ProductBatch,MAIN_MODULE_SupplierProposal,MAIN_MODULE_STRIPE,MAIN_MODULE_ExpenseReport > $GITHUB_WORKSPACE/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $GITHUB_WORKSPACE/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $GITHUB_WORKSPACE/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KnowledgeManagement,MAIN_MODULE_EventOrganization,MAIN_MODULE_PARTNERSHIP >> $GITHUB_WORKSPACE/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_EmailCollector >> $GITHUB_WORKSPACE/enablemodule.log
echo $?
cd -
- name: Result of enabling modules scripts
if: always()
run: |
echo Show content of enablemodule.log file
cat $GITHUB_WORKSPACE/enablemodule.log
- name: Unit testing
run: |
# Ensure we catch errors. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file.
set -e
cd /var/www/html
sudo chmod -R a+rwx /var/www/html/documents
includes/bin/phpunit -d memory_limit=-1 -c /var/www/test/phpunit/phpunittest.xml /var/www/test/phpunit/AllTests.php
phpunitresult=$?
echo "Phpunit return code = $phpunitresult"
set +e