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 | |
Akhil Narang | 4a6108e | 2023-10-11 11:17:47 +0530 | [diff] [blame] | 7 | sudo apt update |
| 8 | sudo apt remove mysql-server mysql-client |
| 9 | sudo apt install libcups2-dev redis-server mariadb-client-10.6 |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 10 | |
| 11 | pip install frappe-bench |
| 12 | |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 13 | githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}} |
Ankush Menat | 6f2c9c6 | 2022-02-03 17:30:42 +0530 | [diff] [blame] | 14 | frappeuser=${FRAPPE_USER:-"frappe"} |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 15 | frappebranch=${FRAPPE_BRANCH:-$githubbranch} |
Ankush Menat | 6f2c9c6 | 2022-02-03 17:30:42 +0530 | [diff] [blame] | 16 | |
| 17 | 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] | 18 | bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench |
| 19 | |
| 20 | mkdir ~/frappe-bench/sites/test_site |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 21 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 22 | if [ "$DB" == "mariadb" ];then |
| 23 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json |
| 24 | else |
| 25 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json |
| 26 | fi |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 27 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 28 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 29 | if [ "$DB" == "mariadb" ];then |
Akhil Narang | 4a6108e | 2023-10-11 11:17:47 +0530 | [diff] [blame] | 30 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" |
| 31 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 32 | |
Akhil Narang | 4a6108e | 2023-10-11 11:17:47 +0530 | [diff] [blame] | 33 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" |
| 34 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe" |
| 35 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 36 | |
Akhil Narang | 4a6108e | 2023-10-11 11:17:47 +0530 | [diff] [blame] | 37 | mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES" |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 38 | fi |
| 39 | |
| 40 | if [ "$DB" == "postgres" ];then |
| 41 | echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres; |
| 42 | echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres; |
| 43 | fi |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 44 | |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 45 | |
| 46 | install_whktml() { |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 47 | if [ "$(lsb_release -rs)" = "22.04" ]; then |
| 48 | wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb |
| 49 | sudo apt install /tmp/wkhtmltox.deb |
| 50 | else |
| 51 | echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)" |
| 52 | exit 1 |
| 53 | fi |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 54 | } |
| 55 | install_whktml & |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 56 | wkpid=$! |
| 57 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 58 | |
| 59 | cd ~/frappe-bench || exit |
| 60 | |
| 61 | sed -i 's/watch:/# watch:/g' Procfile |
| 62 | sed -i 's/schedule:/# schedule:/g' Procfile |
| 63 | sed -i 's/socketio:/# socketio:/g' Procfile |
| 64 | sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile |
| 65 | |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 66 | bench get-app payments --branch ${githubbranch%"-hotfix"} |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 67 | bench get-app erpnext "${GITHUB_WORKSPACE}" |
Ankush Menat | 92c0dcc | 2021-10-20 14:43:39 +0530 | [diff] [blame] | 68 | |
| 69 | if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi |
| 70 | |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 71 | wait $wkpid |
| 72 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 73 | bench start &>> ~/frappe-bench/bench_start.log & |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 74 | CI=Yes bench build --app frappe & |
Sagar Vora | 19bb8c1 | 2021-03-17 20:03:54 +0530 | [diff] [blame] | 75 | bench --site test_site reinstall --yes |