I donāt update frequently, but I understand your situation, and the challenges of frequent merging. Probably some of the Frappe maintainers could offer Tips & Tricks in this area, since theyāre doing this at a large scale every week.
One thing I try to do is wrap my customizations with comments.
# ---- BPO: Start some Modification
...
print(f"Good morning, '{foo}'")
...
# ---- BPO: End Modification
This helps me while doing visual merges, so I donāt accidentally break-apart my code blocks.
If Iām confident, I will run a run a git pull. And hope that mostly Iāll see fast-forwards, with minimal manual merges.
Sometimes Iāll do a git difftool ahead of time against the upstream branch. To preview whatās going to happen. And perhaps manually merge code changes, before I run git pull.
Definitely appears to be both art and science. I too would love to learn more from experts on how this is being smoothly accomplished.
I have a ton of customizations in my ERPNext environments. But I deliberately avoid updating them from upstream, except during scheduled maintenance windows.
I am always grateful when you step in with your depth of experience.
Iām starting my first installation, so it makes sense to me try to be compatible with V13 from the get go.
The main point of my question was whether I had missed documentation of some critical technique, but it seems you have the same issues and handle them the same way.
I wish that the ERPNext team would make allowances for end-user developer customizations. I mean how hard would it be if every file had an import command for customizations. Eg;
erpdev@loso:~/frappe-bench-DELS$ ll apps/erpnext/erpnext/accounts/doctype/sales_invoice
total 484
drwxr-xr-x 5 erpdev erpdev 4096 Mar 4 18:31 ./
drwxr-xr-x 149 erpdev erpdev 12288 Mar 2 00:00 ../
-rw-r--r-- 1 erpdev erpdev 40 Mar 1 23:58 __init__.py
drwxr-xr-x 2 erpdev erpdev 4096 Mar 4 18:32 __pycache__/
: : : :
-rw-r--r-- 1 erpdev erpdev 33968 Mar 4 16:47 sales_invoice.js
-rw-r--r-- 1 erpdev erpdev 222 Mar 4 16:46 sales_invoice_dc.js
: : : :
-rw-r--r-- 1 erpdev erpdev 75707 Mar 4 18:31 sales_invoice.py
-rw-r--r-- 1 erpdev erpdev 321 Mar 2 00:28 sales_invoice_dc.py
: : : :
So, sales_invoice_dc.js and sales_invoice_dc.py would be null files, always imported by sales_invoice.js and sales_invoice.py respectively.
Like:
# -------------------------- User protected zone -------------------->>>
from . import sales_invoice_dc # developer customization
# -------------------------- User protected zone --------------------<<<
That is a nice idea, Martin. I would definitely use something like that. Today, Iām either writing code to hooks.py (which calls various other functions). Or I just edit the original code, and deal with comparisons. It depends on what I need done.
Fun Fact: Did you know that hooks.py is being processed every time a worker job is executed? To see what I mean, add this line anywhere in your hooks.py (make sure itās outside of a function)
print("This is hooks.py. Something just imported or called me.")
Then start ERPNext with bench start. Keep an eye on your console logs. Every 5 minutes, the worker_short job is re-running all the code inside hooks.py.
Feels like a bug. Though Iām afraid to get rid of it. Because I donāt see where hooks.py is otherwise being called and loaded on startup.
One of many little mysteries. Itās inefficient (loading the same functions over and over into the namespace). But not dangerous, so long as my hooks.py code stays inside of Classes and Functions, and doesnāt ādo anythingā by itself.
This applies for vanilla ERPNext only, and I DO NOT do any code changes unless it is a PR.
If anything fails in vanilla it will be fixed (eventually). No custom app to complicate things.
Every day there is a frappe_docker cron job that does following:
Installs latest version of ERPNext (currently v12)
Creates a site, (also tests basic backups, restores, etc)
Migrate v12 site to develop branch.
Once in a while we see patch failures.
I report on issues and tag patch writers as soon as I see the patch failing.
When v13 will get released Iāll update the cron job.
Anyone can keep a watch and report, it will benefit everyone in the future during production migration.
It took me a minute to understand why you posted this, but I think I get it.
That CI/CD job exists to flag daily any regression in compatibility between code base and database of V12 vs V13. Correct?
Iām guessing you intended that in reply to my remark, āIām starting my first installation, so it makes sense to me try to be compatible with V13 from the get go.ā Should I understand it as a suggestion to stick with V12 until V13 is released, then migrate once?
revant_oneās CI/CD process appears quite good. But heās not maintaining a separate fork of Frappe/ERPNext. Any changes he makes to code, he also creates a Pull Request to the official source code. Therefore, when his CI/CD does a synchronization, almost all differences will be handled by git āfast forwardā. Which requires no human intervention.
This would not work for my environments. I usually have 2 additional Apps. But more importantly, my Frappe and ERPNext code are forks of the official versions. I have made opinionated modifications and customizations, which are not in the official versions.
However, I am not performing a daily synchronization with official code. Maybe every 1-2 months? So just handle the upgrade manually, using git commands from the shell, and GUI tools like meld.