Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ cd ~ || exit

sudo apt-get update
sudo apt-get -y remove mysql-server mysql-client
sudo apt-get -y install redis-server libcups2-dev mariadb-client-10.6 -qq
sudo apt-get -y install redis-server libcups2-dev mariadb-client -qq
Comment thread
ravibharathi656 marked this conversation as resolved.

pip install frappe-bench

git clone https://github.com/frappe/frappe --branch develop --depth 1
git clone https://github.com/frappe/frappe --branch version-15 --depth 1
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench

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

bench get-app payments --branch develop
bench get-app erpnext --branch develop
bench get-app erpnext --branch version-15
bench get-app ecommerce_integrations "${GITHUB_WORKSPACE}"

bench start &
bench --site test_site reinstall --yes

bench get-app ecommerce_integrations "${GITHUB_WORKSPACE}"
bench --site test_site install-app ecommerce_integrations
bench setup requirements --dev
2 changes: 1 addition & 1 deletion .github/helper/site_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"root_login": "root",
"root_password": "root",
"host_name": "http://test_site:8000",
"install_apps": ["payments", "erpnext"],
"install_apps": ["payments", "erpnext", "ecommerce_integrations"],
"throttle_user_limit": 100
}
60 changes: 48 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,35 @@ name: CI
on:
push:
branches:
- develop
- main
- version-15
pull_request:
branches:
- develop
- main
- version-15
paths-ignore:
- "**.css"
- "**.js"
- "**.md"
- "**.html"
- "**.csv"
schedule:
# Run everyday at midnight UTC / 5:30 IST
- cron: "0 0 * * *"

env:
ECOMMERCE_BRANCH: ${{ github.base_ref || github.ref_name }}

