blob: 0c71b41a7cd594684d64bdc7770148308ce11fec [file] [log] [blame]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05301#!/bin/bash
2
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +05303set -e
4
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05305cd ~ || exit
6
Ankush Menatc7efa3b2022-06-02 12:27:11 +05307sudo apt update && sudo apt install redis-server libcups2-dev
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05308
9pip install frappe-bench
10
Ankush Menat6f2c9c62022-02-03 17:30:42 +053011frappeuser=${FRAPPE_USER:-"frappe"}
12frappebranch=${FRAPPE_BRANCH:-${GITHUB_BASE_REF:-${GITHUB_REF##*/}}}
13
14git clone "https://github.com/${frappeuser}/frappe" --branch "${frappebranch}" --depth 1
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053015bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
16
17mkdir ~/frappe-bench/sites/test_site
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053018
Conord2074b12022-01-02 12:03:10 -060019if [ "$DB" == "mariadb" ];then
20 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json
21else
22 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json
23fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053024
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053025
Conord2074b12022-01-02 12:03:10 -060026if [ "$DB" == "mariadb" ];then
Ankush Menatd23b5d82022-12-06 12:58:07 +053027 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
28 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
Conord2074b12022-01-02 12:03:10 -060029
Ankush Menatd23b5d82022-12-06 12:58:07 +053030 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
31 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
32 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
Conord2074b12022-01-02 12:03:10 -060033
Ankush Menatd23b5d82022-12-06 12:58:07 +053034 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES"
Conord2074b12022-01-02 12:03:10 -060035fi
36
37if [ "$DB" == "postgres" ];then
38 echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres;
39 echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres;
40fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053041
Ankush Menat229db142022-02-17 15:22:36 +053042
43install_whktml() {
Raffael Meyera4cb0312023-01-09 09:57:34 +010044 if [ "$(lsb_release -rs)" = "22.04" ]; then
45 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
46 sudo apt install /tmp/wkhtmltox.deb
47 else
48 echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)"
49 exit 1
50 fi
Ankush Menat229db142022-02-17 15:22:36 +053051}
52install_whktml &
Raffael Meyera4cb0312023-01-09 09:57:34 +010053wkpid=$!
54
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053055
56cd ~/frappe-bench || exit
57
58sed -i 's/watch:/# watch:/g' Procfile
59sed -i 's/schedule:/# schedule:/g' Procfile
60sed -i 's/socketio:/# socketio:/g' Procfile
61sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
62
phot0n76493e92022-07-25 10:56:04 +053063bench get-app payments
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053064bench get-app erpnext "${GITHUB_WORKSPACE}"
Ankush Menat92c0dcc2021-10-20 14:43:39 +053065
66if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
67
Raffael Meyera4cb0312023-01-09 09:57:34 +010068wait $wkpid
69
Ankush Menat203c2b22021-07-02 22:35:15 +053070bench start &> bench_run_logs.txt &
Ankush Menat229db142022-02-17 15:22:36 +053071CI=Yes bench build --app frappe &
Sagar Vora19bb8c12021-03-17 20:03:54 +053072bench --site test_site reinstall --yes