fix: add vendor directory to .eslintignore
[openemr.git] / ci / ciLibrary.source
blob42374f0ee205eb06dd4e99fdc52e47ad973b8fb5
1 #!/bin/bash
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"
22 else
23 echo "github composer token did not work"
25 else
26 echo "Not using composer github api token"
30 dockers_env_start() {
31 failTest=false
32 cd ci/${DOCKER_DIR} || failTest=true
33 docker-compose up -d || failTest=true
34 cd ../../ || failTest=true
35 if $failTest; then
36 exit 1
40 main_build() {
41 failTest=false
42 # TODO, figure out how not to require the below line (maybe chown or something like that)
43 sudo chmod -R 0777 .
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
53 if $failTest; then
54 exit 1
58 ccda_build() {
59 failTest=false
60 cd ccdaservice || failTest=true
61 npm install || failTest=true
62 cd ../ || failTest=true
63 if $failTest; then
64 exit 1
68 install_configure() {
69 failTest=false
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
81 if $failTest; then
82 exit 1
86 build_test_unit() {
87 failTest=false
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
89 if $failTest; then
90 exit 1
94 build_test_e2e() {
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)
96 # first run
97 failTest=false
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
100 exit
102 # try run again
103 failTest=false
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
106 exit
108 # hail mary run
109 failTest=false
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
112 exit
114 # failed 3 tests, so send the official fail
115 exit 1
118 build_test_api() {
119 failTest=false
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
121 if $failTest; then
122 exit 1
126 build_test_fixtures() {
127 failTest=false
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
129 if $failTest; then
130 exit 1
134 build_test_services() {
135 failTest=false
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
137 if $failTest; then
138 exit 1
142 build_test_validators() {
143 failTest=false
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
145 if $failTest; then
146 exit 1
150 build_test_controllers() {
151 failTest=false
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
153 if $failTest; then
154 exit 1
158 build_test_common() {
159 failTest=false
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
161 if $failTest; then
162 exit 1