concurrency:
group: develop-${{ github.event.number }}
group: ci-${{ github.event.number || github.ref_name }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
WITH_COVERAGE: ${{ github.event_name != 'pull_request' }}

strategy:
fail-fast: false
Expand All @@ -30,14 +45,14 @@ jobs:
MARIADB_ROOT_PASSWORD: 'root'
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v4

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

Expand All @@ -51,15 +66,16 @@ jobs:
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -74,7 +90,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -85,16 +101,36 @@ jobs:
- name: Install
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
BRANCH_TO_CLONE: ${{ env.ECOMMERCE_BRANCH }}


- name: Run Tests
run: cd ~/frappe-bench/ && bench --site test_site run-tests --app ecommerce_integrations --coverage
run: cd ~/frappe-bench/ && bench --site test_site run-tests --app ecommerce_integrations ${{ env.WITH_COVERAGE == 'true' && '--coverage' || '' }}
env:
TYPE: server

- name: Upload coverage data
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: coverage
path: /home/runner/frappe-bench/sites/coverage.xml

coverage:
name: Coverage Wrap Up
needs: tests
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Clone
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4

- name: Upload coverage data
uses: codecov/codecov-action@v2
Comment thread
ravibharathi656 marked this conversation as resolved.
with:
fail_ci_if_error: true
files: /home/runner/frappe-bench/sites/coverage.xml
verbose: true
28 changes: 14 additions & 14 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
name: Linters

on:
pull_request: { }
pull_request:
branches:
- main
- version-15

jobs:

linters:
name: linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.10
uses: actions/setup-python@v5
Comment thread
ravibharathi656 marked this conversation as resolved.
with:
python-version: 3.8
python-version: '3.10'
cache: pip

- name: Install and Run Pre-commit
uses: pre-commit/action@v2.0.3
uses: pre-commit/action@v3.0.0

- name: Download Semgrep rules
run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules

- uses: returntocorp/semgrep-action@v1
env:
SEMGREP_TIMEOUT: 120
with:
config: >-
r/python.lang.correctness
./frappe-semgrep-rules/rules
- name: Run Semgrep rules
run: |
pip install semgrep==1.90.0
semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v14
uses: actions/setup-node@v2
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup dependencies
run: |
npm install @semantic-release/git @semantic-release/exec --no-save
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: "Frappe PR Bot"
GIT_AUTHOR_EMAIL: "developers@frappe.io"
GIT_COMMITTER_NAME: "Frappe PR Bot"
Expand Down
39 changes: 18 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
exclude: 'node_modules|.git'
default_stages: [commit]
fail_fast: true
default_stages: [pre-commit]
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: "ecommerce_integrations.*"
exclude: ".*json$|.*txt$|.*csv|.*md|.*svg"
- id: end-of-file-fixer
files: "ecommerce_integrations.*"
exclude: ".*json$|.*txt$"
- id: check-yaml
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: debug-statements

- repo: https://github.com/adityahase/black
rev: 364d1ddcf58eb6bad2e0b757329f06f40ea83044
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
hooks:
- id: black
exclude: ".*setup.py$"
additional_dependencies: ['click==8.0.4']

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
exclude: ".*setup.py$"

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [flake8-isort]
exclude: ".*setup.py$"
- id: ruff
name: "Run ruff import sorter"
args: ["--select=I", "--fix"]
- id: ruff
name: "Run ruff linter"
- id: ruff-format
name: "Run ruff formatter"

ci:
autoupdate_schedule: weekly
Expand Down
2 changes: 1 addition & 1 deletion ecommerce_integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.20.1"
__version__ = "1.20.2"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import urllib

import dateutil

import frappe
from frappe import _

Expand Down Expand Up @@ -47,7 +48,7 @@ def call_sp_api_method(self, sp_api_method, **kwargs) -> dict:
errors = {}
max_retries = self.amz_setting.max_retry_limit

for x in range(max_retries):
for _x in range(max_retries):
try:
result = sp_api_method(**kwargs)
return result.get("payload")
Expand All @@ -62,7 +63,8 @@ def call_sp_api_method(self, sp_api_method, **kwargs) -> dict:
msg = f"<b>Error:</b> {error}<br/><b>Error Description:</b> {errors.get(error)}"
frappe.msgprint(msg, alert=True, indicator="red")
frappe.log_error(
message=f"{error}: {errors.get(error)}", title=f'Method "{sp_api_method.__name__}" failed',
message=f"{error}: {errors.get(error)}",
title=f'Method "{sp_api_method.__name__}" failed',
)

self.amz_setting.enable_sync = 0
Expand All @@ -76,11 +78,11 @@ def get_finances_instance(self) -> Finances:
return Finances(**self.instance_params)

def get_account(self, name) -> str:
account_name = frappe.db.get_value("Account", {"account_name": "Amazon {0}".format(name)})
account_name = frappe.db.get_value("Account", {"account_name": f"Amazon {name}"})

if not account_name:
new_account = frappe.new_doc("Account")
new_account.account_name = "Amazon {0}".format(name)
new_account.account_name = f"Amazon {name}"
new_account.company = self.amz_setting.company
new_account.parent_account = self.amz_setting.market_place_account_group
new_account.insert(ignore_permissions=True)
Expand Down Expand Up @@ -271,9 +273,7 @@ def get_item_code(self, order_item) -> str:

def get_order_items(self, order_id) -> list:
orders = self.get_orders_instance()
order_items_payload = self.call_sp_api_method(
sp_api_method=orders.get_order_items, order_id=order_id
)
order_items_payload = self.call_sp_api_method(sp_api_method=orders.get_order_items, order_id=order_id)

final_order_items = []
warehouse = self.amz_setting.warehouse
Expand Down Expand Up @@ -301,7 +301,9 @@ def get_order_items(self, order_id) -> list:
break

order_items_payload = self.call_sp_api_method(
sp_api_method=orders.get_order_items, order_id=order_id, next_token=next_token,
sp_api_method=orders.get_order_items,
order_id=order_id,
next_token=next_token,
)

return final_order_items
Expand Down Expand Up @@ -333,7 +335,8 @@ def create_customer(order) -> str:
new_contact = frappe.new_doc("Contact")
new_contact.first_name = order_customer_name
new_contact.append(
"links", {"link_doctype": "Customer", "link_name": existing_customer_name},
"links",
{"link_doctype": "Customer", "link_name": existing_customer_name},
)
new_contact.insert()

Expand Down Expand Up @@ -469,7 +472,9 @@ def get_orders(self, created_after) -> list:
break

orders_payload = self.call_sp_api_method(
sp_api_method=orders.get_orders, created_after=created_after, next_token=next_token,
sp_api_method=orders.get_orders,
created_after=created_after,
next_token=next_token,
)

return sales_orders
Expand Down
Loading
Loading