2021-03-12 08:39:52 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-03-15 05:47:19 +00:00
|
|
|
set -e
|
|
|
|
|
2021-03-12 08:39:52 +00:00
|
|
|
cd ~ || exit
|
|
|
|
|
2023-10-11 05:47:47 +00:00
|
|
|
sudo apt update
|
|
|
|
sudo apt remove mysql-server mysql-client
|
|
|
|
sudo apt install libcups2-dev redis-server mariadb-client-10.6
|
2021-03-12 08:39:52 +00:00
|
|
|
|
|
|
|
pip install frappe-bench
|
|
|
|
|
2023-03-16 10:50:21 +00:00
|
|
|
githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}}
|
2022-02-03 12:00:42 +00:00
|
|
|
frappeuser=${FRAPPE_USER:-"frappe"}
|
2023-03-16 10:50:21 +00:00
|
|
|
frappebranch=${FRAPPE_BRANCH:-$githubbranch}
|
2022-02-03 12:00:42 +00:00
|
|
|
|
|
|
|
git clone "https://github.com/${frappeuser}/frappe" --branch "${frappebranch}" --depth 1
|
2021-03-12 08:39:52 +00:00
|
|
|
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
|
|
|
|
|
|
|
|
mkdir ~/frappe-bench/sites/test_site
|
|
|
|
|
2022-01-02 18:03:10 +00:00
|
|
|
if [ "$DB" == "mariadb" ];then
|
|
|
|
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json
|
|
|
|
else
|
|
|
|
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json
|
|
|
|
fi
|
2021-03-12 08:39:52 +00:00
|
|
|
|
|
|
|
|
2022-01-02 18:03:10 +00:00
|
|
|
if [ "$DB" == "mariadb" ];then
|
2023-10-11 05:47:47 +00:00
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
2022-01-02 18:03:10 +00:00
|
|
|
|
2023-10-11 05:47:47 +00:00
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
|
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
2022-01-02 18:03:10 +00:00
|
|
|
|
2023-10-11 05:47:47 +00:00
|
|
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES"
|
2022-01-02 18:03:10 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DB" == "postgres" ];then
|
|
|
|
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres;
|
|
|
|
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres;
|
|
|
|
fi
|
2021-03-12 08:39:52 +00:00
|
|
|
|
2022-02-17 09:52:36 +00:00
|
|
|
|
|
|
|
install_whktml() {
|
2023-01-09 08:57:34 +00:00
|
|
|
if [ "$(lsb_release -rs)" = "22.04" ]; then
|
|
|
|
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
|
|
|
|
sudo apt install /tmp/wkhtmltox.deb
|
|
|
|
else
|
|
|
|
echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-17 09:52:36 +00:00
|
|
|
}
|
|
|
|
install_whktml &
|
2023-01-09 08:57:34 +00:00
|
|
|
wkpid=$!
|
|
|
|
|
2021-03-12 08:39:52 +00:00
|
|
|
|
|
|
|
cd ~/frappe-bench || exit
|
|
|
|
|
|
|
|
sed -i 's/watch:/# watch:/g' Procfile
|
|
|
|
sed -i 's/schedule:/# schedule:/g' Procfile
|
|
|
|
sed -i 's/socketio:/# socketio:/g' Procfile
|
|
|
|
sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
|
|
|
|
|
2023-03-16 10:50:21 +00:00
|
|
|
bench get-app payments --branch ${githubbranch%"-hotfix"}
|
2021-03-12 08:39:52 +00:00
|
|
|
bench get-app erpnext "${GITHUB_WORKSPACE}"
|
2021-10-20 09:13:39 +00:00
|
|
|
|
|
|
|
if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
|
|
|
|
|
2023-01-09 08:57:34 +00:00
|
|
|
wait $wkpid
|
|
|
|
|
2023-09-14 09:16:45 +00:00
|
|
|
bench start &>> ~/frappe-bench/bench_start.log &
|
2022-02-17 09:52:36 +00:00
|
|
|
CI=Yes bench build --app frappe &
|
2021-03-17 14:33:54 +00:00
|
|
|
bench --site test_site reinstall --yes
|