php8 fixes (#4020)
[openemr.git] / .travis.yml
blob6713bbf94241493e36e809280796b1d82e8441d5
1 dist: bionic
2 language: php
3 .steps:
4   - &composer_github_auth |
5       githubTokenRateLimitRequest=`curl -H "Authorization: token 310659f0a8658693af9ccb9da8969584b598910a" https://api.github.com/rate_limit`
6       githubTokenRateLimit=`echo $githubTokenRateLimitRequest | jq '.rate.remaining'`
7       echo "Number of github api requests remaining is $githubTokenRateLimit"
8       if [ "$githubTokenRateLimit" -gt 500 ]; then
9         echo "Using composer github api token"
10         composer config --global --auth github-oauth.github.com 310659f0a8658693af9ccb9da8969584b598910a
11       else
12         echo "Not using composer github api token"
13       fi
14   - &lint_style |
15       failTest=false
16       echo "--------------------------------------"
17       echo "Checking for PHP styling (PSR-12) issues"
18       echo "--------------------------------------"
19       composer global require "squizlabs/php_codesniffer=3.*" || failTest=true
20       $HOME/.config/composer/vendor/bin/phpcs -p -n --extensions=php,inc --report-width=120 --standard=ci/phpcs.xml --report=full . || failTest=true
21       # todo clean up method visibility and other refactors in src/
22       # $HOME/.config/composer/vendor/bin/phpcs -p -n --extensions=php,inc --report-width=120 --standard=ci/phpcs_src.xml --report=full src/ || failTest=true
24       if $failTest; then
25         failJob=true
26         mes="FAILED"
27       else
28         mes="PASSED"
29       fi
30       echo "-----------------------------------------------"
31       jobTest="${mes} - Checking for PHP styling (PSR-12) issues"
32       jobTests+="${jobTest}\n"
33       echo "${jobTest}"
34       echo "-----------------------------------------------"
35   - &lint_theme_style |
36       failTest=false
37       echo "--------------------------------------"
38       echo "Checking for PHP theme styling issues"
39       echo "--------------------------------------"
40       npm install || failTest=true
41       npx stylelint "**/*.css" || failTest=true
42       npx stylelint "**/*.scss" || failTest=true
43       if $failTest; then
44         failJob=true
45         mes="FAILED"
46       else
47         mes="PASSED"
48       fi
49       echo "-----------------------------------------------"
50       jobTest="${mes} - Checking for PHP theme styling issues"
51       jobTests+="${jobTest}\n"
52       echo "${jobTest}"
53       echo "-----------------------------------------------"
54   - &lint_syntax |
55       failTest=false
56       echo "------------------------------"
57       echo "Checking for PHP syntax errors"
58       echo "------------------------------"
59       failSyntax=false
60       if find . -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 >&- | grep "^"; then failSyntax=true; fi
61       if find . -type f -name "*.inc" -exec php -d error_reporting=32767 -l {} \; 2>&1 >&- | grep "^"; then failSyntax=true; fi
62       if $failSyntax; then
63         failTest=true
64       fi
65       if $failTest; then
66         failJob=true
67         mes="FAILED"
68       else
69         mes="PASSED"
70       fi
71       echo "---------------------------------------"
72       jobTest="${mes} - Checking for PHP syntax errors"
73       jobTests+="${jobTest}\n"
74       echo "${jobTest}"
75       echo "---------------------------------------"
76   - &dockers_env_start |
77       failTest=false
78       echo "---------------------------------------------------------------------"
79       echo "Start up the appropriate testing docker system to allow testing below"
80       echo "---------------------------------------------------------------------"
81       cd ci/${DOCKER_DIR} || failTest=true
82       docker-compose up -d || failTest=true
83       cd ../../ || failTest=true
84       if $failTest; then
85         failJob=true
86         mes="FAILED"
87       else
88         mes="PASSED"
89       fi
90       echo "------------------------------------------------------------------------------"
91       jobTest="${mes} - Start up the appropriate testing docker system to allow testing below"
92       jobTests+="${jobTest}\n"
93       echo "${jobTest}"
94       echo "------------------------------------------------------------------------------"
95   - &main_build |
96       failTest=false
97       echo "------------------"
98       echo "Main OpenEMR Build"
99       echo "------------------"
100       composer install || failTest=true
101       npm install || failTest=true
102       npm run build || failTest=true
103       composer global require phing/phing || failTest=true
104       $HOME/.config/composer/vendor/bin/phing vendor-clean || failTest=true
105       $HOME/.config/composer/vendor/bin/phing assets-clean || failTest=true
106       composer global remove phing/phing || failTest=true
107       composer dump-autoload -o || failTest=true
108       rm -fr node_modules || failTest=true
109       if $failTest; then
110         failJob=true
111         mes="FAILED"
112       else
113         mes="PASSED"
114       fi
115       echo "---------------------------"
116       jobTest="${mes} - Main OpenEMR Build"
117       jobTests+="${jobTest}\n"
118       echo "${jobTest}"
119       echo "---------------------------"
120   - &ccda_build |
121       failTest=false
122       echo "------------------"
123       echo "CCDA OpenEMR Build"
124       echo "------------------"
125       cd ccdaservice || failTest=true
126       npm install || failTest=true
127       cd ../ || failTest=true
128       if $failTest; then
129         failJob=true
130         mes="FAILED"
131       else
132         mes="PASSED"
133       fi
134       echo "---------------------------"
135       jobTest="${mes} - CCDA OpenEMR Build"
136       jobTests+="${jobTest}\n"
137       echo "${jobTest}"
138       echo "---------------------------"
139   - &install_configure |
140       failTest=false
141       echo "----------------------------------------------------------------------------------------------"
142       echo "Install and Configure OpenEMR for testing (remove registration modal on login and turn on api)"
143       echo "----------------------------------------------------------------------------------------------"
144       sudo chmod 666 sites/default/sqlconf.php || failTest=true
145       sudo chmod -R 777 sites/default/documents || failTest=true
146       sed -e 's@^exit;@ @' < contrib/util/installScripts/InstallerAuto.php > contrib/util/installScripts/InstallerAutoTemp.php || failTest=true
147       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "php -f ${OPENEMR_DIR}/contrib/util/installScripts/InstallerAutoTemp.php rootpass=root server=mysql loginhost=%" || failTest=true
148       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "rm -f ${OPENEMR_DIR}/contrib/util/installScripts/InstallerAutoTemp.php" || failTest=true
149       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c 'mysql -u openemr --password="openemr" -h mysql -e "INSERT INTO product_registration (opt_out) VALUES (1)" openemr' || failTest=true
150       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c 'mysql -u openemr --password="openemr" -h mysql -e "UPDATE globals SET gl_value = 1 WHERE gl_name = \"rest_api\"" openemr' || failTest=true
151       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c 'mysql -u openemr --password="openemr" -h mysql -e "UPDATE globals SET gl_value = 1 WHERE gl_name = \"rest_fhir_api\"" openemr' || failTest=true
152       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c 'mysql -u openemr --password="openemr" -h mysql -e "UPDATE globals SET gl_value = 1 WHERE gl_name = \"rest_portal_api\"" openemr' || failTest=true
153       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c 'mysql -u openemr --password="openemr" -h mysql -e "UPDATE globals SET gl_value = 1 WHERE gl_name = \"rest_portal_fhir_api\"" openemr' || failTest=true
154       if $failTest; then
155         failJob=true
156         mes="FAILED"
157       else
158         mes="PASSED"
159       fi
160       echo "-------------------------------------------------------------------------------------------------------"
161       jobTest="${mes} - Install and Configure OpenEMR for testing (remove registration modal on login and turn on api)"
162       jobTests+="${jobTest}\n"
163       echo "${jobTest}"
164       echo "-------------------------------------------------------------------------------------------------------"
165   - &build_test_unit |
166       failTest=false
167       echo "---------------"
168       echo "Run Unit Tests"
169       echo "---------------"
170       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite unit --testdox" || failTest=true
171       if $failTest; then
172         failJob=true
173         mes="FAILED"
174       else
175         mes="PASSED"
176       fi
177       echo "-----------------------"
178       jobTest="${mes} - Run Unit Tests"
179       jobTests+="${jobTest}\n"
180       echo "${jobTest}"
181       echo "-----------------------"
182   - &build_test_e2e |
183       failTest=false
184       echo "-------------"
185       echo "Run E2e Tests"
186       echo "-------------"
187       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "${CHROMIUM_INSTALL}; export PANTHER_NO_SANDBOX=1; cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite e2e --testdox" || failTest=true
188       if $failTest; then
189         failJob=true
190         mes="FAILED"
191       else
192         mes="PASSED"
193       fi
194       echo "----------------------"
195       jobTest="${mes} - Run E2e Tests"
196       jobTests+="${jobTest}\n"
197       echo "${jobTest}"
198       echo "----------------------"
199   - &build_test_api |
200       failTest=false
201       echo "-------------"
202       echo "Run Api Tests"
203       echo "-------------"
204       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite api --testdox" || failTest=true
205       if $failTest; then
206         failJob=true
207         mes="FAILED"
208       else
209         mes="PASSED"
210       fi
211       echo "----------------------"
212       jobTest="${mes} - Run Api Tests"
213       jobTests+="${jobTest}\n"
214       echo "${jobTest}"
215       echo "----------------------"
216   - &build_test_fixtures |
217       failTest=false
218       echo "-------------"
219       echo "Run Fixture Tests"
220       echo "-------------"
221       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite fixtures --testdox" || failTest=true
222       if $failTest; then
223         failJob=true
224         mes="FAILED"
225       else
226         mes="PASSED"
227       fi
228       echo "----------------------"
229       jobTest="${mes} - Run Fixture Tests"
230       jobTests+="${jobTest}\n"
231       echo "${jobTest}"
232       echo "----------------------"
233   - &build_test_services |
234       failTest=false
235       echo "-------------"
236       echo "Run Service Tests"
237       echo "-------------"
238       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite services --testdox" || failTest=true
239       if $failTest; then
240         failJob=true
241         mes="FAILED"
242       else
243         mes="PASSED"
244       fi
245       echo "----------------------"
246       jobTest="${mes} - Run Service Tests"
247       jobTests+="${jobTest}\n"
248       echo "${jobTest}"
249       echo "----------------------"
250   - &build_test_validators |
251       failTest=false
252       echo "-------------"
253       echo "Run Validator Tests"
254       echo "-------------"
255       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite validators --testdox" || failTest=true
256       if $failTest; then
257         failJob=true
258         mes="FAILED"
259       else
260         mes="PASSED"
261       fi
262       echo "----------------------"
263       jobTest="${mes} - Run Validator Tests"
264       jobTests+="${jobTest}\n"
265       echo "${jobTest}"
266       echo "----------------------"
267   - &build_test_controllers |
268       failTest=false
269       echo "-------------"
270       echo "Run Controller Tests"
271       echo "-------------"
272       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite controllers --testdox" || failTest=true
273       if $failTest; then
274         failJob=true
275         mes="FAILED"
276       else
277         mes="PASSED"
278       fi
279       echo "----------------------"
280       jobTest="${mes} - Run Controller Tests"
281       jobTests+="${jobTest}\n"
282       echo "${jobTest}"
283       echo "----------------------"
284   - &build_test_common |
285       failTest=false
286       echo "-------------"
287       echo "Run Common Tests"
288       echo "-------------"
289       docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c "cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite common --testdox" || failTest=true
290       if $failTest; then
291         failJob=true
292         mes="FAILED"
293       else
294         mes="PASSED"
295       fi
296       echo "----------------------"
297       jobTest="${mes} - Run Common Tests"
298       jobTests+="${jobTest}\n"
299       echo "${jobTest}"
300       echo "----------------------"
301   - &job_summary_prep |
302       if $failJob; then
303         mes="FAILED"
304       else
305         mes="PASSED"
306       fi
307       jobSummary="--------------------------------------------\n"
308       jobSummary+="--------------------------------------------\n"
309       jobSummary+="${mes} - JOB SUMMARY\n"
310       jobSummary+="--------------------------------------------\n"
311       jobSummary+="${jobTests}"
312       jobSummary+="--------------------------------------------"
313 before_install:
314   - echo "extension=ldap.so" >>php --ini | grep "Loaded Configuration" | sed -e "s|.:\s||"``
315   - nvm install --lts
316 before_script:
317   - echo 'error_reporting = "E_ALL & ~E_NOTICE & ~E_STRICT"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
318 jobs:
319   include:
320     - name: 'Psr12 style'
321       php: '7.4'
322       script:
323         - failJob=false
324         - *composer_github_auth
325         - *lint_style
326         - *job_summary_prep
327         - echo -e "${jobSummary}"
328         - if $failJob; then travis_terminate 1; fi
329     - name: 'Theme style'
330       php: '7.4'
331       script:
332         - failJob=false
333         - *lint_theme_style
334         - *job_summary_prep
335         - echo -e "${jobSummary}"
336         - if $failJob; then travis_terminate 1; fi
337     - name: 'Syntax - PHP 7.3'
338       php: '7.3'
339       script:
340         - failJob=false
341         - *lint_syntax
342         - *job_summary_prep
343         - echo -e "${jobSummary}"
344         - if $failJob; then travis_terminate 1; fi
345     - name: 'Syntax - PHP 7.4'
346       php: '7.4'
347       script:
348         - failJob=false
349         - *lint_syntax
350         - *job_summary_prep
351         - echo -e "${jobSummary}"
352         - if $failJob; then travis_terminate 1; fi
353     - name: 'Syntax - PHP 8.0'
354       php: 'nightly'
355       script:
356         - failJob=false
357         - *lint_syntax
358         - *job_summary_prep
359         - echo -e "${jobSummary}"
360         - if $failJob; then travis_terminate 1; fi
361     - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.5'
362       php: '7.3'
363       env:
364         - DOCKER_DIR=apache_73_105
365         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
366         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
367       script:
368         - failJob=false
369         - *dockers_env_start
370         - *composer_github_auth
371         - *main_build
372         - *ccda_build
373         - *install_configure
374         - *build_test_unit
375         - *build_test_e2e
376         #- *build_test_api
377         - *build_test_fixtures
378         - *build_test_services
379         - *build_test_validators
380         - *build_test_controllers
381         - *build_test_common
382         - *job_summary_prep
383         - echo -e "${jobSummary}"
384         - if $failJob; then travis_terminate 1; fi
385     - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.4'
386       php: '7.3'
387       env:
388         - DOCKER_DIR=apache_73_104
389         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
390         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
391       script:
392         - failJob=false
393         - *dockers_env_start
394         - *composer_github_auth
395         - *main_build
396         - *ccda_build
397         - *install_configure
398         - *build_test_unit
399         - *build_test_e2e
400         #- *build_test_api
401         - *build_test_fixtures
402         - *build_test_services
403         - *build_test_validators
404         - *build_test_controllers
405         - *build_test_common
406         - *job_summary_prep
407         - echo -e "${jobSummary}"
408         - if $failJob; then travis_terminate 1; fi
409     - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.3'
410       php: '7.3'
411       env:
412         - DOCKER_DIR=apache_73_103
413         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
414         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
415       script:
416         - failJob=false
417         - *dockers_env_start
418         - *composer_github_auth
419         - *main_build
420         - *ccda_build
421         - *install_configure
422         - *build_test_unit
423         - *build_test_e2e
424         #- *build_test_api
425         - *build_test_fixtures
426         - *build_test_services
427         - *build_test_validators
428         - *build_test_controllers
429         - *build_test_common
430         - *job_summary_prep
431         - echo -e "${jobSummary}"
432         - if $failJob; then travis_terminate 1; fi
433     - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.2'
434       php: '7.3'
435       env:
436         - DOCKER_DIR=apache_73_102
437         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
438         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
439       script:
440         - failJob=false
441         - *dockers_env_start
442         - *composer_github_auth
443         - *main_build
444         - *ccda_build
445         - *install_configure
446         - *build_test_unit
447         - *build_test_e2e
448         #- *build_test_api
449         - *build_test_fixtures
450         - *build_test_services
451         - *build_test_validators
452         - *build_test_controllers
453         - *build_test_common
454         - *job_summary_prep
455         - echo -e "${jobSummary}"
456         - if $failJob; then travis_terminate 1; fi
457     - name: 'Build and test - PHP 7.3 - Apache - MySQL 8'
458       php: '7.3'
459       env:
460         - DOCKER_DIR=apache_73_8
461         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
462         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
463       script:
464         - failJob=false
465         - *dockers_env_start
466         - *composer_github_auth
467         - *main_build
468         - *ccda_build
469         - *install_configure
470         - *build_test_unit
471         - *build_test_e2e
472         #- *build_test_api
473         - *build_test_fixtures
474         - *build_test_services
475         - *build_test_validators
476         - *build_test_controllers
477         - *build_test_common
478         - *job_summary_prep
479         - echo -e "${jobSummary}"
480         - if $failJob; then travis_terminate 1; fi
481     - name: 'Build and test - PHP 7.3 - Apache - MySQL 5.7'
482       php: '7.3'
483       env:
484         - DOCKER_DIR=apache_73_57
485         - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
486         - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
487       script:
488         - failJob=false
489         - *dockers_env_start
490         - *composer_github_auth
491         - *main_build
492         - *ccda_build
493         - *install_configure
494         - *build_test_unit
495         - *build_test_e2e
496         #- *build_test_api
497         - *build_test_fixtures
498         - *build_test_services
499         - *build_test_validators
500         - *build_test_controllers
501         - *build_test_common
502         - *job_summary_prep
503         - echo -e "${jobSummary}"
504         - if $failJob; then travis_terminate 1; fi
505     - name: 'Build and test - PHP 7.3 - Nginx - MariaDB 10.5'
506       php: '7.3'
507       env:
508         - DOCKER_DIR=nginx_73
509         - OPENEMR_DIR=/usr/share/nginx/html/openemr
510         - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
511       script:
512         - failJob=false
513         - *dockers_env_start
514         - *composer_github_auth
515         - *main_build
516         - *ccda_build
517         - *install_configure
518         - *build_test_unit
519         - *build_test_e2e
520         #- *build_test_api
521         - *build_test_fixtures
522         - *build_test_services
523         - *build_test_validators
524         - *build_test_controllers
525         - *build_test_common
526         - *job_summary_prep
527         - echo -e "${jobSummary}"
528         - if $failJob; then travis_terminate 1; fi
529     - name: 'Build and test - PHP 7.4 - Nginx - MariaDB 10.5'
530       php: '7.4'
531       env:
532         - DOCKER_DIR=nginx_74
533         - OPENEMR_DIR=/usr/share/nginx/html/openemr
534         - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
535       script:
536         - failJob=false
537         - *dockers_env_start
538         - *composer_github_auth
539         - *main_build
540         - *ccda_build
541         - *install_configure
542         - *build_test_unit
543         - *build_test_e2e
544         #- *build_test_api
545         - *build_test_fixtures
546         - *build_test_services
547         - *build_test_validators
548         - *build_test_controllers
549         - *build_test_common
550         - *job_summary_prep
551         - echo -e "${jobSummary}"
552         - if $failJob; then travis_terminate 1; fi
553     - name: 'Build and test - PHP 8.0 - Nginx - MariaDB 10.5'
554       php: 'nightly'
555       env:
556         - DOCKER_DIR=nginx_80
557         - OPENEMR_DIR=/usr/share/nginx/html/openemr
558         - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
559       script:
560         - failJob=false
561         - *dockers_env_start
562         - *composer_github_auth
563         - *main_build
564         - *ccda_build
565         - *install_configure
566         - *build_test_unit
567         #- *build_test_api
568         - *build_test_fixtures
569         - *build_test_services
570         - *build_test_validators
571         - *build_test_controllers
572         - *build_test_common
573         - *job_summary_prep
574         - echo -e "${jobSummary}"
575         - if $failJob; then travis_terminate 1; fi