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
12 echo "Not using composer github api token"
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
30 echo "-----------------------------------------------"
31 jobTest="${mes} - Checking for PHP styling (PSR-12) issues"
32 jobTests+="${jobTest}\n"
34 echo "-----------------------------------------------"
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
49 echo "-----------------------------------------------"
50 jobTest="${mes} - Checking for PHP theme styling issues"
51 jobTests+="${jobTest}\n"
53 echo "-----------------------------------------------"
56 echo "------------------------------"
57 echo "Checking for PHP syntax errors"
58 echo "------------------------------"
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
71 echo "---------------------------------------"
72 jobTest="${mes} - Checking for PHP syntax errors"
73 jobTests+="${jobTest}\n"
75 echo "---------------------------------------"
76 - &dockers_env_start |
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
90 echo "------------------------------------------------------------------------------"
91 jobTest="${mes} - Start up the appropriate testing docker system to allow testing below"
92 jobTests+="${jobTest}\n"
94 echo "------------------------------------------------------------------------------"
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
115 echo "---------------------------"
116 jobTest="${mes} - Main OpenEMR Build"
117 jobTests+="${jobTest}\n"
119 echo "---------------------------"
122 echo "------------------"
123 echo "CCDA OpenEMR Build"
124 echo "------------------"
125 cd ccdaservice || failTest=true
126 npm install || failTest=true
127 cd ../ || failTest=true
134 echo "---------------------------"
135 jobTest="${mes} - CCDA OpenEMR Build"
136 jobTests+="${jobTest}\n"
138 echo "---------------------------"
139 - &install_configure |
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 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 = 3 WHERE gl_name = \"oauth_password_grant\"" openemr' || failTest=true
161 echo "-------------------------------------------------------------------------------------------------------"
162 jobTest="${mes} - Install and Configure OpenEMR for testing (remove registration modal on login and turn on api)"
163 jobTests+="${jobTest}\n"
165 echo "-------------------------------------------------------------------------------------------------------"
168 echo "---------------"
169 echo "Run Unit Tests"
170 echo "---------------"
171 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
178 echo "-----------------------"
179 jobTest="${mes} - Run Unit Tests"
180 jobTests+="${jobTest}\n"
182 echo "-----------------------"
188 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
195 echo "----------------------"
196 jobTest="${mes} - Run E2e Tests"
197 jobTests+="${jobTest}\n"
199 echo "----------------------"
205 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
212 echo "----------------------"
213 jobTest="${mes} - Run Api Tests"
214 jobTests+="${jobTest}\n"
216 echo "----------------------"
217 - &build_test_fixtures |
220 echo "Run Fixture Tests"
222 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
229 echo "----------------------"
230 jobTest="${mes} - Run Fixture Tests"
231 jobTests+="${jobTest}\n"
233 echo "----------------------"
234 - &build_test_services |
237 echo "Run Service Tests"
239 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
246 echo "----------------------"
247 jobTest="${mes} - Run Service Tests"
248 jobTests+="${jobTest}\n"
250 echo "----------------------"
251 - &build_test_validators |
254 echo "Run Validator Tests"
256 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
263 echo "----------------------"
264 jobTest="${mes} - Run Validator Tests"
265 jobTests+="${jobTest}\n"
267 echo "----------------------"
268 - &build_test_controllers |
271 echo "Run Controller Tests"
273 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
280 echo "----------------------"
281 jobTest="${mes} - Run Controller Tests"
282 jobTests+="${jobTest}\n"
284 echo "----------------------"
285 - &build_test_common |
288 echo "Run Common Tests"
290 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
297 echo "----------------------"
298 jobTest="${mes} - Run Common Tests"
299 jobTests+="${jobTest}\n"
301 echo "----------------------"
302 - &job_summary_prep |
308 jobSummary="--------------------------------------------\n"
309 jobSummary+="--------------------------------------------\n"
310 jobSummary+="${mes} - JOB SUMMARY\n"
311 jobSummary+="--------------------------------------------\n"
312 jobSummary+="${jobTests}"
313 jobSummary+="--------------------------------------------"
315 - echo "extension=ldap.so" >>php --ini | grep "Loaded Configuration" | sed -e "s|.:\s||"``
318 - echo 'error_reporting = "E_ALL & ~E_NOTICE & ~E_STRICT"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
321 - name: 'Psr12 style'
325 - *composer_github_auth
328 - echo -e "${jobSummary}"
329 - if $failJob; then travis_terminate 1; fi
330 - name: 'Theme style'
336 - echo -e "${jobSummary}"
337 - if $failJob; then travis_terminate 1; fi
338 - name: 'Syntax - PHP 7.3'
344 - echo -e "${jobSummary}"
345 - if $failJob; then travis_terminate 1; fi
346 - name: 'Syntax - PHP 7.4'
352 - echo -e "${jobSummary}"
353 - if $failJob; then travis_terminate 1; fi
354 - name: 'Syntax - PHP 8.0'
360 - echo -e "${jobSummary}"
361 - if $failJob; then travis_terminate 1; fi
362 - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.5'
365 - DOCKER_DIR=apache_73_105
366 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
367 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
371 - *composer_github_auth
378 - *build_test_fixtures
379 - *build_test_services
380 - *build_test_validators
381 - *build_test_controllers
384 - echo -e "${jobSummary}"
385 - if $failJob; then travis_terminate 1; fi
386 - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.4'
389 - DOCKER_DIR=apache_73_104
390 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
391 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
395 - *composer_github_auth
402 - *build_test_fixtures
403 - *build_test_services
404 - *build_test_validators
405 - *build_test_controllers
408 - echo -e "${jobSummary}"
409 - if $failJob; then travis_terminate 1; fi
410 - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.3'
413 - DOCKER_DIR=apache_73_103
414 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
415 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
419 - *composer_github_auth
426 - *build_test_fixtures
427 - *build_test_services
428 - *build_test_validators
429 - *build_test_controllers
432 - echo -e "${jobSummary}"
433 - if $failJob; then travis_terminate 1; fi
434 - name: 'Build and test - PHP 7.3 - Apache - MariaDB 10.2'
437 - DOCKER_DIR=apache_73_102
438 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
439 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
443 - *composer_github_auth
450 - *build_test_fixtures
451 - *build_test_services
452 - *build_test_validators
453 - *build_test_controllers
456 - echo -e "${jobSummary}"
457 - if $failJob; then travis_terminate 1; fi
458 - name: 'Build and test - PHP 7.3 - Apache - MySQL 8'
461 - DOCKER_DIR=apache_73_8
462 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
463 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
467 - *composer_github_auth
474 - *build_test_fixtures
475 - *build_test_services
476 - *build_test_validators
477 - *build_test_controllers
480 - echo -e "${jobSummary}"
481 - if $failJob; then travis_terminate 1; fi
482 - name: 'Build and test - PHP 7.3 - Apache - MySQL 5.7'
485 - DOCKER_DIR=apache_73_57
486 - OPENEMR_DIR=/var/www/localhost/htdocs/openemr
487 - CHROMIUM_INSTALL="apk update; apk add --no-cache chromium chromium-chromedriver; export PANTHER_CHROME_DRIVER_BINARY=/usr/lib/chromium/chromedriver"
491 - *composer_github_auth
498 - *build_test_fixtures
499 - *build_test_services
500 - *build_test_validators
501 - *build_test_controllers
504 - echo -e "${jobSummary}"
505 - if $failJob; then travis_terminate 1; fi
506 - name: 'Build and test - PHP 7.3 - Nginx - MariaDB 10.5'
509 - DOCKER_DIR=nginx_73
510 - OPENEMR_DIR=/usr/share/nginx/html/openemr
511 - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
515 - *composer_github_auth
522 - *build_test_fixtures
523 - *build_test_services
524 - *build_test_validators
525 - *build_test_controllers
528 - echo -e "${jobSummary}"
529 - if $failJob; then travis_terminate 1; fi
530 - name: 'Build and test - PHP 7.4 - Nginx - MariaDB 10.5'
533 - DOCKER_DIR=nginx_74
534 - OPENEMR_DIR=/usr/share/nginx/html/openemr
535 - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
539 - *composer_github_auth
546 - *build_test_fixtures
547 - *build_test_services
548 - *build_test_validators
549 - *build_test_controllers
552 - echo -e "${jobSummary}"
553 - if $failJob; then travis_terminate 1; fi
554 - name: 'Build and test - PHP 8.0 - Nginx - MariaDB 10.5'
557 - DOCKER_DIR=nginx_80
558 - OPENEMR_DIR=/usr/share/nginx/html/openemr
559 - CHROMIUM_INSTALL="apt-get update; apt-get install -y chromium-driver; export PANTHER_CHROME_DRIVER_BINARY=/usr/bin/chromedriver"
563 - *composer_github_auth
570 - *build_test_fixtures
571 - *build_test_services
572 - *build_test_validators
573 - *build_test_controllers
576 - echo -e "${jobSummary}"
577 - if $failJob; then travis_terminate 1; fi