blob: 859146bbcde756f41004e215ceb91a2291a82466 [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 Menate5e00702021-08-30 12:07:11 +05307sudo apt-get 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
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"
36fi
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() {
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}
50install_whktml &
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053051
52cd ~/frappe-bench || exit
53
54sed -i 's/watch:/# watch:/g' Procfile
55sed -i 's/schedule:/# schedule:/g' Procfile
56sed -i 's/socketio:/# socketio:/g' Procfile
57sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
58
59bench get-app erpnext "${GITHUB_WORKSPACE}"
Ankush Menat92c0dcc2021-10-20 14:43:39 +053060
61if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
62
Ankush Menat203c2b22021-07-02 22:35:15 +053063bench start &> bench_run_logs.txt &
Ankush Menat229db142022-02-17 15:22:36 +053064CI=Yes bench build --app frappe &
Sagar Vora19bb8c12021-03-17 20:03:54 +053065bench --site test_site reinstall --yes