Skip to content

Commit

Permalink
Merge branch 'develop' into skip-restart-on-setup-req
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza authored May 12, 2020
2 parents 0c9db68 + c022d7b commit 11c2ec6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ To setup a development environment for Docker, follow the [Frappe/ERPNext Docker
Copy the `env-example` file to `.env`

```sh
$ cp installation/env-example installation/.env
```

Make a directory for handling sites:

```sh
$ mkdir installation/sites
$ cp env-example .env
```

Optionally, you may also setup an [NGINX Proxy for SSL Certificates](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) with auto-renewal for your Production instance. We recommend this for instances being accessed over the internet. For this to work, the DNS needs to be configured correctly so that [LetsEncrypt](https://letsencrypt.org) can verify the domain. To setup the proxy, run the following commands:
Expand Down
7 changes: 4 additions & 3 deletions bench/patches/v5/fix_user_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# imports - module imports
from bench.cli import change_uid_msg
from bench.config.production_setup import get_supervisor_confdir, is_centos7
from bench.config.production_setup import get_supervisor_confdir, is_centos7, service
from bench.config.common_site_config import get_config
from bench.utils import exec_cmd, get_bench_name, get_cmd_output

Expand Down Expand Up @@ -53,7 +53,8 @@ def execute(bench_path):
user = get_config('.').get("frappe_user") or getpass.getuser()

if is_sudoers_set():
exec_cmd("sudo bench setup sudoers {user}".format(user=user))

if is_production_set(bench_path):
exec_cmd("sudo bench setup supervisor --yes --user {user}".format(user=user))
service("supervisord", "restart")

exec_cmd("sudo bench setup sudoers {user}".format(user=user))
10 changes: 9 additions & 1 deletion bench/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
import bench
import bench.utils

# imports - third party imports
from six import PY2


if PY2:
FRAPPE_BRANCH = "version-12"
else:
FRAPPE_BRANCH = "develop"

class TestBenchBase(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -76,7 +84,7 @@ def init_bench(self, bench_name, **kwargs):
frappe_tmp_path = "/tmp/frappe"

if not os.path.exists(frappe_tmp_path):
bench.utils.exec_cmd("git clone https://github.com/frappe/frappe --depth 1 --origin upstream {location}".format(location=frappe_tmp_path))
bench.utils.exec_cmd("git clone https://github.com/frappe/frappe -b {branch} --depth 1 --origin upstream {location}".format(branch=FRAPPE_BRANCH, location=frappe_tmp_path))

kwargs.update(dict(
python=sys.executable,
Expand Down
14 changes: 8 additions & 6 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import bench
import bench.utils
from bench.release import get_bumped_version
from bench.tests.test_base import TestBenchBase
from bench.tests.test_base import TestBenchBase, FRAPPE_BRANCH


class TestBenchInit(TestBenchBase):
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_install_app(self):
self.init_bench(bench_name)
bench.utils.exec_cmd("bench setup requirements --node", cwd=bench_path)
bench.utils.exec_cmd("bench build", cwd=bench_path)
bench.utils.exec_cmd("bench get-app erpnext", cwd=bench_path)
bench.utils.exec_cmd("bench get-app erpnext --branch {0}".format(FRAPPE_BRANCH), cwd=bench_path)

self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", "erpnext")))

Expand All @@ -109,10 +109,12 @@ def test_install_app(self):

# create and install app on site
self.new_site(site_name, bench_name)
bench.utils.exec_cmd("bench --site {0} install-app erpnext".format(site_name), cwd=bench_path)
installed_erpnext = not bench.utils.exec_cmd("bench --site {0} install-app erpnext".format(site_name), cwd=bench_path)

app_installed_on_site = subprocess.check_output(["bench", "--site", site_name, "list-apps"], cwd=bench_path).decode('utf8')
self.assertTrue("erpnext" in app_installed_on_site)

if installed_erpnext:
self.assertTrue("erpnext" in app_installed_on_site)


def test_remove_app(self):
Expand All @@ -134,11 +136,11 @@ def test_switch_to_branch(self):
bench_path = os.path.join(self.benches_path, "test-bench")
app_path = os.path.join(bench_path, "apps", "frappe")

bench.utils.exec_cmd("bench switch-to-branch version-12 frappe", cwd=bench_path)
bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path)
app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual("version-12", app_branch_after_switch)

bench.utils.exec_cmd("bench switch-to-branch develop frappe", cwd=bench_path)
bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path)
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual("develop", app_branch_after_second_switch)

Expand Down
2 changes: 1 addition & 1 deletion bench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def exec_cmd(cmd, cwd='.'):
import shlex
print("{0}$ {1}{2}".format(color.silver, cmd, color.nc))
cmd = shlex.split(cmd)
subprocess.call(cmd, cwd=cwd, universal_newlines=True)
return subprocess.call(cmd, cwd=cwd, universal_newlines=True)


def which(executable, raise_err = False):
Expand Down
5 changes: 4 additions & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ def run_playbook(playbook_name, sudo=False, extra_vars=None):
else:
cwd = os.path.join(os.path.expanduser('~'), 'bench')

success = subprocess.check_call(args, cwd=os.path.join(cwd, 'bench', 'playbooks'), stdout=log_stream, stderr=sys.stderr)
playbooks_locations = [os.path.join(cwd, 'bench', 'playbooks'), os.path.join(cwd, 'playbooks')]
playbooks_folder = [x for x in playbooks_locations if os.path.exists(x)][0]

success = subprocess.check_call(args, cwd=playbooks_folder, stdout=log_stream, stderr=sys.stderr)
return success


Expand Down

0 comments on commit 11c2ec6

Please sign in to comment.