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 | c7efa3b | 2022-06-02 12:27:11 +0530 | [diff] [blame] | 7 | sudo apt update && sudo apt 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 | |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 11 | githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}} |
Ankush Menat | 6f2c9c6 | 2022-02-03 17:30:42 +0530 | [diff] [blame] | 12 | frappeuser=${FRAPPE_USER:-"frappe"} |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 13 | frappebranch=${FRAPPE_BRANCH:-$githubbranch} |
Ankush Menat | 6f2c9c6 | 2022-02-03 17:30:42 +0530 | [diff] [blame] | 14 | |
| 15 | 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] | 16 | bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench |
| 17 | |
| 18 | mkdir ~/frappe-bench/sites/test_site |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 19 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 20 | if [ "$DB" == "mariadb" ];then |
| 21 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json |
| 22 | else |
| 23 | cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json |
| 24 | fi |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 25 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 26 | |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 27 | if [ "$DB" == "mariadb" ];then |
Ankush Menat | d23b5d8 | 2022-12-06 12:58:07 +0530 | [diff] [blame] | 28 | mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" |
| 29 | mysql --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] | 30 | |
Ankush Menat | d23b5d8 | 2022-12-06 12:58:07 +0530 | [diff] [blame] | 31 | mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" |
| 32 | mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe" |
| 33 | mysql --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] | 34 | |
Ankush Menat | d23b5d8 | 2022-12-06 12:58:07 +0530 | [diff] [blame] | 35 | mysql --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES" |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 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() { |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 45 | if [ "$(lsb_release -rs)" = "22.04" ]; then |
| 46 | 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 |
| 47 | sudo apt install /tmp/wkhtmltox.deb |
| 48 | else |
| 49 | echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)" |
| 50 | exit 1 |
| 51 | fi |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 52 | } |
| 53 | install_whktml & |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 54 | wkpid=$! |
| 55 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 56 | |
| 57 | cd ~/frappe-bench || exit |
| 58 | |
| 59 | sed -i 's/watch:/# watch:/g' Procfile |
| 60 | sed -i 's/schedule:/# schedule:/g' Procfile |
| 61 | sed -i 's/socketio:/# socketio:/g' Procfile |
| 62 | sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile |
| 63 | |
mergify[bot] | bd2dd7d | 2023-03-16 16:20:21 +0530 | [diff] [blame] | 64 | bench get-app payments --branch ${githubbranch%"-hotfix"} |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 65 | bench get-app erpnext "${GITHUB_WORKSPACE}" |
Ankush Menat | 92c0dcc | 2021-10-20 14:43:39 +0530 | [diff] [blame] | 66 | |
| 67 | if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi |
| 68 | |
Raffael Meyer | a4cb031 | 2023-01-09 09:57:34 +0100 | [diff] [blame] | 69 | wait $wkpid |
| 70 | |
Ankush Menat | 203c2b2 | 2021-07-02 22:35:15 +0530 | [diff] [blame] | 71 | bench start &> bench_run_logs.txt & |
Ankush Menat | 229db14 | 2022-02-17 15:22:36 +0530 | [diff] [blame] | 72 | CI=Yes bench build --app frappe & |
Sagar Vora | 19bb8c1 | 2021-03-17 20:03:54 +0530 | [diff] [blame] | 73 | bench --site test_site reinstall --yes |