Skip to content

Commit

Permalink
Speed up e2e-tests locally by skipping environment setup (#3527)
Browse files Browse the repository at this point in the history
* speed up e2etest locally by avoid setting up env

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* minor bug fix

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

---------

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam authored Jan 19, 2024
1 parent 3d14cea commit db31ee6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ show-coverage:
e2e-tests:
behave --tags=-skip

e2e-tests-fast: export BEHAVE_LOCAL_ENV=TRUE
e2e-tests-fast:
behave --tags=-skip --no-capture

pip-compile:
pip-compile -q -o -

Expand Down
48 changes: 30 additions & 18 deletions features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import shutil
import subprocess
import tempfile
import venv
from pathlib import Path
Expand Down Expand Up @@ -93,24 +94,35 @@ def _create_tmp_dir() -> Path:


def _setup_minimal_env(context):
kedro_install_venv_dir = _create_new_venv()
context.kedro_install_venv_dir = kedro_install_venv_dir
context = _setup_context_with_venv(context, kedro_install_venv_dir)
call(
[
context.python,
"-m",
"pip",
"install",
"-U",
# pip==23.2 breaks pip-tools<7.0, and pip-tools>=7.0 does not support Python 3.7
# pip==23.3 breaks dependency resolution
"pip>=21.2,<23.2",
],
env=context.env,
)
call([context.python, "-m", "pip", "install", "-e", "."], env=context.env)
return context
if os.environ.get("BEHAVE_LOCAL_ENV"):
output = subprocess.check_output(
["which", "kedro"] # noqa: S603, S607
) # equivalent run "which kedro"
output = output.strip().decode("utf8")
kedro_install_venv_dir = Path(output).parent.parent
context.kedro_install_venv_dir = kedro_install_venv_dir
context = _setup_context_with_venv(context, kedro_install_venv_dir)
return context
else:
kedro_install_venv_dir = _create_new_venv()
context.kedro_install_venv_dir = kedro_install_venv_dir
context = _setup_context_with_venv(context, kedro_install_venv_dir)

call(
[
context.python,
"-m",
"pip",
"install",
"-U",
# pip==23.2 breaks pip-tools<7.0, and pip-tools>=7.0 does not support Python 3.7
# pip==23.3 breaks dependency resolution
"pip>=21.2,<23.2",
],
env=context.env,
)
call([context.python, "-m", "pip", "install", "-e", "."], env=context.env)
return context


def _install_project_requirements(context):
Expand Down

0 comments on commit db31ee6

Please sign in to comment.