Skip to content

Commit

Permalink
Merge pull request #1347 from gavindsouza/ci-reduce-time
Browse files Browse the repository at this point in the history
ci: Reduce test builds' runtimes
  • Loading branch information
gavindsouza committed Aug 1, 2022
2 parents 6d67502 + 01b7759 commit ec9d858
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
15 changes: 10 additions & 5 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, path):

@property
def python(self) -> str:
return get_env_cmd("python3", bench_path=self.name)
return get_env_cmd("python", bench_path=self.name)

@property
def shallow_clone(self) -> bool:
Expand Down Expand Up @@ -352,15 +352,18 @@ def env(self, python="python3"):

if not os.path.exists(self.bench.python):
if virtualenv:
self.run(f"{virtualenv} {quiet_flag} env -p {python}")
self.run(f"{virtualenv} {quiet_flag} env -p {python}", cwd=self.bench.name)
else:
venv = get_venv_path(verbose=verbose, python=python)
self.run(f"{venv} env")
self.run(f"{venv} env", cwd=self.bench.name)

self.pip()

if os.path.exists(frappe):
self.run(f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {frappe}")
self.run(
f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {frappe}",
cwd=self.bench.name,
)

@step(title="Setting Up Bench Config", success="Bench Config Set Up")
def config(self, redis=True, procfile=True):
Expand Down Expand Up @@ -388,7 +391,9 @@ def pip(self, verbose=False):
verbose = bench.cli.verbose or verbose
quiet_flag = "" if verbose else "--quiet"

return self.run(f"{self.bench.python} -m pip install {quiet_flag} --upgrade pip")
return self.run(
f"{self.bench.python} -m pip install {quiet_flag} --upgrade pip", cwd=self.bench.name
)

def logging(self):
from bench.utils import setup_logging
Expand Down
15 changes: 7 additions & 8 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def test_new_site(self):
site_config_path = os.path.join(site_path, "site_config.json")

self.init_bench(bench_name)
exec_cmd("bench setup requirements --node", cwd=bench_path)
self.new_site(site_name, bench_name)

self.assertTrue(os.path.exists(site_path))
Expand All @@ -99,7 +98,7 @@ def test_new_site(self):
def test_get_app(self):
self.init_bench("test-bench")
bench_path = os.path.join(self.benches_path, "test-bench")
exec_cmd(f"bench get-app {TEST_FRAPPE_APP}", cwd=bench_path)
exec_cmd(f"bench get-app {TEST_FRAPPE_APP} --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP)))
app_installed_in_env = TEST_FRAPPE_APP in subprocess.check_output(
["bench", "pip", "freeze"], cwd=bench_path
Expand All @@ -111,7 +110,7 @@ def test_get_app_resolve_deps(self):
FRAPPE_APP = "healthcare"
self.init_bench("test-bench")
bench_path = os.path.join(self.benches_path, "test-bench")
exec_cmd(f"bench get-app {FRAPPE_APP} --resolve-deps", cwd=bench_path)
exec_cmd(f"bench get-app {FRAPPE_APP} --resolve-deps --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", FRAPPE_APP)))

states_path = os.path.join(bench_path, "sites", "apps.json")
Expand All @@ -128,9 +127,9 @@ def test_install_app(self):
bench_path = os.path.join(self.benches_path, "test-bench")

self.init_bench(bench_name)
exec_cmd("bench setup requirements --node", cwd=bench_path)
exec_cmd("bench build", cwd=bench_path)
exec_cmd(f"bench get-app {TEST_FRAPPE_APP} --branch master", cwd=bench_path)
exec_cmd(
f"bench get-app {TEST_FRAPPE_APP} --branch master --skip-assets", cwd=bench_path
)

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

Expand Down Expand Up @@ -158,9 +157,9 @@ def test_remove_app(self):
self.init_bench("test-bench")
bench_path = os.path.join(self.benches_path, "test-bench")

exec_cmd("bench setup requirements --node", cwd=bench_path)
exec_cmd(
f"bench get-app {TEST_FRAPPE_APP} --branch master --overwrite", cwd=bench_path
f"bench get-app {TEST_FRAPPE_APP} --branch master --overwrite --skip-assets",
cwd=bench_path,
)
exec_cmd(f"bench remove-app {TEST_FRAPPE_APP}", cwd=bench_path)

Expand Down

0 comments on commit ec9d858

Please sign in to comment.