Skip to content

Commit

Permalink
ci: remove cypress, fix hrms install, conform (#221)
Browse files Browse the repository at this point in the history
* ci: remove cypress, fix hrms install, conform

* ci: fix mypy error
  • Loading branch information
HKuz authored and agritheory committed Apr 1, 2024
1 parent 9d99698 commit cbfe67f
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 149 deletions.
20 changes: 7 additions & 13 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ fi

cd ~ || exit

# sudo apt update -y && sudo apt install redis-server -y

pip install --upgrade pip
pip install frappe-bench

Expand All @@ -28,14 +26,8 @@ mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_si
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"

if [ "${GITHUB_EVENT_NAME}" = 'pull_request' ]; then
BRANCH_NAME="${GITHUB_BASE_REF}"
else
BRANCH_NAME="${GITHUB_REF_NAME}"
fi
echo "BRANCH_NAME: ${BRANCH_NAME}"

git clone https://github.com/frappe/frappe --branch "${BRANCH_NAME}"
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

mkdir ~/frappe-bench/sites/test_site
Expand All @@ -48,9 +40,9 @@ sed -i 's/schedule:/# schedule:/g' Procfile
sed -i 's/socketio:/# socketio:/g' Procfile
sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile

bench get-app hrms --branch "${BRANCH_NAME}" --resolve-deps --skip-assets --overwrite
bench get-app erpnext --branch "${BRANCH_NAME}" --resolve-deps --skip-assets --overwrite
bench get-app check_run "${GITHUB_WORKSPACE}" --skip-assets --resolve-deps
bench get-app erpnext https://github.com/frappe/erpnext --branch ${BRANCH_NAME} --resolve-deps --skip-assets
bench get-app hrms https://github.com/frappe/hrms --branch ${BRANCH_NAME} --skip-assets
bench get-app check_run "${GITHUB_WORKSPACE}" --skip-assets

printf '%s\n' 'frappe' 'erpnext' 'hrms' 'check_run' > ~/frappe-bench/sites/apps.txt
bench setup requirements --python
Expand All @@ -60,6 +52,8 @@ bench start &> bench_run_logs.txt &
CI=Yes &
bench --site test_site reinstall --yes --admin-password admin

bench setup requirements --dev

echo "BENCH VERSION NUMBERS:"
bench version
echo "SITE LIST-APPS:"
Expand Down
2 changes: 1 addition & 1 deletion .github/helper/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${{GITHUB_WORKSPACE}}"
exit 1
fi

sudo apt update && sudo apt install redis-server libcups2-dev
sudo apt update -y && sudo apt install redis-server libcups2-dev mariadb-client

# install wkhtmltopdf
wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
Expand Down
35 changes: 20 additions & 15 deletions .github/helper/site_config.json
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": "test@example.com",
"mail_server": "smtp.example.com",
"mail_login": "test@example.com",
"mail_password": "test",
"admin_password": "admin",
"root_login": "root",
"root_password": "travis",
"host_name": "http://test_site:8000",
"install_apps": ["erpnext", "check_run"],
"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": "test@example.com",
"mail_server": "smtp.example.com",
"mail_login": "test@example.com",
"mail_password": "test",
"admin_password": "admin",
"root_login": "root",
"root_password": "admin",
"host_name": "http://test_site:8000",
"install_apps": [
"erpnext",
"hrms",
"check_run"
],
"throttle_user_limit": 100,
"developer_mode": 1
}
10 changes: 9 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: pip install mypy

- name: Install mypy types
run: mypy ./check_run/. --install-types
run: mypy ./check_run/. --install-types --non-interactive

- name: Run mypy
uses: sasanquaneuf/mypy-github-action@releases/v1
Expand Down Expand Up @@ -142,6 +142,14 @@ jobs:
echo "D,${file}" >> base/mrd.txt
done
- name: Setup requirements and script
run: |
pip install rich
pip install json_source_map
git clone --depth 1 https://gist.github.com/3eea518743067f1b971114f1a2016f69 fsjd
- name: Diff table
run: python3 fsjd/frappe_schema_json_diff.py base/mrd.txt head/acmr.txt 1

py_json_merge:
runs-on: ubuntu-latest
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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 }}

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
name: Server

services:
mysql:
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@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: 'yarn' # Replaces `Get yarn cache directory path` and `yarn-cache` steps

- name: Add to Hosts
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts

- name: Cache pip
uses: actions/cache@v3
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: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ 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/check_run/check_run/tests/ --disable-warnings -s
95 changes: 0 additions & 95 deletions .github/workflows/ui_test.yaml

This file was deleted.

15 changes: 10 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: 'frappe.*'
files: 'check_run.*'
exclude: '.*json$|.*txt$|.*csv|.*md|.*svg'
- id: check-yaml
- id: no-commit-to-branch
Expand Down Expand Up @@ -38,14 +38,19 @@ repos:
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
frappe/public/dist/.*|
check_run/public/dist/.*|
.*node_modules.*|
.*boilerplate.*|
frappe/www/website_script.js|
frappe/templates/includes/.*|
frappe/public/js/lib/.*
check_run/www/website_script.js|
check_run/templates/includes/.*|
check_run/public/js/lib/.*
)$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
Expand Down
32 changes: 15 additions & 17 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@
import datetime
import json
import timeit
from itertools import groupby, zip_longest
from io import StringIO
from typing_extensions import Self

# from PyPDF2 import PdfFileWriter
from pypdf import PdfWriter
from itertools import groupby, zip_longest

import frappe
from atnacha import ACHBatch, ACHEntry, NACHAFile
from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry
from erpnext.accounts.utils import get_balance_on
from frappe.contacts.doctype.address.address import get_default_address
from frappe.desk.form.load import get_attachments
from frappe.model.document import Document
from frappe.utils.data import flt
from frappe.utils.data import nowdate, getdate, now, get_datetime
from frappe.utils.print_format import read_multi_pdf
from frappe.permissions import has_permission
from frappe.utils.file_manager import save_file, remove_all
from frappe.utils.password import get_decrypted_password
from frappe.contacts.doctype.address.address import get_default_address
from frappe.query_builder.custom import ConstantColumn
from frappe.query_builder.functions import Coalesce, Sum, NullIf
from frappe.desk.form.load import get_attachments
from frappe.query_builder.functions import Coalesce, NullIf, Sum
from frappe.utils.data import flt, get_datetime, getdate, now, nowdate
from frappe.utils.file_manager import remove_all, save_file
from frappe.utils.password import get_decrypted_password
from frappe.utils.print_format import read_multi_pdf

from erpnext.accounts.utils import get_balance_on
from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry
# from PyPDF2 import PdfFileWriter
from pypdf import PdfWriter
from typing_extensions import Self

from atnacha import ACHEntry, ACHBatch, NACHAFile
from check_run.check_run.doctype.check_run_settings.check_run_settings import (
CheckRunSettings,
create,
Expand Down Expand Up @@ -306,7 +304,7 @@ def create_payment_entries(self: Self, transactions: list[frappe._dict]) -> list
if frappe.db.get_value("Mode of Payment", _group[0].mode_of_payment, "type") == "Bank":
groups = list(zip_longest(*[iter(_group)] * split))
else:
groups = [_group]
groups = [_group] # type: ignore

if not groups:
continue
Expand Down

0 comments on commit cbfe67f

Please sign in to comment.