Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Mohammad Hasnain Mohsin Rajan | 46d5431 | 2021-03-15 11:17:19 +0530 | [diff] [blame] | 3 | set -e |
| 4 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 5 | cd ~ || exit |
| 6 | |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 7 | sudo apt-get install redis-server libcups2-dev |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 8 | |
| 9 | pip install frappe-bench |
| 10 | |
Ankush Menat | 6f2c9c6 | 2022-02-03 17:30:42 +0530 | [diff] [blame] | 11 | frappeuser=${FRAPPE_USER:-"frappe"} |
| 12 | frappebranch=${FRAPPE_BRANCH:-${GITHUB_BASE_REF:-${GITHUB_REF##*/}}} |
| 13 | |
| 14 | git clone "https://github.com/${frappeuser}/frappe" --branch "${frappebranch}" --depth 1 |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 15 | bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench |
| 16 | |
| 17 | mkdir ~/frappe-bench/sites/test_site |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 18 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 19 | if [ "$DB" == "mariadb" ];then |
| 20 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json |
| 21 | else |
| 22 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json |
| 23 | fi |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 24 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 25 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 26 | if [ "$DB" == "mariadb" ];then |
| 27 | mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" |
| 28 | mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" |
| 29 | |
| 30 | mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" |
| 31 | mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe" |
| 32 | mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" |
| 33 | |
| 34 | mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" |
| 35 | mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES" |
| 36 | fi |
| 37 | |
| 38 | if [ "$DB" == "postgres" ];then |
| 39 | echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres; |
| 40 | echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres; |
| 41 | fi |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 42 | |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 43 | |
| 44 | install_whktml() { |
| 45 | wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz |
| 46 | tar -xf /tmp/wkhtmltox.tar.xz -C /tmp |
| 47 | sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf |
| 48 | sudo chmod o+x /usr/local/bin/wkhtmltopdf |
| 49 | } |
| 50 | install_whktml & |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 51 | |
| 52 | cd ~/frappe-bench || exit |
| 53 | |
| 54 | sed -i 's/watch:/# watch:/g' Procfile |
| 55 | sed -i 's/schedule:/# schedule:/g' Procfile |
| 56 | sed -i 's/socketio:/# socketio:/g' Procfile |
| 57 | sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile |
| 58 | |
| 59 | bench get-app erpnext "${GITHUB_WORKSPACE}" |
Ankush Menat | 92c0dcc | 2021-10-20 14:43:39 +0530 | [diff] [blame] | 60 | |
| 61 | if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi |
| 62 | |
Ankush Menat | 203c2b2 | 2021-07-02 22:35:15 +0530 | [diff] [blame] | 63 | bench start &> bench_run_logs.txt & |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 64 | CI=Yes bench build --app frappe & |
Sagar Vora | 19bb8c1 | 2021-03-17 20:03:54 +0530 | [diff] [blame] | 65 | bench --site test_site reinstall --yes |