Skip to content

Commit

Permalink
ci: check for stale doctypes in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Sep 29, 2021
1 parent b68ac24 commit 5ebed6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ jobs:
wget https://erpnext.com/files/v10-erpnext.sql.gz
bench --site test_site --force restore ~/frappe-bench/v10-erpnext.sql.gz
bench --site test_site migrate
bench --site test_site execute erpnext.tests.utils.test_stale_doctypes
21 changes: 21 additions & 0 deletions erpnext/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import frappe
from frappe.core.doctype.report.report import get_report_module_dotted_path
from frappe.model.base_document import get_controller

ReportFilters = Dict[str, Any]
ReportName = NewType("ReportName", str)
Expand Down Expand Up @@ -119,3 +120,23 @@ def execute_script_report(
report_execute_fn(filter_with_optional_param)

return report_data


def test_stale_doctypes():
"""Check that all doctypes in DB actually exist after patch test"""

erpnext_modules = frappe.get_all("Module Def", {"app_name": "erpnext"}, pluck="name")
doctypes = frappe.get_all("DocType", {"istable": 0, "module": ("in", erpnext_modules)}, pluck="name")

stale_doctypes = []

for doctype in doctypes:
try:
get_controller(doctype)
except ImportError:
stale_doctypes.append(doctype)


if stale_doctypes:
frappe.throw(frappe._("Following doctypes exist in DB without controller.\n {}")
.format('\n'.join(stale_doctypes)))

0 comments on commit 5ebed6f

Please sign in to comment.