Skip to content

Commit 9a00857

Browse files
committed
Merge branch 'staging' into production
2 parents 93b1868 + 71eea07 commit 9a00857

29 files changed

Lines changed: 797 additions & 48 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"db_host": "127.0.0.1",
3+
"db_port": 3306,
4+
"db_name": "test_frappe_consumer",
5+
"db_password": "test_frappe",
6+
"allow_tests": true,
7+
"db_type": "mariadb",
8+
"auto_email_id": "test@example.com",
9+
"mail_server": "smtp.example.com",
10+
"mail_login": "test@example.com",
11+
"mail_password": "test",
12+
"admin_password": "admin",
13+
"root_login": "root",
14+
"root_password": "travis",
15+
"host_name": "http://test_site:8000",
16+
"server_script_enabled": true
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"db_host": "127.0.0.1",
3+
"db_port": 5432,
4+
"db_name": "test_frappe_consumer",
5+
"db_password": "test_frappe",
6+
"db_type": "postgres",
7+
"allow_tests": true,
8+
"auto_email_id": "test@example.com",
9+
"mail_server": "smtp.example.com",
10+
"mail_login": "test@example.com",
11+
"mail_password": "test",
12+
"admin_password": "admin",
13+
"root_login": "postgres",
14+
"root_password": "travis",
15+
"host_name": "http://test_site:8000",
16+
"server_script_enabled": true
17+
}

