3 # Copyright (C) 2020 Brady Miller <brady.g.miller@gmail.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Bash library for openemr ci
13 composer_github_auth
() {
14 githubToken
=`echo MjE2OTcwOGE2MmM5ZWRiMzA3NGFmNGVjMmZkOGE0MWY2YzVkMDJhZgo= | base64 --decode`
15 githubTokenRateLimitRequest
=`curl -H "Authorization: token $githubToken" https://api.github.com/rate_limit`
16 githubTokenRateLimit
=`echo $githubTokenRateLimitRequest | jq '.rate.remaining'`
17 echo "Number of github api requests remaining is $githubTokenRateLimit"
18 if [ "$githubTokenRateLimit" -gt 500 ]; then
19 echo "Trying to use composer github api token"
20 if `composer config --global --auth github-oauth.github.com "$githubToken"`; then
21 echo "github composer token worked"
23 echo "github composer token did not work"
26 echo "Not using composer github api token"
32 cd ci
/${DOCKER_DIR} || failTest
=true
33 docker-compose up
-d || failTest
=true
34 cd ..
/..
/ || failTest
=true
42 # TODO, figure out how not to require the below line (maybe chown or something like that)
44 composer
install || failTest
=true
45 npm
install || failTest
=true
46 npm run build || failTest
=true
47 composer global require phing
/phing || failTest
=true
48 $HOME/.composer
/vendor
/bin
/phing vendor-clean || failTest
=true
49 $HOME/.composer
/vendor
/bin
/phing assets-clean || failTest
=true
50 composer global remove phing
/phing || failTest
=true
51 composer dump-autoload
-o || failTest
=true
52 rm -fr node_modules || failTest
=true
60 cd ccdaservice || failTest
=true
61 npm
install || failTest
=true
62 cd ..
/ || failTest
=true
70 sudo
chmod 666 sites
/default
/sqlconf.php || failTest
=true
71 sudo
chmod -R 777 sites
/default
/documents || failTest
=true
72 sed -e 's@^exit;@ @' < contrib
/util
/installScripts
/InstallerAuto.php
> contrib
/util
/installScripts
/InstallerAutoTemp.php || failTest
=true
73 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
74 docker
exec -i $
(docker ps |
grep _openemr | cut
-f 1 -d " ") sh
-c "rm -f ${OPENEMR_DIR}/contrib/util/installScripts/InstallerAutoTemp.php" || failTest
=true
75 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
76 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
77 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
78 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
79 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
80 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_system_scopes_api\"" openemr' || failTest
=true
88 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
95 # Since e2e testing is a bit inconsistent, gonna do up to three runs (and only one needs to pass to pass the e2e testing)
98 docker
exec -i $
(docker ps |
grep _openemr | cut
-f 1 -d " ") sh
-c "${CHROMIUM_INSTALL}; export PANTHER_NO_SANDBOX=1; export PANTHER_CHROME_ARGUMENTS='--disable-dev-shm-usage'; cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite e2e --testdox" || failTest
=true
99 if [ "$failTest" == false
]; then
104 docker
exec -i $
(docker ps |
grep _openemr | cut
-f 1 -d " ") sh
-c "${CHROMIUM_INSTALL}; export PANTHER_NO_SANDBOX=1; export PANTHER_CHROME_ARGUMENTS='--disable-dev-shm-usage'; cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite e2e --testdox" || failTest
=true
105 if [ "$failTest" == false
]; then
110 docker
exec -i $
(docker ps |
grep _openemr | cut
-f 1 -d " ") sh
-c "${CHROMIUM_INSTALL}; export PANTHER_NO_SANDBOX=1; export PANTHER_CHROME_ARGUMENTS='--disable-dev-shm-usage'; cd ${OPENEMR_DIR}; php ${OPENEMR_DIR}/vendor/bin/phpunit --testsuite e2e --testdox" || failTest
=true
111 if [ "$failTest" == false
]; then
114 # failed 3 tests, so send the official fail
120 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
126 build_test_fixtures
() {
128 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
134 build_test_services
() {
136 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
142 build_test_validators
() {
144 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
150 build_test_controllers
() {
152 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
158 build_test_common
() {
160 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