blob: 48337cee6406c0c02a3812a9a381bd523c7965a9 [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
mergify[bot]bd2dd7d2023-03-16 16:20:21 +053011githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}}
Ankush Menat6f2c9c62022-02-03 17:30:42 +053012frappeuser=${FRAPPE_USER:-"frappe"}
mergify[bot]bd2dd7d2023-03-16 16:20:21 +053013frappebranch=${FRAPPE_BRANCH:-$githubbranch}
Ankush Menat6f2c9c62022-02-03 17:30:42 +053014
15git clone "https://github.com/${frappeuser}/frappe" --branch "${frappebranch}" --depth 1
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053016bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
17
18mkdir ~/frappe-bench/sites/test_site
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053019
Conord2074b12022-01-02 12:03:10 -060020if [ "$DB" == "mariadb" ];then
21 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json
22else
23 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json
24fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053025
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053026
Conord2074b12022-01-02 12:03:10 -060027if [ "$DB" == "mariadb" ];then
Ankush Menatd23b5d82022-12-06 12:58:07 +053028 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'"
Conord2074b12022-01-02 12:03:10 -060030
Ankush Menatd23b5d82022-12-06 12:58:07 +053031 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'"
Conord2074b12022-01-02 12:03:10 -060034
Ankush Menatd23b5d82022-12-06 12:58:07 +053035 mysql --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES"
Conord2074b12022-01-02 12:03:10 -060036fi
37
38if [ "$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;
41fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053042
Ankush Menat229db142022-02-17 15:22:36 +053043
44install_whktml() {
Raffael Meyera4cb0312023-01-09 09:57:34 +010045 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 Menat229db142022-02-17 15:22:36 +053052}
53install_whktml &
Raffael Meyera4cb0312023-01-09 09:57:34 +010054wkpid=$!
55
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053056
57cd ~/frappe-bench || exit
58
59sed -i 's/watch:/# watch:/g' Procfile
60sed -i 's/schedule:/# schedule:/g' Procfile
61sed -i 's/socketio:/# socketio:/g' Procfile
62sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
63
mergify[bot]bd2dd7d2023-03-16 16:20:21 +053064bench get-app payments --branch ${githubbranch%"-hotfix"}
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053065bench get-app erpnext "${GITHUB_WORKSPACE}"
Ankush Menat92c0dcc2021-10-20 14:43:39 +053066
67if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
68
Raffael Meyera4cb0312023-01-09 09:57:34 +010069wait $wkpid
70
Ankush Menat203c2b22021-07-02 22:35:15 +053071bench start &> bench_run_logs.txt &
Ankush Menat229db142022-02-17 15:22:36 +053072CI=Yes bench build --app frappe &
Sagar Vora19bb8c12021-03-17 20:03:54 +053073bench --site test_site reinstall --yes