.github/helper/install.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd ~ || exit
6+
7+
pip install frappe-bench
8+
9+
bench init frappe-bench --skip-assets --python "$(which python)" --frappe-path "${GITHUB_WORKSPACE}"
10+
11+
mkdir ~/frappe-bench/sites/test_site
12+
cp "${GITHUB_WORKSPACE}/.github/helper/consumer_db/$DB.json" ~/frappe-bench/sites/test_site/site_config.json
13+
14+
if [ "$TYPE" == "server" ]; then
15+
mkdir ~/frappe-bench/sites/test_site_producer;
16+
cp "${GITHUB_WORKSPACE}/.github/helper/producer_db/$DB.json" ~/frappe-bench/sites/test_site_producer/site_config.json;
17+
fi
18+
19+
if [ "$DB" == "mariadb" ];then
20+
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'";
21+
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'";
22+
23+
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe_consumer";
24+
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe_consumer'@'localhost' IDENTIFIED BY 'test_frappe_consumer'";
25+
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe_consumer\`.* TO 'test_frappe_consumer'@'localhost'";
26+
27+
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe_producer";
28+
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe_producer'@'localhost' IDENTIFIED BY 'test_frappe_producer'";
29+
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe_producer\`.* TO 'test_frappe_producer'@'localhost'";
30+
31+
mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'";
32+
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES";
33+
fi
34+
35+
if [ "$DB" == "postgres" ];then
36+
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_consumer" -U postgres;
37+
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_consumer WITH PASSWORD 'test_frappe'" -U postgres;
38+
39+
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_producer" -U postgres;
40+
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_producer WITH PASSWORD 'test_frappe'" -U postgres;
41+
fi
42+
43+
cd ./frappe-bench || exit
44+
45+
sed -i 's/^watch:/# watch:/g' Procfile
46+
sed -i 's/^schedule:/# schedule:/g' Procfile
47+
48+
if [ "$TYPE" == "server" ]; then sed -i 's/^socketio:/# socketio:/g' Procfile; fi
49+
if [ "$TYPE" == "server" ]; then sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile; fi
50+
51+
if [ "$TYPE" == "ui" ]; then bench setup requirements --node; fi
52+
53+
# install node-sass which is required for website theme test
54+
cd ./apps/frappe || exit
55+
yarn add node-sass@4.13.1
56+
cd ../..
57+
58+
bench start &
59+
bench --site test_site reinstall --yes
60+
if [ "$TYPE" == "server" ]; then bench --site test_site_producer reinstall --yes; fi
61+
bench build --app frappe
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
6+
# if [[ $? != 2 ]];then
7+
# exit;
8+
# fi
9+
10+
# install wkhtmltopdf
11+
wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
12+
tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
13+
sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
14+
sudo chmod o+x /usr/local/bin/wkhtmltopdf
15+
16+
# install cups
17+
sudo apt-get install libcups2-dev
18+
19+
# install redis
20+
sudo apt-get install redis-server
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"db_host": "127.0.0.1",
3+
"db_port": 3306,
4+
"db_name": "test_frappe_producer",
5+
"db_password": "test_frappe",
6+
"allow_tests": true,
7+
"db_type": "mariadb",
8+
"auto_email_id": "test@example.com",
9+
"mail_server": "smtp.example.com",
10+
"mail_login": "test@example.com",
11+
"mail_password": "test",
12+
"admin_password": "admin",
13+
"root_login": "root",
14+
"root_password": "travis",
15+
"host_name": "http://test_site_producer:8000"
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"db_host": "127.0.0.1",
3+
"db_port": 5432,
4+
"db_name": "test_frappe_producer",
5+
"db_password": "test_frappe",
6+
"db_type": "postgres",
7+
"allow_tests": true,
8+
"auto_email_id": "test@example.com",
9+
"mail_server": "smtp.example.com",
10+
"mail_login": "test@example.com",
11+
"mail_password": "test",
12+
"admin_password": "admin",
13+
"root_login": "postgres",
14+
"root_password": "travis",
15+
"host_name": "http://test_site_producer:8000"
16+
}

.github/helper/roulette.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# if the script ends with exit code 0, then no tests are run further, else all tests are run
2+
import os
3+
import re
4+
import shlex
5+
import subprocess
6+
import sys
7+
8+
9+
def get_output(command, shell=True):
10+
print(command)
11+
command = shlex.split(command)
12+
return subprocess.check_output(command, shell=shell, encoding="utf8").strip()
13+
14+
def is_py(file):
15+
return file.endswith("py")
16+
17+
def is_js(file):
18+
return file.endswith("js")
19+
20+
def is_docs(file):
21+
regex = re.compile(r'\.(md|png|jpg|jpeg)$|^.github|LICENSE')
22+
return bool(regex.search(file))
23+
24+
25+
if __name__ == "__main__":
26+
build_type = os.environ.get("TYPE")
27+
before = os.environ.get("BEFORE")
28+
after = os.environ.get("AFTER")
29+
commit_range = before + '...' + after
30+
print("Build Type: {}".format(build_type))
31+
print("Commit Range: {}".format(commit_range))
32+
33+
try:
34+
files_changed = get_output("git diff --name-only {}".format(commit_range), shell=False)
35+
except Exception:
36+
sys.exit(2)
37+
38+
if "fatal" not in files_changed:
39+
files_list = files_changed.split()
40+
only_docs_changed = len(list(filter(is_docs, files_list))) == len(files_list)
41+
only_js_changed = len(list(filter(is_js, files_list))) == len(files_list)
42+
only_py_changed = len(list(filter(is_py, files_list))) == len(files_list)
43+
44+
if only_docs_changed:
45+
print("Only docs were updated, stopping build process.")
46+
sys.exit(0)
47+
48+
if only_js_changed and build_type == "server":
49+
print("Only JavaScript code was updated; Stopping Python build process.")
50+
sys.exit(0)
51+
52+
if only_py_changed and build_type == "ui":
53+
print("Only Python code was updated, stopping Cypress build process.")
54+
sys.exit(0)
55+
56+
sys.exit(2)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Patch
2+
3+
on: [pull_request, workflow_dispatch]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-18.04
8+
9+
name: Patch Test
10+
11+
services:
12+
mysql:
13+
image: mariadb:10.3
14+
env:
15+
MYSQL_ALLOW_EMPTY_PASSWORD: YES
16+
ports:
17+
- 3306:3306
18+
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
19+
20+
steps:
21+
- name: Clone
22+
uses: actions/checkout@v2
23+
24+
- name: Setup Python
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.7
28+
29+
- name: Add to Hosts
30+
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
31+
32+
- name: Cache pip
33+
uses: actions/cache@v2
34+
with:
35+
path: ~/.cache/pip
36+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
37+
restore-keys: |
38+
${{ runner.os }}-pip-
39+
${{ runner.os }}-
40+
41+
- name: Cache node modules
42+
uses: actions/cache@v2
43+
env:
44+
cache-name: cache-node-modules
45+
with:
46+
path: ~/.npm
47+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-build-${{ env.cache-name }}-
50+
${{ runner.os }}-build-
51+
${{ runner.os }}-
52+
53+
- name: Get yarn cache directory path
54+
id: yarn-cache-dir-path
55+
run: echo "::set-output name=dir::$(yarn cache dir)"
56+
57+
- uses: actions/cache@v2
58+
id: yarn-cache
59+
with:
60+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
61+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-yarn-
64+
65+
- name: Install Dependencies
66+
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
67+
env:
68+
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
69+
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
70+
TYPE: server
71+
72+
73+
- name: Install
74+
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
75+
env:
76+
DB: mariadb
77+
TYPE: server
78+
79+
- name: Run Patch Tests
80+
run: |
81+
cd ~/frappe-bench/
82+
wget https://frappeframework.com/files/v10-frappe.sql.gz
83+
bench --site test_site --force restore ~/frappe-bench/v10-frappe.sql.gz
84+
bench --site test_site migrate
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Server
2+
3+
on: [pull_request, workflow_dispatch]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-18.04
8+
9+
strategy:
10+
fail-fast: false
11+
12+
name: Python Unit Tests (MariaDB)
13+
14+
services:
15+
mysql:
16+
image: mariadb:10.3
17+
env:
18+
MYSQL_ALLOW_EMPTY_PASSWORD: YES
19+
ports:
20+
- 3306:3306
21+
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
22+
23+
steps:
24+
- name: Clone
25+
uses: actions/checkout@v2
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.7
31+
32+
- uses: actions/setup-node@v2
33+
with:
34+
node-version: 14
35+
check-latest: true
36+
37+
- name: Add to Hosts
38+
run: |
39+
echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
40+
echo "127.0.0.1 test_site_producer" | sudo tee -a /etc/hosts
41+
42+
- name: Cache pip
43+
uses: actions/cache@v2
44+
with:
45+
path: ~/.cache/pip
46+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
47+
restore-keys: |
48+
${{ runner.os }}-pip-
49+
${{ runner.os }}-
50+
51+
- name: Cache node modules
52+
uses: actions/cache@v2
53+
env:
54+
cache-name: cache-node-modules
55+
with:
56+
path: ~/.npm
57+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
58+
restore-keys: |
59+
${{ runner.os }}-build-${{ env.cache-name }}-
60+
${{ runner.os }}-build-
61+
${{ runner.os }}-
62+
63+
- name: Get yarn cache directory path
64+
id: yarn-cache-dir-path
65+
run: echo "::set-output name=dir::$(yarn cache dir)"
66+
67+
- uses: actions/cache@v2
68+
id: yarn-cache
69+
with:
70+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
71+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
72+
restore-keys: |
73+
${{ runner.os }}-yarn-
74+
75+
- name: Install Dependencies
76+
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
77+
env:
78+
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
79+
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
80+
TYPE: server
81+
82+
- name: Install
83+
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
84+
env:
85+
DB: mariadb
86+
TYPE: server
87+
88+
- name: Run Tests
89+
run: cd ~/frappe-bench/ && bench --site test_site run-tests

0 commit comments

Comments
 (0)