From 4b2ab9e00df17426fb06233a7f4c8d2ead04a838 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Sun, 21 Jul 2019 23:16:50 +0530 Subject: [PATCH 01/53] feat: Session Defaults --- .../core/doctype/session_default/__init__.py | 0 .../session_default/session_default.json | 29 ++++++++++++ .../session_default/session_default.py | 10 ++++ .../session_default_settings/__init__.py | 0 .../session_default_settings.js | 8 ++++ .../session_default_settings.json | 39 +++++++++++++++ .../session_default_settings.py | 44 +++++++++++++++++ .../test_session_default_settings.py | 10 ++++ frappe/desk/form/load.py | 2 +- frappe/hooks.py | 2 + frappe/model/base_document.py | 3 +- .../public/js/frappe/ui/toolbar/navbar.html | 2 + frappe/public/js/frappe/ui/toolbar/toolbar.js | 47 +++++++++++++++++++ 13 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 frappe/core/doctype/session_default/__init__.py create mode 100644 frappe/core/doctype/session_default/session_default.json create mode 100644 frappe/core/doctype/session_default/session_default.py create mode 100644 frappe/core/doctype/session_default_settings/__init__.py create mode 100644 frappe/core/doctype/session_default_settings/session_default_settings.js create mode 100644 frappe/core/doctype/session_default_settings/session_default_settings.json create mode 100644 frappe/core/doctype/session_default_settings/session_default_settings.py create mode 100644 frappe/core/doctype/session_default_settings/test_session_default_settings.py diff --git a/frappe/core/doctype/session_default/__init__.py b/frappe/core/doctype/session_default/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/core/doctype/session_default/session_default.json b/frappe/core/doctype/session_default/session_default.json new file mode 100644 index 0000000000..d382e12456 --- /dev/null +++ b/frappe/core/doctype/session_default/session_default.json @@ -0,0 +1,29 @@ +{ + "creation": "2019-07-17 16:21:33.546379", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "ref_doctype" + ], + "fields": [ + { + "fieldname": "ref_doctype", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Document Type", + "options": "DocType" + } + ], + "istable": 1, + "modified": "2019-07-21 13:22:25.752553", + "modified_by": "Administrator", + "module": "Core", + "name": "Session Default", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/frappe/core/doctype/session_default/session_default.py b/frappe/core/doctype/session_default/session_default.py new file mode 100644 index 0000000000..8a8db46ff1 --- /dev/null +++ b/frappe/core/doctype/session_default/session_default.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class SessionDefault(Document): + pass diff --git a/frappe/core/doctype/session_default_settings/__init__.py b/frappe/core/doctype/session_default_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.js b/frappe/core/doctype/session_default_settings/session_default_settings.js new file mode 100644 index 0000000000..9b71a17aed --- /dev/null +++ b/frappe/core/doctype/session_default_settings/session_default_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Session Default Settings', { + // refresh: function(frm) { + + // } +}); diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.json b/frappe/core/doctype/session_default_settings/session_default_settings.json new file mode 100644 index 0000000000..3eeb3f4167 --- /dev/null +++ b/frappe/core/doctype/session_default_settings/session_default_settings.json @@ -0,0 +1,39 @@ +{ + "creation": "2019-07-17 16:22:31.300991", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "session_defaults" + ], + "fields": [ + { + "fieldname": "session_defaults", + "fieldtype": "Table", + "label": "Session Defaults", + "options": "Session Default" + } + ], + "issingle": 1, + "modified": "2019-07-19 16:04:33.971089", + "modified_by": "Administrator", + "module": "Core", + "name": "Session Default Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.py b/frappe/core/doctype/session_default_settings/session_default_settings.py new file mode 100644 index 0000000000..5af15ac3a2 --- /dev/null +++ b/frappe/core/doctype/session_default_settings/session_default_settings.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +import json +from frappe.model.document import Document + +class SessionDefaultSettings(Document): + pass + +@frappe.whitelist() +def get_session_default_values(): + settings = frappe.get_single('Session Default Settings') + fields = [] + for default_values in settings.session_defaults: + reference_doctype = frappe.scrub(default_values.ref_doctype) + fields.append({ + 'fieldname': reference_doctype, + 'fieldtype': 'Link', + 'options': default_values.ref_doctype, + 'label': 'Default ' + default_values.ref_doctype, + 'default': frappe.defaults.get_user_default(reference_doctype) + }) + return json.dumps(fields) + +@frappe.whitelist() +def set_session_default_values(default_values): + default_values = json.loads(default_values) + for entry in default_values: + try: + frappe.defaults.set_user_default(entry, default_values.get(entry)) + except: + return + return "success" + +#called on hook 'on_logout' to clear defaults for the session +def clear_session_defaults(): + settings = frappe.get_single('Session Default Settings').session_defaults + for entry in settings: + document_type = frappe.db.get_value('Session Default', entry.name, 'ref_doctype') + frappe.defaults.clear_user_default(frappe.scrub(document_type + )) diff --git a/frappe/core/doctype/session_default_settings/test_session_default_settings.py b/frappe/core/doctype/session_default_settings/test_session_default_settings.py new file mode 100644 index 0000000000..0044ab7c31 --- /dev/null +++ b/frappe/core/doctype/session_default_settings/test_session_default_settings.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestSessionDefaultSettings(unittest.TestCase): + pass diff --git a/frappe/desk/form/load.py b/frappe/desk/form/load.py index 3b67b78144..e790bf6d06 100644 --- a/frappe/desk/form/load.py +++ b/frappe/desk/form/load.py @@ -252,4 +252,4 @@ def get_view_logs(doctype, docname): if view_logs: logs = view_logs - return logs \ No newline at end of file + return logs diff --git a/frappe/hooks.py b/frappe/hooks.py index 6b9caec22a..545ac8c3e8 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -80,6 +80,8 @@ on_session_creation = [ "frappe.utils.scheduler.reset_enabled_scheduler_events", ] +on_logout = "frappe.core.doctype.session_default_settings.session_default_settings.clear_session_defaults" + # permissions permission_query_conditions = { diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 47380c6550..570835bc32 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -175,10 +175,11 @@ class BaseDocument(object): if not self.doctype: return value if not isinstance(value, BaseDocument): - if "doctype" not in value: + if "doctype" not in value or value['doctype'] is None: value["doctype"] = self.get_table_field_doctype(key) if not value["doctype"]: raise AttributeError(key) + value = get_controller(value["doctype"])(value) value.init_valid_columns() diff --git a/frappe/public/js/frappe/ui/toolbar/navbar.html b/frappe/public/js/frappe/ui/toolbar/navbar.html index 799cc9bb3b..5e49d533bf 100644 --- a/frappe/public/js/frappe/ui/toolbar/navbar.html +++ b/frappe/public/js/frappe/ui/toolbar/navbar.html @@ -28,6 +28,8 @@ {%= __("My Profile") %}
  • {%= __("My Settings") %}
  • +
  • + {%= __("Session Defaults") %}
  • diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index d1826cc688..f5a09303c5 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -235,3 +235,50 @@ frappe.ui.toolbar.show_about = function() { } return false; }; + +frappe.ui.toolbar.setup_session_defaults = function() { + let fields = []; + frappe.call({ + method: 'frappe.core.doctype.session_default_settings.session_default_settings.get_session_default_values', + callback: function (data) { + fields = JSON.parse(data.message); + let perms = frappe.perm.get_perm('Session Default Settings'); + //add settings button only if user is a System Manager or has permission on 'Session Default Settings' + if ((in_list(frappe.user_roles, 'System Manager')) || (perms[0].read == 1)) { + fields[fields.length] = { + 'fieldname': 'settings', + 'fieldtype': 'Button', + 'label': __('Settings'), + 'click': () => { + frappe.set_route('Form', 'Session Default Settings', 'Session Default Settings'); + } + } + } + frappe.prompt(fields, function(values) { + frappe.call({ + method: 'frappe.core.doctype.session_default_settings.session_default_settings.set_session_default_values', + args: { + default_values: JSON.stringify(values) + }, + callback: function(data) { + if (data.message == "success") { + frappe.show_alert({ + 'message': __('Session Defaults Saved'), + 'indicator': 'green' + }); + } + else { + frappe.show_alert({ + 'message': __('An error occurred while setting Session Defaults'), + 'indicator': 'red' + }); + } + } + }) + }, + __('Session Defaults'), + __('Save'), + ); + } + }); +}; From 891735b5d6ebff153f5b4dc30b429752e24b6943 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Sun, 21 Jul 2019 23:56:31 +0530 Subject: [PATCH 02/53] fix: codacy fixes --- .../session_default_settings/session_default_settings.py | 2 +- frappe/public/js/frappe/ui/toolbar/toolbar.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.py b/frappe/core/doctype/session_default_settings/session_default_settings.py index 5af15ac3a2..752233b8bc 100644 --- a/frappe/core/doctype/session_default_settings/session_default_settings.py +++ b/frappe/core/doctype/session_default_settings/session_default_settings.py @@ -31,7 +31,7 @@ def set_session_default_values(default_values): for entry in default_values: try: frappe.defaults.set_user_default(entry, default_values.get(entry)) - except: + except Exception: return return "success" diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index f5a09303c5..9e6ccfe48b 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -252,7 +252,7 @@ frappe.ui.toolbar.setup_session_defaults = function() { 'click': () => { frappe.set_route('Form', 'Session Default Settings', 'Session Default Settings'); } - } + }; } frappe.prompt(fields, function(values) { frappe.call({ @@ -266,15 +266,14 @@ frappe.ui.toolbar.setup_session_defaults = function() { 'message': __('Session Defaults Saved'), 'indicator': 'green' }); - } - else { + } else { frappe.show_alert({ 'message': __('An error occurred while setting Session Defaults'), 'indicator': 'red' }); } } - }) + }); }, __('Session Defaults'), __('Save'), From d06abbd85284e850105f7a1ce76ba76fabee5b8b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 23 Jul 2019 16:46:15 +0530 Subject: [PATCH 03/53] feat: Option to skip failing patches in migrate (#7959) --- frappe/commands/site.py | 5 +++-- frappe/migrate.py | 4 ++-- frappe/modules/patch_handler.py | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 0eb6a36098..5668759882 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -220,8 +220,9 @@ def disable_user(context, email): @click.command('migrate') @click.option('--rebuild-website', help="Rebuild webpages after migration") +@click.option('--skip-failing', is_flag=True, help="Skip patches that fail to run") @pass_context -def migrate(context, rebuild_website=False): +def migrate(context, rebuild_website=False, skip_failing=False): "Run patches, sync schema and rebuild files/translations" from frappe.migrate import migrate @@ -230,7 +231,7 @@ def migrate(context, rebuild_website=False): frappe.init(site=site) frappe.connect() try: - migrate(context.verbose, rebuild_website=rebuild_website) + migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing) finally: frappe.destroy() diff --git a/frappe/migrate.py b/frappe/migrate.py index 7b5ce55b36..6778a3f18f 100644 --- a/frappe/migrate.py +++ b/frappe/migrate.py @@ -17,7 +17,7 @@ from frappe.core.doctype.language.language import sync_languages from frappe.modules.utils import sync_customizations from frappe.utils import global_search -def migrate(verbose=True, rebuild_website=False): +def migrate(verbose=True, rebuild_website=False, skip_failing=False): '''Migrate all apps to the latest version, will: - run before migrate hooks - run patches @@ -45,7 +45,7 @@ def migrate(verbose=True, rebuild_website=False): frappe.get_attr(fn)() # run patches - frappe.modules.patch_handler.run_all() + frappe.modules.patch_handler.run_all(skip_failing) # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() diff --git a/frappe/modules/patch_handler.py b/frappe/modules/patch_handler.py index 685d755fbd..b3237b8b76 100644 --- a/frappe/modules/patch_handler.py +++ b/frappe/modules/patch_handler.py @@ -19,23 +19,31 @@ import os class PatchError(Exception): pass -def run_all(): +def run_all(skip_failing=False): """run all pending patches""" executed = [p[0] for p in frappe.db.sql("""select patch from `tabPatch Log`""")] frappe.flags.final_patches = [] - for patch in get_all_patches(): - if patch and (patch not in executed): + + def run_patch(patch): + try: if not run_single(patchmodule = patch): log(patch + ': failed: STOPPED') raise PatchError(patch) + except Exception: + if not skip_failing: + raise + else: + log('Failed to execute patch') + + for patch in get_all_patches(): + if patch and (patch not in executed): + run_patch(patch) # patches to be run in the end for patch in frappe.flags.final_patches: patch = patch.replace('finally:', '') - if not run_single(patchmodule = patch): - log(patch + ': failed: STOPPED') - raise PatchError(patch) + run_patch(patch) def get_all_patches(): patches = [] From 17c2d2cb69420a3506ef4d64b631237d964142ba Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 23 Jul 2019 19:11:19 +0530 Subject: [PATCH 04/53] fix: Check is_private when checking for duplicates (#7957) * fix: Check is_private when checking for duplicates * fix: Fallback file_size --- frappe/core/doctype/file/file.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index 47df90d18c..6e6cce52bf 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -188,14 +188,20 @@ class File(NestedSet): # check duplicate name # check duplicate assignement - n_records = frappe.db.sql("""select name from `tabFile` - where content_hash=%s - and name!=%s - and attached_to_doctype=%s - and attached_to_name=%s""", (self.content_hash, self.name, self.attached_to_doctype, - self.attached_to_name)) - if len(n_records) > 0: - self.duplicate_entry = n_records[0][0] + filters = { + 'content_hash': self.content_hash, + 'is_private': self.is_private, + 'name': ('!=', self.name) + } + if self.attached_to_doctype and self.attached_to_name: + filters.update({ + 'attached_to_doctype': self.attached_to_doctype, + 'attached_to_name': self.attached_to_name + }) + duplicate_file = frappe.db.get_value('File', filters) + + if duplicate_file: + self.duplicate_entry = duplicate_file frappe.throw(_("Same file has already been attached to the record"), frappe.DuplicateEntryError) @@ -451,7 +457,7 @@ class File(NestedSet): return self.file_url = unquote(self.file_url) - self.file_size = frappe.form_dict.file_size + self.file_size = frappe.form_dict.file_size or self.file_size def get_uploaded_content(self): @@ -484,7 +490,13 @@ class File(NestedSet): self.content_hash = get_content_hash(self.content) self.content_type = mimetypes.guess_type(self.file_name)[0] - _file = frappe.get_value("File", {"content_hash": self.content_hash}, ["file_url"]) + # check if a file exists with the same content hash and is also in the same folder (public or private) + _file = frappe.get_value("File", { + "content_hash": self.content_hash, + "is_private": self.is_private + }, + ["file_url"]) + if _file: self.file_url = _file file_exists = True From e2ef036991ed01f4199817c889440540b971b256 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 24 Jul 2019 00:03:08 +0530 Subject: [PATCH 05/53] fix: added tests and few fixes --- .../session_default_settings.js | 8 ------- .../session_default_settings.py | 10 ++++----- .../test_session_default_settings.py | 22 +++++++++++++++++-- frappe/public/js/frappe/ui/toolbar/toolbar.js | 3 ++- 4 files changed, 27 insertions(+), 16 deletions(-) delete mode 100644 frappe/core/doctype/session_default_settings/session_default_settings.js diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.js b/frappe/core/doctype/session_default_settings/session_default_settings.js deleted file mode 100644 index 9b71a17aed..0000000000 --- a/frappe/core/doctype/session_default_settings/session_default_settings.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019, Frappe Technologies and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Session Default Settings', { - // refresh: function(frm) { - - // } -}); diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.py b/frappe/core/doctype/session_default_settings/session_default_settings.py index 752233b8bc..453ece2890 100644 --- a/frappe/core/doctype/session_default_settings/session_default_settings.py +++ b/frappe/core/doctype/session_default_settings/session_default_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ import json from frappe.model.document import Document @@ -20,14 +21,15 @@ def get_session_default_values(): 'fieldname': reference_doctype, 'fieldtype': 'Link', 'options': default_values.ref_doctype, - 'label': 'Default ' + default_values.ref_doctype, + 'label': _('Default {0}').format(_(default_values.ref_doctype)), 'default': frappe.defaults.get_user_default(reference_doctype) }) return json.dumps(fields) @frappe.whitelist() def set_session_default_values(default_values): - default_values = json.loads(default_values) + if not frappe.flags.in_test: + default_values = json.loads(default_values) for entry in default_values: try: frappe.defaults.set_user_default(entry, default_values.get(entry)) @@ -39,6 +41,4 @@ def set_session_default_values(default_values): def clear_session_defaults(): settings = frappe.get_single('Session Default Settings').session_defaults for entry in settings: - document_type = frappe.db.get_value('Session Default', entry.name, 'ref_doctype') - frappe.defaults.clear_user_default(frappe.scrub(document_type - )) + frappe.defaults.clear_user_default(frappe.scrub(entry.ref_doctype)) diff --git a/frappe/core/doctype/session_default_settings/test_session_default_settings.py b/frappe/core/doctype/session_default_settings/test_session_default_settings.py index 0044ab7c31..12aa14d343 100644 --- a/frappe/core/doctype/session_default_settings/test_session_default_settings.py +++ b/frappe/core/doctype/session_default_settings/test_session_default_settings.py @@ -3,8 +3,26 @@ # See license.txt from __future__ import unicode_literals -# import frappe +import frappe import unittest +from frappe.core.doctype.session_default_settings.session_default_settings import set_session_default_values, clear_session_defaults class TestSessionDefaultSettings(unittest.TestCase): - pass + def test_set_session_default_settings(self): + frappe.set_user("Administrator") + settings = frappe.get_single("Session Default Settings") + settings.session_defaults = [] + settings.append("session_defaults", { + "ref_doctype": "Role" + }) + settings.save() + + set_session_default_values({"role": "Website Manager"}) + + todo = frappe.get_doc(dict(doctype="ToDo", description="test session defaults set", assigned_by="Administrator")).insert() + self.assertEqual(todo.role, "Website Manager") + + def test_clear_session_defaults(self): + clear_session_defaults() + todo = frappe.get_doc(dict(doctype="ToDo", description="test session defaults cleared", assigned_by="Administrator")).insert() + self.assertNotEqual(todo.role, "Website Manager") diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index 9e6ccfe48b..ed5091b52f 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -258,7 +258,7 @@ frappe.ui.toolbar.setup_session_defaults = function() { frappe.call({ method: 'frappe.core.doctype.session_default_settings.session_default_settings.set_session_default_values', args: { - default_values: JSON.stringify(values) + default_values: values, }, callback: function(data) { if (data.message == "success") { @@ -266,6 +266,7 @@ frappe.ui.toolbar.setup_session_defaults = function() { 'message': __('Session Defaults Saved'), 'indicator': 'green' }); + frappe.clear_cache(); } else { frappe.show_alert({ 'message': __('An error occurred while setting Session Defaults'), From 2ee3610b43850d73ec1f13cc7812d4c6d3d47a34 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:38:14 +0530 Subject: [PATCH 06/53] fix(travis): Reduce Clutter Let's just try and do this for MariaDB Python 3.6 only --- .travis.yml | 20 -------------------- .travis/install.sh | 8 +------- .travis/run-tests.sh | 15 --------------- 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0dbd382702..0fec22cbe8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,31 +3,11 @@ dist: trusty sudo: required python: - - 2.7 - 3.6 -env: - - DB=mariadb - - DB=postgres - - TEST_TYPE=ui - services: - mysql -addons: - postgresql: "9.5" - hosts: - - test_site - - test_site_postgres - - test_site_ui - -matrix: - exclude: - - python: 2.7 - env: DB=postgres - - python: 2.7 - env: TEST_TYPE=ui - install: - $TRAVIS_BUILD_DIR/.travis/install.sh diff --git a/.travis/install.sh b/.travis/install.sh index a457939b22..f1a49d9ddf 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -18,10 +18,4 @@ sudo pip install -e ~/bench rm $TRAVIS_BUILD_DIR/.git/shallow cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR -if [[ $DB == 'mariadb' ]]; then - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ -elif [[ $TEST_TYPE == 'ui' ]]; then - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_ui ~/frappe-bench/sites/ -elif [[ $DB == 'postgres' ]]; then - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_postgres ~/frappe-bench/sites/ -fi +cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh index 177e191088..439800b5aa 100755 --- a/.travis/run-tests.sh +++ b/.travis/run-tests.sh @@ -13,18 +13,3 @@ if [[ $DB == 'mariadb' ]]; then bench --site test_site reinstall --yes bench --site test_site scheduler disable bench --site test_site run-tests --coverage - -elif [[ $TEST_TYPE == 'ui' ]]; then - setup_mariadb_env 'test_site_ui' - bench --site test_site_ui reinstall --yes - bench --site test_site_ui execute frappe.utils.install.complete_setup_wizard - bench --site test_site_ui scheduler disable - cd apps/frappe && yarn && yarn cypress:run - -elif [[ $DB == 'postgres' ]]; then - psql -c "CREATE DATABASE test_frappe;" -U postgres - psql -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe';" -U postgres - bench --site test_site_postgres reinstall --yes - bench --site test_site_postgres scheduler disable - bench --site test_site_postgres run-tests --coverage -fi From 6f1e6812b71fcf6122ffe7e7c5a04942bbcaecdd Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:41:07 +0530 Subject: [PATCH 07/53] fix(travis): Remove install.sh and run-tests.sh --- .travis.yml | 26 ++++++++++++++++++++++++-- .travis/install.sh | 21 --------------------- .travis/run-tests.sh | 15 --------------- 3 files changed, 24 insertions(+), 38 deletions(-) delete mode 100755 .travis/install.sh delete mode 100755 .travis/run-tests.sh diff --git a/.travis.yml b/.travis.yml index 0fec22cbe8..0d7e699391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,23 @@ services: - mysql install: - - $TRAVIS_BUILD_DIR/.travis/install.sh + - sudo rm /etc/apt/sources.list.d/mongodb*.list + - sudo rm /etc/apt/sources.list.d/docker.list + - sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ + - sudo apt-get purge -y mysql-common mysql-server mysql-client + - source ~/.nvm/nvm.sh + - nvm install v8.10.0 + + - pip install python-coveralls + + - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py + + - sudo python install.py --develop --user travis --without-bench-setup + - sudo pip install -e ~/bench + + - rm $TRAVIS_BUILD_DIR/.git/shallow + - cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR + - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ before_script: - cd ~/frappe-bench @@ -18,7 +34,13 @@ before_script: - sleep 10 script: - - $TRAVIS_BUILD_DIR/.travis/run-tests.sh + - mysql -u root -ptravis -e "create database test_frappe" + - mysql -u root -ptravis -e "USE mysql; CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'; FLUSH PRIVILEGES; " + - mysql -u root -ptravis -e "USE mysql; GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';" + - bench --site test_site reinstall --yes + - bench --site test_site scheduler disable + - bench --site test_site run-tests --coverage + after_script: - coveralls -b apps/frappe -d ../../sites/.coverage \ No newline at end of file diff --git a/.travis/install.sh b/.travis/install.sh deleted file mode 100755 index f1a49d9ddf..0000000000 --- a/.travis/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -sudo rm /etc/apt/sources.list.d/mongodb*.list -sudo rm /etc/apt/sources.list.d/docker.list -sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ -sudo apt-get purge -y mysql-common mysql-server mysql-client -source ~/.nvm/nvm.sh -nvm install v8.10.0 - -pip install python-coveralls - -wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - -sudo python install.py --develop --user travis --without-bench-setup -sudo pip install -e ~/bench - -rm $TRAVIS_BUILD_DIR/.git/shallow -cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR -cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh deleted file mode 100755 index 439800b5aa..0000000000 --- a/.travis/run-tests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -setup_mariadb_env() { - mysql -u root -ptravis -e "create database $1" - mysql -u root -ptravis -e "USE mysql; CREATE USER '$1'@'localhost' IDENTIFIED BY '$1'; FLUSH PRIVILEGES; " - mysql -u root -ptravis -e "USE mysql; GRANT ALL PRIVILEGES ON \`$1\`.* TO '$1'@'localhost';" -} - -if [[ $DB == 'mariadb' ]]; then - setup_mariadb_env 'test_frappe' - bench --site test_site reinstall --yes - bench --site test_site scheduler disable - bench --site test_site run-tests --coverage From acd801ba6672b097ee931605a5efe3bf87627c63 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:42:36 +0530 Subject: [PATCH 08/53] fix(travis): Remove unncessary installations --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d7e699391..9beae139cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,6 @@ services: - mysql install: - - sudo rm /etc/apt/sources.list.d/mongodb*.list - - sudo rm /etc/apt/sources.list.d/docker.list - - sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ - - sudo apt-get purge -y mysql-common mysql-server mysql-client - source ~/.nvm/nvm.sh - nvm install v8.10.0 From 87f14c2c09cf4e5844d79de84d2c1bc2f73c18eb Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:44:36 +0530 Subject: [PATCH 09/53] style: Use similar SQL syntax --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9beae139cd..c6a288b2a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,11 @@ before_script: - sleep 10 script: - - mysql -u root -ptravis -e "create database test_frappe" - - mysql -u root -ptravis -e "USE mysql; CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'; FLUSH PRIVILEGES; " - - mysql -u root -ptravis -e "USE mysql; GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';" + - mysql -u root -ptravis -e "CREATE DATABASE test_frappe" + - mysql -u root -ptravis -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" + - mysql -u root -ptravis -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" + - mysql -u root -ptravis -e "FLUSH PRIVILEGES" + - bench --site test_site reinstall --yes - bench --site test_site scheduler disable - bench --site test_site run-tests --coverage From 51edbe5498f857053712d500a82505c54f695dd3 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:45:31 +0530 Subject: [PATCH 10/53] fix(travis): Defer installing coveralls --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6a288b2a8..f416854120 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ install: - source ~/.nvm/nvm.sh - nvm install v8.10.0 - - pip install python-coveralls - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py @@ -41,4 +40,5 @@ script: after_script: + - pip install python-coveralls - coveralls -b apps/frappe -d ../../sites/.coverage \ No newline at end of file From 5406a3b26054796f719413b192bfc4f682ffbe62 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:48:41 +0530 Subject: [PATCH 11/53] fix(travis): Let's go pro here --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f416854120..be6fbebfcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,6 @@ install: - source ~/.nvm/nvm.sh - nvm install v8.10.0 - - - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - - - sudo python install.py --develop --user travis --without-bench-setup - sudo pip install -e ~/bench - rm $TRAVIS_BUILD_DIR/.git/shallow From f2226e0542a2d84182466b4e59bea31c61fefcef Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:49:16 +0530 Subject: [PATCH 12/53] fix(travis): sudo is unncessary here --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index be6fbebfcc..6d599bb1eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - source ~/.nvm/nvm.sh - nvm install v8.10.0 - - sudo pip install -e ~/bench + - pip install -e ~/bench - rm $TRAVIS_BUILD_DIR/.git/shallow - cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR From fbd7387436b90fb0ff2faedf086642bc097d1615 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 19:51:42 +0530 Subject: [PATCH 13/53] fix(travis): Clone bench repo --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6d599bb1eb..4ba0c967e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ install: - source ~/.nvm/nvm.sh - nvm install v8.10.0 + - git clone https://github.com/frappe/bench --depth 1 - pip install -e ~/bench - rm $TRAVIS_BUILD_DIR/.git/shallow From 6fd9c8dee62519291cc44bb2406f8d74838121c8 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:05:14 +0530 Subject: [PATCH 14/53] fix(travis): Do not build assets --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ba0c967e7..65c78b7064 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,11 @@ install: - source ~/.nvm/nvm.sh - nvm install v8.10.0 - - git clone https://github.com/frappe/bench --depth 1 - - pip install -e ~/bench + - git clone https://github.com/adityahase/bench --depth 1 --branch faster + - pip install -e ./bench - rm $TRAVIS_BUILD_DIR/.git/shallow - - cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR + - cd ~/ && bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ before_script: From 515014a35556275b8eff2c41e1e1957901a67af2 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:06:56 +0530 Subject: [PATCH 15/53] fix(travis): Remove unncessary actions --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 65c78b7064..22c2e6c30f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,13 +15,11 @@ install: - git clone https://github.com/adityahase/bench --depth 1 --branch faster - pip install -e ./bench - - rm $TRAVIS_BUILD_DIR/.git/shallow - cd ~/ && bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ before_script: - cd ~/frappe-bench - - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - sleep 10 From aef7d8d3818f4c522c0605e72fe0fca361c0d93a Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:09:01 +0530 Subject: [PATCH 16/53] fix(travis): Rearrange commands --- .travis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 22c2e6c30f..ecb48f4212 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,21 +18,20 @@ install: - cd ~/ && bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ -before_script: - - cd ~/frappe-bench - - bench start & - - sleep 10 - -script: - mysql -u root -ptravis -e "CREATE DATABASE test_frappe" - mysql -u root -ptravis -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" - mysql -u root -ptravis -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" - mysql -u root -ptravis -e "FLUSH PRIVILEGES" +before_script: + - cd ~/frappe-bench + - bench start & + - sleep 10 - bench --site test_site reinstall --yes - bench --site test_site scheduler disable - - bench --site test_site run-tests --coverage +script: + - bench --site test_site run-tests --coverage after_script: - pip install python-coveralls From 550f93bdd4b9b3c0a7bfdded51f45faa5ca73b36 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:19:42 +0530 Subject: [PATCH 17/53] fix(travis): Change working directory to ~ --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ecb48f4212..5aad3d295f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,14 @@ services: - mysql install: + - cd ~ - source ~/.nvm/nvm.sh - nvm install v8.10.0 - git clone https://github.com/adityahase/bench --depth 1 --branch faster - pip install -e ./bench - - cd ~/ && bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR + - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ - mysql -u root -ptravis -e "CREATE DATABASE test_frappe" From cbcb9de2d12085075f98798880c082cbad5b49fe Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:28:06 +0530 Subject: [PATCH 18/53] fix(travis): Drop ~ in favour of . --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aad3d295f..1b78bb6f48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ services: install: - cd ~ - - source ~/.nvm/nvm.sh + - source ./.nvm/nvm.sh - nvm install v8.10.0 - git clone https://github.com/adityahase/bench --depth 1 --branch faster @@ -25,7 +25,7 @@ install: - mysql -u root -ptravis -e "FLUSH PRIVILEGES" before_script: - - cd ~/frappe-bench + - cd ./frappe-bench - bench start & - sleep 10 - bench --site test_site reinstall --yes From 265c215fa8d9a75258ded30b7dea09bb56c4b29b Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:33:31 +0530 Subject: [PATCH 19/53] fix(travis): Set mysql root password to 'travis' --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b78bb6f48..7a499de2d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,12 @@ install: - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ - - mysql -u root -ptravis -e "CREATE DATABASE test_frappe" - - mysql -u root -ptravis -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" - - mysql -u root -ptravis -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" - - mysql -u root -ptravis -e "FLUSH PRIVILEGES" + - mysql -u root -e "CREATE DATABASE test_frappe" + - mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" + - mysql -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" + + - mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" + - mysql -u root -e "FLUSH PRIVILEGES" before_script: - cd ./frappe-bench From fac983270d41e46d369d517ef9cee57c2674f46c Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:34:26 +0530 Subject: [PATCH 20/53] fix(travis): SET required MariaDB variables --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7a499de2d6..40f7cd8e7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,12 @@ install: - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ + - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" + - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" + - mysql -u root -e "SET GLOBAL innodb_file_format=Barracuda" + - mysql -u root -e "SET GLOBAL innodb_file_per_table=ON" + - mysql -u root -e "SET GLOBAL innodb_large_prefix=1" + - mysql -u root -e "CREATE DATABASE test_frappe" - mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" - mysql -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" From a8b73c0a048ac887373d84eb13d3bdd22791ec5c Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:46:25 +0530 Subject: [PATCH 21/53] fix(travis): Do not run unnecessary processes --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 40f7cd8e7a..42b022c588 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,10 @@ install: before_script: - cd ./frappe-bench + - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile + - sed -i 's/socketio:/# socketio:/g' Procfile + - sed -i 's/watch:/# watch:/g' Procfile + - sed -i 's/schedule:/# schedule:/g' Procfile - bench start & - sleep 10 - bench --site test_site reinstall --yes From dcd4aac0849abd2b0e254d76a3f9e380b0bd1d6e Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:53:17 +0530 Subject: [PATCH 22/53] fix(travis): Do not sleep for 10 seconds --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 42b022c588..f6e3752b5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,12 +34,13 @@ install: before_script: - cd ./frappe-bench + - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile - sed -i 's/socketio:/# socketio:/g' Procfile - sed -i 's/watch:/# watch:/g' Procfile - sed -i 's/schedule:/# schedule:/g' Procfile + - bench start & - - sleep 10 - bench --site test_site reinstall --yes - bench --site test_site scheduler disable From a09e2794bf1f6d35655b9003433b94d652aeaee2 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:57:32 +0530 Subject: [PATCH 23/53] fix(travis): Install wkhtmltopdf --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index f6e3752b5a..22e34033d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,11 @@ install: - mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" - mysql -u root -e "FLUSH PRIVILEGES" + - wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz + - tar -xf /tmp/wkhtmltox.tar.xz -C /tmp + - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf + - sudo chmod o+x /usr/local/bin/wkhtmltopdf + before_script: - cd ./frappe-bench From 9c4567018ea188fa44ec037b7efb6f983ee8f413 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 20:57:49 +0530 Subject: [PATCH 24/53] fix(travis): Build frappe assets --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 22e34033d6..323a9f68dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ before_script: - bench start & - bench --site test_site reinstall --yes - bench --site test_site scheduler disable + - bench build --app frappe script: - bench --site test_site run-tests --coverage From 2941568fe2b38603d303195f5d41460ce672d429 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:01:03 +0530 Subject: [PATCH 25/53] perf(travis): Use pip cacher --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 323a9f68dd..86f9e52fa3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ python: services: - mysql +cache: + - pip + install: - cd ~ - source ./.nvm/nvm.sh From eded71a63a3f8413d773fcb337c2a337058b1666 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:08:58 +0530 Subject: [PATCH 26/53] fix(travis): Add test_site to hosts --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 86f9e52fa3..0ec9ee5349 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,10 @@ python: services: - mysql +addons: + hosts: + - test_site + cache: - pip From 043260cf21eaf63b8e18cfb04498c4dc57ce095a Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:12:13 +0530 Subject: [PATCH 27/53] perf(travis): Use --depth 1 while performing git clone --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0ec9ee5349..bc4d4beb8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,9 @@ addons: hosts: - test_site +git: + depth: 1 + cache: - pip From 690ef1af7cebf9c44f7a6a15e55b32ae20ced609 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:19:35 +0530 Subject: [PATCH 28/53] fix(travis): Run Python 2.7 and Python 3.6 builds --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bc4d4beb8a..317cff12e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ sudo: required python: - 3.6 + - 2.7 services: - mysql From a4cc151f1fcf56745817de36d14c2dbceee6f7e0 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:44:12 +0530 Subject: [PATCH 29/53] fix(travis): Use MariaDB 10.3 instead of MySQL --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 317cff12e2..c9b8249c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,10 @@ python: - 3.6 - 2.7 -services: - - mysql - addons: hosts: - test_site + mariadb: 10.3 git: depth: 1 @@ -32,9 +30,6 @@ install: - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" - - mysql -u root -e "SET GLOBAL innodb_file_format=Barracuda" - - mysql -u root -e "SET GLOBAL innodb_file_per_table=ON" - - mysql -u root -e "SET GLOBAL innodb_large_prefix=1" - mysql -u root -e "CREATE DATABASE test_frappe" - mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" From f064689af096f53866e3339df65d8f7e3db0055f Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 4 Jul 2019 21:57:54 +0530 Subject: [PATCH 30/53] fix(travis): Create Build Matrix --- .travis.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9b8249c04..7f9c76cf24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,11 @@ language: python dist: trusty sudo: required -python: - - 3.6 - - 2.7 - addons: hosts: - test_site mariadb: 10.3 + postgresql: 9.5 git: depth: 1 @@ -17,6 +14,21 @@ git: cache: - pip +matrix: + include: + - name: "Python 3.6 MariaDB" + python: 3.6 + env: DB=MariaDB + - name: "Python 3.6 PostgreSQL" + python: 3.6 + env: DB=PostgreSQL + - name: "Cypress" + python: 3.6 + env: DB=MariaDB + - name: "Python 2.7 MariaDB" + python: 2.7 + env: DB=MariaDB + install: - cd ~ - source ./.nvm/nvm.sh From 96d7a2f171fd4861273de87c6a4f6b45bc7977c2 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 17:38:16 +0530 Subject: [PATCH 31/53] fix(travis): Handle postgres builds as well --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7f9c76cf24..f5899e3bd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,6 +50,9 @@ install: - mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" - mysql -u root -e "FLUSH PRIVILEGES" + - psql -c "CREATE DATABASE test_frappe" -U postgres + - psql -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres + - wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz - tar -xf /tmp/wkhtmltox.tar.xz -C /tmp - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf From fb03b34f3dfeca9606b6e2b7a2ecdfc19c059f2d Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 17:44:52 +0530 Subject: [PATCH 32/53] fix(travis): Use database specific site_config.json files --- .travis.yml | 12 +++++++----- test_sites/mariadb.json | 14 ++++++++++++++ test_sites/postgres.json | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 test_sites/mariadb.json create mode 100644 test_sites/postgres.json diff --git a/.travis.yml b/.travis.yml index f5899e3bd6..b8a1b30f65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,16 +18,16 @@ matrix: include: - name: "Python 3.6 MariaDB" python: 3.6 - env: DB=MariaDB + env: DB=mariadb - name: "Python 3.6 PostgreSQL" python: 3.6 - env: DB=PostgreSQL + env: DB=postgres - name: "Cypress" python: 3.6 - env: DB=MariaDB + env: DB=mariadb - name: "Python 2.7 MariaDB" python: 2.7 - env: DB=MariaDB + env: DB=mariadb install: - cd ~ @@ -38,7 +38,9 @@ install: - pip install -e ./bench - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ + + - mkdir ~/frappe-bench/sites/test_site + - cp $TRAVIS_BUILD_DIR/test_sites/$DB.json ~/frappe-bench/sites/test_site/site_config.json - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" diff --git a/test_sites/mariadb.json b/test_sites/mariadb.json new file mode 100644 index 0000000000..550ad94769 --- /dev/null +++ b/test_sites/mariadb.json @@ -0,0 +1,14 @@ +{ + "db_host": "localhost", + "db_name": "test_frappe", + "db_password": "test_frappe", + "db_type": "mariadb", + "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" +} diff --git a/test_sites/postgres.json b/test_sites/postgres.json new file mode 100644 index 0000000000..619dd91f10 --- /dev/null +++ b/test_sites/postgres.json @@ -0,0 +1,14 @@ +{ + "db_host": "localhost", + "db_name": "test_frappe", + "db_password": "test_frappe", + "db_type": "postgres", + "auto_email_id": "test@example.com", + "mail_server": "smtp.example.com", + "mail_login": "test@example.com", + "mail_password": "test", + "admin_password": "admin", + "root_login": "postgres", + "root_password": "travis", + "host_name": "http://test_site:8000" +} From 252b14c7f1af3251191a0a1327259781f0cacb29 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:03:17 +0530 Subject: [PATCH 33/53] fix(travis): Include UI tests --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8a1b30f65..32f409babd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,16 +18,16 @@ matrix: include: - name: "Python 3.6 MariaDB" python: 3.6 - env: DB=mariadb + env: DB=mariadb TYPE=server - name: "Python 3.6 PostgreSQL" python: 3.6 - env: DB=postgres + env: DB=postgres TYPE=server - name: "Cypress" python: 3.6 - env: DB=mariadb + env: DB=mariadb TYPE=ui - name: "Python 2.7 MariaDB" python: 2.7 - env: DB=mariadb + env: DB=mariadb TYPE=server install: - cd ~ @@ -74,7 +74,14 @@ before_script: - bench build --app frappe script: - - bench --site test_site run-tests --coverage + - | + if [ $TYPE == "server" ]; then + bench --site test_site run-tests --coverage + else + bench setup requirements --node + bench --site test_site execute frappe.utils.install.complete_setup_wizard + bench --site test_site run-ui-tests + fi after_script: - pip install python-coveralls From 393e3c2165be944baf3db29d096c4c6a7801d50a Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:25:20 +0530 Subject: [PATCH 34/53] perf(travis): Use yarn cacher --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 32f409babd..227204e139 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ git: cache: - pip + - yarn matrix: include: From 6a2660a34c8c0f33c3eb24c833f255434c8f0b9d Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:34:22 +0530 Subject: [PATCH 35/53] fix(travis): Remove shell scripted if condition --- .travis.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 227204e139..97ee96b36e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,15 +20,25 @@ matrix: - name: "Python 3.6 MariaDB" python: 3.6 env: DB=mariadb TYPE=server + script: bench --site test_site run-tests --coverage + - name: "Python 3.6 PostgreSQL" python: 3.6 env: DB=postgres TYPE=server + script: bench --site test_site run-tests --coverage + - name: "Cypress" python: 3.6 env: DB=mariadb TYPE=ui + before_script: + - bench setup requirements --node + - bench --site test_site execute frappe.utils.install.complete_setup_wizard + script: bench --site test_site run-ui-tests frappe + - name: "Python 2.7 MariaDB" python: 2.7 env: DB=mariadb TYPE=server + script: bench --site test_site run-tests --coverage install: - cd ~ @@ -61,7 +71,7 @@ install: - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf - sudo chmod o+x /usr/local/bin/wkhtmltopdf -before_script: +after_install: - cd ./frappe-bench - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile @@ -74,16 +84,7 @@ before_script: - bench --site test_site scheduler disable - bench build --app frappe -script: - - | - if [ $TYPE == "server" ]; then - bench --site test_site run-tests --coverage - else - bench setup requirements --node - bench --site test_site execute frappe.utils.install.complete_setup_wizard - bench --site test_site run-ui-tests - fi after_script: - pip install python-coveralls - - coveralls -b apps/frappe -d ../../sites/.coverage \ No newline at end of file + - coveralls -b apps/frappe -d ../../sites/.coverage From ed4cd9641eac97f335468e2667fe20da3680382b Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:39:32 +0530 Subject: [PATCH 36/53] fix(travis): Reach bench directory before executing bench commands --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97ee96b36e..cd282dd0ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,17 +20,18 @@ matrix: - name: "Python 3.6 MariaDB" python: 3.6 env: DB=mariadb TYPE=server - script: bench --site test_site run-tests --coverage + script: cd ~/frappe-bench && bench --site test_site run-tests --coverage - name: "Python 3.6 PostgreSQL" python: 3.6 env: DB=postgres TYPE=server - script: bench --site test_site run-tests --coverage + script: cd ~/frappe-bench && bench --site test_site run-tests --coverage - name: "Cypress" python: 3.6 env: DB=mariadb TYPE=ui before_script: + - cd ~/frappe-bench - bench setup requirements --node - bench --site test_site execute frappe.utils.install.complete_setup_wizard script: bench --site test_site run-ui-tests frappe @@ -38,7 +39,7 @@ matrix: - name: "Python 2.7 MariaDB" python: 2.7 env: DB=mariadb TYPE=server - script: bench --site test_site run-tests --coverage + script: cd ~/frappe-bench && bench --site test_site run-tests --coverage install: - cd ~ From cb89a3062f985eb3ccc72fdac588f29a3f0debc2 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:41:58 +0530 Subject: [PATCH 37/53] fix(travis): Remove TYPE environment vairable --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd282dd0ef..8c870c606d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,17 +19,17 @@ matrix: include: - name: "Python 3.6 MariaDB" python: 3.6 - env: DB=mariadb TYPE=server + env: DB=mariadb script: cd ~/frappe-bench && bench --site test_site run-tests --coverage - name: "Python 3.6 PostgreSQL" python: 3.6 - env: DB=postgres TYPE=server + env: DB=postgres script: cd ~/frappe-bench && bench --site test_site run-tests --coverage - name: "Cypress" python: 3.6 - env: DB=mariadb TYPE=ui + env: DB=mariadb before_script: - cd ~/frappe-bench - bench setup requirements --node @@ -38,7 +38,7 @@ matrix: - name: "Python 2.7 MariaDB" python: 2.7 - env: DB=mariadb TYPE=server + env: DB=mariadb script: cd ~/frappe-bench && bench --site test_site run-tests --coverage install: From e80639cb667ac4753758e5cb940708ce2be8960f Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:45:20 +0530 Subject: [PATCH 38/53] fix(travis): No stage named after_install --- .travis.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8c870c606d..f161291b0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,18 +20,17 @@ matrix: - name: "Python 3.6 MariaDB" python: 3.6 env: DB=mariadb - script: cd ~/frappe-bench && bench --site test_site run-tests --coverage + script: bench --site test_site run-tests --coverage - name: "Python 3.6 PostgreSQL" python: 3.6 env: DB=postgres - script: cd ~/frappe-bench && bench --site test_site run-tests --coverage + script: bench --site test_site run-tests --coverage - name: "Cypress" python: 3.6 env: DB=mariadb before_script: - - cd ~/frappe-bench - bench setup requirements --node - bench --site test_site execute frappe.utils.install.complete_setup_wizard script: bench --site test_site run-ui-tests frappe @@ -39,7 +38,7 @@ matrix: - name: "Python 2.7 MariaDB" python: 2.7 env: DB=mariadb - script: cd ~/frappe-bench && bench --site test_site run-tests --coverage + script: bench --site test_site run-tests --coverage install: - cd ~ @@ -72,7 +71,6 @@ install: - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf - sudo chmod o+x /usr/local/bin/wkhtmltopdf -after_install: - cd ./frappe-bench - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile @@ -85,7 +83,6 @@ after_install: - bench --site test_site scheduler disable - bench build --app frappe - after_script: - pip install python-coveralls - coveralls -b apps/frappe -d ../../sites/.coverage From 8d3d4c016baa8e2e81f21930c800dfa686004a42 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:50:28 +0530 Subject: [PATCH 39/53] perf(travis): Use npm cacher --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f161291b0e..12c3e6cc24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ git: cache: - pip + - npm - yarn matrix: From c774a6fc51b020bd47b190302658c448ae9f3f91 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 18:51:39 +0530 Subject: [PATCH 40/53] fix(travis): Run cypress tests headlessly --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12c3e6cc24..f7ef23f080 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ matrix: before_script: - bench setup requirements --node - bench --site test_site execute frappe.utils.install.complete_setup_wizard - script: bench --site test_site run-ui-tests frappe + script: bench --site test_site run-ui-tests frappe --headless - name: "Python 2.7 MariaDB" python: 2.7 From 0204dae52d1861dedbc56baeadbc9918ad1a6789 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 19:05:22 +0530 Subject: [PATCH 41/53] fix(travis): execute bench build before cypress tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f7ef23f080..6ee1d541d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ matrix: env: DB=mariadb before_script: - bench setup requirements --node + - bench build --app frappe - bench --site test_site execute frappe.utils.install.complete_setup_wizard script: bench --site test_site run-ui-tests frappe --headless From 8a3c5a8c51107213970b03fbf036fe9704e5c3ad Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 19:08:04 +0530 Subject: [PATCH 42/53] fix(tests): Raise CalledProcessError if run-ui-test errors --- frappe/commands/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 6e0786a528..eb8cf0e088 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -478,7 +478,7 @@ def run_ui_tests(context, app, headless=False): run_or_open = 'run' if headless else 'open' command = '{site_env} {password_env} yarn run cypress {run_or_open}' formatted_command = command.format(site_env=site_env, password_env=password_env, run_or_open=run_or_open) - frappe.commands.popen(formatted_command, cwd=app_base_path) + frappe.commands.popen(formatted_command, cwd=app_base_path, raise_err=True) @click.command('run-setup-wizard-ui-test') @click.option('--app', help="App to run tests on, leave blank for all apps") From ab46cd21bbe45da45ff95f333037c07bf65f915d Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 19:15:02 +0530 Subject: [PATCH 43/53] fix(travis): Remove unused files --- .travis.yml | 2 +- {test_sites => .travis}/mariadb.json | 0 {test_sites => .travis}/postgres.json | 0 test_sites/apps.txt | 0 test_sites/test_site/site_config.json | 12 ------------ test_sites/test_site_postgres/site_config.json | 15 --------------- test_sites/test_site_ui/site_config.json | 14 -------------- 7 files changed, 1 insertion(+), 42 deletions(-) rename {test_sites => .travis}/mariadb.json (100%) rename {test_sites => .travis}/postgres.json (100%) delete mode 100644 test_sites/apps.txt delete mode 100644 test_sites/test_site/site_config.json delete mode 100644 test_sites/test_site_postgres/site_config.json delete mode 100644 test_sites/test_site_ui/site_config.json diff --git a/.travis.yml b/.travis.yml index 6ee1d541d4..200d09365c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ install: - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR - mkdir ~/frappe-bench/sites/test_site - - cp $TRAVIS_BUILD_DIR/test_sites/$DB.json ~/frappe-bench/sites/test_site/site_config.json + - cp $TRAVIS_BUILD_DIR/.travis/$DB.json ~/frappe-bench/sites/test_site/site_config.json - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" diff --git a/test_sites/mariadb.json b/.travis/mariadb.json similarity index 100% rename from test_sites/mariadb.json rename to .travis/mariadb.json diff --git a/test_sites/postgres.json b/.travis/postgres.json similarity index 100% rename from test_sites/postgres.json rename to .travis/postgres.json diff --git a/test_sites/apps.txt b/test_sites/apps.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test_sites/test_site/site_config.json b/test_sites/test_site/site_config.json deleted file mode 100644 index 40a2d62b6d..0000000000 --- a/test_sites/test_site/site_config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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_password": "travis", - "run_selenium_tests": 1, - "host_name": "http://test_site:8000" -} diff --git a/test_sites/test_site_postgres/site_config.json b/test_sites/test_site_postgres/site_config.json deleted file mode 100644 index 5f00580c53..0000000000 --- a/test_sites/test_site_postgres/site_config.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_host": "localhost", - "db_name": "test_frappe", - "db_password": "test_frappe", - "db_type": "postgres", - "auto_email_id": "test@example.com", - "mail_server": "smtp.example.com", - "mail_login": "test@example.com", - "mail_password": "test", - "admin_password": "admin", - "root_login": "postgres", - "root_password": "travis", - "run_selenium_tests": 1, - "host_name": "http://test_site_postgres:8000" -} diff --git a/test_sites/test_site_ui/site_config.json b/test_sites/test_site_ui/site_config.json deleted file mode 100644 index d233a6b553..0000000000 --- a/test_sites/test_site_ui/site_config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "developer_mode": 1, - "db_name": "test_site_ui", - "db_password": "test_site_ui", - "db_type": "mariadb", - "auto_email_id": "test@example.com", - "mail_server": "smtp.example.com", - "mail_login": "test@example.com", - "mail_password": "test", - "admin_password": "admin", - "root_password": "travis", - "run_selenium_tests": 1, - "host_name": "http://test_site_ui:8000" -} From 3623e4735f949147be07b4302b0786702561bcea Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 23 Jul 2019 19:46:52 +0530 Subject: [PATCH 44/53] perf(travis): Faster cypress tests --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 200d09365c..bdbea5e551 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,10 +32,11 @@ matrix: python: 3.6 env: DB=mariadb before_script: - - bench setup requirements --node - - bench build --app frappe - bench --site test_site execute frappe.utils.install.complete_setup_wizard - script: bench --site test_site run-ui-tests frappe --headless + - cd apps/frappe + - yarn + script: + - yarn cypress:run - name: "Python 2.7 MariaDB" python: 2.7 From cf99fd81f3c5f6e09ed3bed3c8b8beb0e42a167c Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 13:44:32 +0530 Subject: [PATCH 45/53] fix(travis): Activate socketio --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bdbea5e551..195dfa9636 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,8 +76,6 @@ install: - cd ./frappe-bench - - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile - - sed -i 's/socketio:/# socketio:/g' Procfile - sed -i 's/watch:/# watch:/g' Procfile - sed -i 's/schedule:/# schedule:/g' Procfile From d11a2e5bcda70e4c6b0135f5e8339d3692c3c468 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 13:49:28 +0530 Subject: [PATCH 46/53] fix(travis): No need to disable scheduler with cli --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 195dfa9636..ac1905671f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,7 +81,6 @@ install: - bench start & - bench --site test_site reinstall --yes - - bench --site test_site scheduler disable - bench build --app frappe after_script: From bf1c38380b4f5d3e8394f67b3a12757dce2111e1 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 13:59:47 +0530 Subject: [PATCH 47/53] fix(travis): Build app before cypress tests --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac1905671f..0f92947f9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,10 @@ matrix: env: DB=mariadb before_script: - bench --site test_site execute frappe.utils.install.complete_setup_wizard - - cd apps/frappe - - yarn + - bench setup requirements --node + - bench build --app frappe script: - - yarn cypress:run + - bench --site test_site run-ui-tests frappe --headless - name: "Python 2.7 MariaDB" python: 2.7 From ecf3dfeb150a196a3804a7ccfe915576a232e63b Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 14:11:58 +0530 Subject: [PATCH 48/53] fix(travis): Run setup requirements before running node socketio.js --- .travis.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f92947f9f..7abad59004 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,27 +20,23 @@ matrix: include: - name: "Python 3.6 MariaDB" python: 3.6 - env: DB=mariadb + env: DB=mariadb TYPE=server script: bench --site test_site run-tests --coverage - name: "Python 3.6 PostgreSQL" python: 3.6 - env: DB=postgres + env: DB=postgres TYPE=server script: bench --site test_site run-tests --coverage - name: "Cypress" python: 3.6 - env: DB=mariadb - before_script: - - bench --site test_site execute frappe.utils.install.complete_setup_wizard - - bench setup requirements --node - - bench build --app frappe - script: - - bench --site test_site run-ui-tests frappe --headless + env: DB=mariadb TYPE=ui + before_script: bench --site test_site execute frappe.utils.install.complete_setup_wizard + script: bench --site test_site run-ui-tests frappe --headless - name: "Python 2.7 MariaDB" python: 2.7 - env: DB=mariadb + env: DB=mariadb TYPE=server script: bench --site test_site run-tests --coverage install: @@ -79,6 +75,11 @@ install: - sed -i 's/watch:/# watch:/g' Procfile - sed -i 's/schedule:/# schedule:/g' Procfile + - if [ $TYPE == "server" ]; then sed -i 's/socketio:/# socketio:/g' Procfile; fi + - if [ $TYPE == "server" ]; then sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile; fi + + - if [ $TYPE == "ui" ]; then bench setup requirements --node; fi + - bench start & - bench --site test_site reinstall --yes - bench build --app frappe From 7d65a557d1eb813de0ebe244554f698c8805d81c Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 14:29:29 +0530 Subject: [PATCH 49/53] fix(commnds): Raise CalledProcessError if process returns non-zero exit code --- frappe/commands/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/commands/__init__.py b/frappe/commands/__init__.py index 84e5f4937f..8110f2ec19 100644 --- a/frappe/commands/__init__.py +++ b/frappe/commands/__init__.py @@ -62,7 +62,7 @@ def popen(command, *args, **kwargs): return_ = proc.wait() - if raise_err: + if return_ and raise_err: raise subprocess.CalledProcessError(return_, command) return return_ From 8158803fba9df317a95acae39ae1cbb3f7c7ac01 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 15:00:36 +0530 Subject: [PATCH 50/53] fix(travis): Use frappe/bench --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7abad59004..df66db88a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ install: - source ./.nvm/nvm.sh - nvm install v8.10.0 - - git clone https://github.com/adityahase/bench --depth 1 --branch faster + - git clone https://github.com/frappe/bench --depth 1 - pip install -e ./bench - bench init frappe-bench --skip-assets --python $(which python) --frappe-path $TRAVIS_BUILD_DIR From 44de671ac118c42ead9d483302f4643daf3d49af Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 24 Jul 2019 16:06:48 +0530 Subject: [PATCH 51/53] fix: urls for changelog --- frappe/change_log/v12/v12_0_0.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/frappe/change_log/v12/v12_0_0.md b/frappe/change_log/v12/v12_0_0.md index 897b351122..99b31c0b9a 100644 --- a/frappe/change_log/v12/v12_0_0.md +++ b/frappe/change_log/v12/v12_0_0.md @@ -1,8 +1,8 @@ # Version 12 Release Notes ### UI/UX Enhancements -1. [New Desktop](/docs/user/manual/en/using-erpnext/desktop) -1. [Keyboard Navigation](/docs/user/manual/en/using-erpnext/articles/keyboard-shortcuts) +1. [New Desktop](https://erpnext.com/docs/user/manual/en/using-erpnext/desktop) +1. [Keyboard Navigation](https://erpnext.com/docs/user/manual/en/using-erpnext/articles/keyboard-shortcuts) 1. [Link Preview](/version-12/release-notes/features#link-preview) 1. [New Upload Dialog](/version-12/release-notes/features#new-upload-dialog) 1. [Frequently visited links appear in Awesomebar results](/version-12/release-notes/features#frequently-visited-links-appear-in-awesomebar-results) @@ -10,20 +10,20 @@ 1. [List View Enhancements](/version-12/release-notes/features#list-view-enhancements) ### New Automation Module -1. [Assignment Rule](/docs/user/manual/en/setting-up/automation/assignment-rule) -1. [Milestones](/docs/user/manual/en/setting-up/automation/milestone-tracker) -1. [Auto Repeat](/docs/user/manual/en/setting-up/automation/auto-repeat) +1. [Assignment Rule](https://erpnext.com/docs/user/manual/en/setting-up/automation/assignment-rule) +1. [Milestones](https://erpnext.com/docs/user/manual/en/setting-up/automation/milestone-tracker) +1. [Auto Repeat](https://erpnext.com/docs/user/manual/en/setting-up/automation/auto-repeat) ### Other Changes & Enhancements -1. [Document Follow](/docs/user/manual/en/setting-up/email/document-follow) -1. [Energy Points](/docs/user/manual/en/setting-up/energy-point-system) -1. [Dashboards](/docs/user/manual/en/customize-erpnext/dashboard) +1. [Document Follow](https://erpnext.com/docs/user/manual/en/setting-up/email/document-follow) +1. [Energy Points](https://erpnext.com/docs/user/manual/en/setting-up/energy-point-system) +1. [Dashboards](https://erpnext.com/docs/user/manual/en/customize-erpnext/dashboard) 1. [Disable customization for single doctypes](/version-12/release-notes/features#disable-customization-for-single-doctypes) -1. [Email Linking](/docs/user/manual/en/setting-up/email/linking-emails-to-document) -1. [Google Contacts](/docs/user/manual/en/erpnext_integration/google_contacts) +1. [Email Linking](https://erpnext.com/docs/user/manual/en/setting-up/email/linking-emails-to-document) +1. [Google Contacts](https://erpnext.com/docs/user/manual/en/erpnext_integration/google_contacts) 1. [PDF Encryption](/version-12/release-notes/features#pdf-encryption) -1. [Raw Printing](/docs/user/manual/en/setting-up/print/raw-printing) +1. [Raw Printing](https://erpnext.com/docs/user/manual/en/setting-up/print/raw-printing) 1. [Web Form Refactor](/version-12/release-notes/features#web-form-refactor) -1. [Website Refactor](/docs/user/manual/en/website) -1. [Added Track Views field to Customize Form](/version-12/release-notes/features#added-track-views-field-to-customize-form) -1. [Add custom columns to any report](/version-12/release-notes/features#add-custom-columns-to-any-report) +1. [Website Refactor](https://erpnext.com/docs/user/manual/en/website) +1. [Added Track Views field to Customize Form](https://erpnext.com/version-12/release-notes/features#added-track-views-field-to-customize-form) +1. [Add custom columns to any report](https://erpnext.com/version-12/release-notes/features#add-custom-columns-to-any-report) From 5dc72f00f51d072a14ad816c8386ea705ddf2290 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 24 Jul 2019 16:09:56 +0530 Subject: [PATCH 52/53] fix: more url fixes --- frappe/change_log/v12/v12_0_0.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frappe/change_log/v12/v12_0_0.md b/frappe/change_log/v12/v12_0_0.md index 99b31c0b9a..215b612794 100644 --- a/frappe/change_log/v12/v12_0_0.md +++ b/frappe/change_log/v12/v12_0_0.md @@ -3,11 +3,11 @@ ### UI/UX Enhancements 1. [New Desktop](https://erpnext.com/docs/user/manual/en/using-erpnext/desktop) 1. [Keyboard Navigation](https://erpnext.com/docs/user/manual/en/using-erpnext/articles/keyboard-shortcuts) -1. [Link Preview](/version-12/release-notes/features#link-preview) -1. [New Upload Dialog](/version-12/release-notes/features#new-upload-dialog) -1. [Frequently visited links appear in Awesomebar results](/version-12/release-notes/features#frequently-visited-links-appear-in-awesomebar-results) -1. [Full Width Container]((/version-12/release-notes/features#full-width-container)) -1. [List View Enhancements](/version-12/release-notes/features#list-view-enhancements) +1. [Link Preview](https://erpnext.com/version-12/release-notes/features#link-preview) +1. [New Upload Dialog](https://erpnext.com/version-12/release-notes/features#new-upload-dialog) +1. [Frequently visited links appear in Awesomebar results](https://erpnext.com/version-12/release-notes/features#frequently-visited-links-appear-in-awesomebar-results) +1. [Full Width Container]((https://erpnext.com/version-12/release-notes/features#full-width-container)) +1. [List View Enhancements](https://erpnext.com/version-12/release-notes/features#list-view-enhancements) ### New Automation Module 1. [Assignment Rule](https://erpnext.com/docs/user/manual/en/setting-up/automation/assignment-rule) @@ -18,12 +18,12 @@ 1. [Document Follow](https://erpnext.com/docs/user/manual/en/setting-up/email/document-follow) 1. [Energy Points](https://erpnext.com/docs/user/manual/en/setting-up/energy-point-system) 1. [Dashboards](https://erpnext.com/docs/user/manual/en/customize-erpnext/dashboard) -1. [Disable customization for single doctypes](/version-12/release-notes/features#disable-customization-for-single-doctypes) +1. [Disable customization for single doctypes](https://erpnext.com/version-12/release-notes/features#disable-customization-for-single-doctypes) 1. [Email Linking](https://erpnext.com/docs/user/manual/en/setting-up/email/linking-emails-to-document) 1. [Google Contacts](https://erpnext.com/docs/user/manual/en/erpnext_integration/google_contacts) -1. [PDF Encryption](/version-12/release-notes/features#pdf-encryption) +1. [PDF Encryption](https://erpnext.com/version-12/release-notes/features#pdf-encryption) 1. [Raw Printing](https://erpnext.com/docs/user/manual/en/setting-up/print/raw-printing) -1. [Web Form Refactor](/version-12/release-notes/features#web-form-refactor) +1. [Web Form Refactor](https://erpnext.com/version-12/release-notes/features#web-form-refactor) 1. [Website Refactor](https://erpnext.com/docs/user/manual/en/website) 1. [Added Track Views field to Customize Form](https://erpnext.com/version-12/release-notes/features#added-track-views-field-to-customize-form) 1. [Add custom columns to any report](https://erpnext.com/version-12/release-notes/features#add-custom-columns-to-any-report) From b30199b7f5c9dc62563fc4c528432f1160de0fd3 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 16:30:33 +0530 Subject: [PATCH 53/53] fix(security): Make jinja rendering tighter --- frappe/utils/jinja.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/jinja.py b/frappe/utils/jinja.py index 7a27fb3c3b..f8745b82c3 100644 --- a/frappe/utils/jinja.py +++ b/frappe/utils/jinja.py @@ -71,7 +71,7 @@ def render_template(template, context, is_path=None, safe_render=True): or (template.endswith('.html') and '\n' not in template)): return get_jenv().get_template(template).render(context) else: - if safe_render and ".__" in template: + if safe_render and "__" in template: throw("Illegal template") try: return get_jenv().from_string(template).render(context)