From bfeffd0cc764ba9fac7418978ffc77cc7ddb865d Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 14 Dec 2022 22:28:46 +1100 Subject: [PATCH] Docker fix final 2 (#4049) * Append correct python path if not present (only during testing) * Add a bunch more debug info * Display docker compose version * More unit test fixes * More debug info * Ensure correct python path is included for docker build (only for testing) * Remove debug statements * Don't run docker workflow on PR --- .github/workflows/docker.yaml | 5 +---- InvenTree/InvenTree/config.py | 7 ------- InvenTree/InvenTree/settings.py | 10 +++++----- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 05e068b6c9..f9a6779656 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -21,10 +21,6 @@ on: branches: - 'master' - pull_request: - branches: - - 'master' - jobs: # Build the docker image @@ -73,6 +69,7 @@ jobs: test -f data/secret_key.txt - name: Run Unit Tests run: | + docker-compose --version docker-compose run inventree-dev-server invoke test --disable-pty docker-compose down - name: Set up QEMU diff --git a/InvenTree/InvenTree/config.py b/InvenTree/InvenTree/config.py index fe9a4e4914..27722435f3 100644 --- a/InvenTree/InvenTree/config.py +++ b/InvenTree/InvenTree/config.py @@ -59,13 +59,6 @@ def get_config_file(create=True) -> Path: def load_config_data() -> map: """Load configuration data from the config file.""" - import sys - - print("load_config_data()") - print("- cwd:", os.getcwd()) - print("- exe:", sys.executable) - print("- path:", sys.path) - import yaml cfg_file = get_config_file() diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index bd8bba0756..23f889da7c 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -33,13 +33,13 @@ TESTING = 'test' in sys.argv # Note: The following fix is "required" for docker build workflow # Note: 2022-12-12 still unsure why... -if TESTING: +if TESTING and os.getenv('INVENTREE_DOCKER'): # Ensure that sys.path includes global python libs - python_dir = os.path.dirname(sys.executable) - python_lib = os.path.join(python_dir, "lib", "site-packages") + site_packages = '/usr/local/lib/python3.9/site-packages' - if python_lib not in sys.path: - sys.path.append(python_lib) + if site_packages not in sys.path: + print("Adding missing site-packages path:", site_packages) + sys.path.append(site_packages) # Are environment variables manipulated by tests? Needs to be set by testing code TESTING_ENV = False