-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test suite and CI workflow to version-14 (#34)
* ci: update for test suite * test: add common function test suite * refactor: adjust authorize reference ID for max length constraints
- Loading branch information
Showing
12 changed files
with
1,554 additions
and
1,173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,64 @@ | ||
#!/bin/bash | ||
|
||
export PIP_ROOT_USER_ACTION=ignore | ||
|
||
set -e | ||
|
||
# Check for merge conflicts before proceeding | ||
python -m compileall -f "${GITHUB_WORKSPACE}" | ||
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}" | ||
then echo "Found merge conflicts" | ||
exit 1 | ||
fi | ||
|
||
cd ~ || exit | ||
|
||
pip install --upgrade pip | ||
pip install frappe-bench | ||
git clone https://github.com/frappe/frappe --branch version-14 --depth 1 | ||
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench | ||
|
||
mkdir ~/frappe-bench/sites/test_site | ||
cp -r "${{GITHUB_WORKSPACE}}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site | ||
|
||
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" | ||
|
||
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE OR REPLACE DATABASE test_site" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE OR REPLACE USER 'test_site'@'localhost' IDENTIFIED BY 'test_site'" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_site\`.* TO 'test_site'@'localhost'" | ||
|
||
mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'" # match site_cofig | ||
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES" | ||
|
||
cd ./frappe-bench || exit | ||
echo BRANCH_NAME: "${BRANCH_NAME}" | ||
git clone https://github.com/frappe/frappe --branch ${BRANCH_NAME} | ||
bench init frappe-bench --frappe-path ~/frappe --python "$(which python)" --skip-assets --ignore-exist | ||
|
||
sed -i 's/^watch:/# watch:/g' Procfile | ||
sed -i 's/^schedule:/# schedule:/g' Procfile | ||
mkdir ~/frappe-bench/sites/test_site | ||
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site/ | ||
|
||
sed -i 's/^socketio:/# socketio:/g' Procfile; | ||
sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile; | ||
cd ~/frappe-bench || exit | ||
|
||
bench setup requirements --node | ||
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 | ||
|
||
cd ./apps/frappe || exit | ||
yarn add [email protected] | ||
cd ../.. | ||
bench get-app erpnext https://github.com/frappe/erpnext --branch ${BRANCH_NAME} --resolve-deps --skip-assets | ||
bench get-app payments https://github.com/frappe/payments --branch ${BRANCH_NAME} --skip-assets | ||
bench get-app electronic_payments "${GITHUB_WORKSPACE}" --skip-assets | ||
|
||
bench get-app https://github.com/frappe/payments | ||
bench get-app https://github.com/frappe/erpnext --branch version-14 | ||
bench get-app https://github.com/frappe/hrms | ||
bench setup requirements --dev | ||
printf '%s\n' 'frappe' 'erpnext' 'payments' 'electronic_payments' > ~/frappe-bench/sites/apps.txt | ||
bench setup requirements --python | ||
bench use test_site | ||
|
||
bench start &> bench_run_logs.txt & | ||
CI=Yes bench build --app frappe & | ||
bench --site test_site reinstall --yes | ||
CI=Yes & | ||
bench --site test_site reinstall --yes --admin-password admin | ||
|
||
bench get-app check_run "${{GITHUB_WORKSPACE}}" | ||
bench --site test_site install-app check_run | ||
bench setup requirements --dev | ||
|
||
echo "BENCH VERSION NUMBERS:" | ||
bench version | ||
echo "SITE LIST-APPS:" | ||
bench list-apps | ||
|
||
bench start &> bench_run_logs.txt & | ||
CI=Yes & | ||
bench execute 'electronic_payments.tests.setup.before_test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
{ | ||
"db_host": "127.0.0.1", | ||
"db_port": 3306, | ||
"db_name": "test_frappe", | ||
"db_password": "test_frappe", | ||
"auto_email_id": "[email protected]", | ||
"mail_server": "smtp.example.com", | ||
"mail_login": "[email protected]", | ||
"mail_password": "test", | ||
"admin_password": "admin", | ||
"root_login": "root", | ||
"root_password": "travis", | ||
"host_name": "http://test_site:8000", | ||
"install_apps": ["erpnext", "electronic_payments"], | ||
"throttle_user_limit": 100, | ||
"developer_mode": 1 | ||
"allow_tests": true, | ||
"db_host": "127.0.0.1", | ||
"db_port": 3306, | ||
"db_name": "test_site", | ||
"db_password": "admin", | ||
"auto_email_id": "[email protected]", | ||
"mail_server": "smtp.example.com", | ||
"mail_login": "[email protected]", | ||
"mail_password": "test", | ||
"admin_password": "admin", | ||
"root_login": "root", | ||
"root_password": "admin", | ||
"host_name": "http://test_site:8000", | ||
"install_apps": [ | ||
"erpnext", | ||
"payments", | ||
"electronic_payments" | ||
], | ||
"throttle_user_limit": 100, | ||
"developer_mode": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Pytest CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- version-14 | ||
- version-15 | ||
pull_request: | ||
branches: | ||
- version-14 | ||
- version-15 | ||
env: | ||
BRANCH_NAME: ${{ github.base_ref || github.ref_name }} | ||
|
||
# concurrency: | ||
# group: develop-autoreader-${{ github.event.number }} | ||
# cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
fail-fast: false | ||
name: Server | ||
|
||
services: | ||
mariadb: | ||
image: mariadb:10.6 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: YES | ||
MYSQL_ROOT_PASSWORD: 'admin' | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | ||
|
||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
check-latest: true | ||
cache: 'yarn' | ||
|
||
- name: Add to Hosts | ||
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
${{ runner.os }}- | ||
- name: Install JS Dependencies | ||
run: yarn --prefer-offline | ||
|
||
- name: Install App Dependencies | ||
run: bash ${{ github.workspace }}/.github/helper/install_dependencies.sh | ||
|
||
- name: Install Bench Site and Apps | ||
env: | ||
MYSQL_HOST: 'localhost' | ||
MYSQL_PWD: 'admin' | ||
BRANCH_NAME: ${{ env.BRANCH_NAME}} | ||
run: | | ||
bash ${{ github.workspace }}/.github/helper/install.sh | ||
- name: Run Tests | ||
working-directory: /home/runner/frappe-bench | ||
run: | | ||
source env/bin/activate | ||
pytest ./apps/electronic_payments/electronic_payments/tests/ --disable-warnings -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.