blob: f0f83b061b9ffae6b32af76e84e75a3cf210029c [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
Ankush Menat3ae9fa92022-04-27 14:33:26 +05305# Check for merge conflicts before proceeding
6python -m compileall -f "${GITHUB_WORKSPACE}"
7if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
8 then echo "Found merge conflicts"
9 exit 1
10fi
11
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053012cd ~ || exit
13
Ankush Menatc7efa3b2022-06-02 12:27:11 +053014sudo apt update && sudo apt install redis-server libcups2-dev
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053015
16pip install frappe-bench
17
Ankush Menat6f2c9c62022-02-03 17:30:42 +053018frappeuser=${FRAPPE_USER:-"frappe"}
19frappebranch=${FRAPPE_BRANCH:-${GITHUB_BASE_REF:-${GITHUB_REF##*/}}}
20
21git clone "https://github.com/${frappeuser}/frappe" --branch "${frappebranch}" --depth 1
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053022bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
23
24mkdir ~/frappe-bench/sites/test_site
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053025
Conord2074b12022-01-02 12:03:10 -060026if [ "$DB" == "mariadb" ];then
27 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json
28else
29 cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json
30fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053031
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053032
Conord2074b12022-01-02 12:03:10 -060033if [ "$DB" == "mariadb" ];then
34 mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
35 mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
36
37 mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
38 mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe"
39 mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
40
41 mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
42 mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES"
43fi
44
45if [ "$DB" == "postgres" ];then
46 echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres;
47 echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres;
48fi
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053049
Ankush Menat229db142022-02-17 15:22:36 +053050
51install_whktml() {
52 wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
53 tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
54 sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
55 sudo chmod o+x /usr/local/bin/wkhtmltopdf
56}
57install_whktml &
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053058
59cd ~/frappe-bench || exit
60
61sed -i 's/watch:/# watch:/g' Procfile
62sed -i 's/schedule:/# schedule:/g' Procfile
63sed -i 's/socketio:/# socketio:/g' Procfile
64sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
65
66bench get-app erpnext "${GITHUB_WORKSPACE}"
Ankush Menat92c0dcc2021-10-20 14:43:39 +053067
68if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
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