diff --git a/.drone.yml b/.drone.yml index 7fe5a6705cb4245c8300d08026e696af252ed349..a4ed841a269a23b93de0ca2329055dbfe074c94c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,7 +6,7 @@ steps: - name: static-test image: alpine/flake8 commands: - - python3 -m flake8 --ignore E501,W503 + - python3 -m flake8 --ignore E501,W503 alice-ci/src - name: build image: python @@ -14,6 +14,15 @@ steps: - python3 -m pip install build - python3 -m build alice-ci +- name: test + image: python + environment: + PYPIUSER: USER + PYPIPASS: PASS + commands: + - python3 -m pip install alice-ci/dist/alice_ci*.whl + - alice -i ci-examples/full.yaml -vv + - name: publish image: python environment: diff --git a/alice-ci/src/alice/__main__.py b/alice-ci/src/alice/__main__.py index d5cb563b7975acc9e7ca09afe24bab55abb9e758..ef588d47d0689a743d94d92137d41f67d35f539a 100644 --- a/alice-ci/src/alice/__main__.py +++ b/alice-ci/src/alice/__main__.py @@ -1,4 +1,4 @@ -import alice +from .cli import main if __name__ == '__main__': - alice.cli.main() + main() diff --git a/alice-ci/src/alice/runners/pythonrunner.py b/alice-ci/src/alice/runners/pythonrunner.py index ea1351ab81298e7c679ed2ef94e64d66f14026a4..c2854bd7694d7fa5cf6287befee580686e378043 100644 --- a/alice-ci/src/alice/runners/pythonrunner.py +++ b/alice-ci/src/alice/runners/pythonrunner.py @@ -15,22 +15,24 @@ class PythonRunner: self.workdir = config["workdir"] self.virtual_dir = os.path.abspath(os.path.join(self.workdir, "venv")) self.config = config - PackageManager.getInstance().ensure("build") + PackageManager.getInstance().ensure("virtualenv") self.__init_venv() def __init_venv(self): if os.name == "nt": # Windows self.vpython = os.path.join(self.virtual_dir, "Scripts", "python.exe") else: # Linux & Mac - self.vpython = os.path.join(self.virtual_dir, "bin", "python3") + self.vpython = os.path.join(self.virtual_dir, "bin", "python") if not os.path.exists(self.vpython): + logging.debug(f"[PythonRunner] Venv not found at {self.vpython}") logging.info("[PythonRunner] Initializing venv") with subprocess.Popen([sys.executable, "-m", "virtualenv", self.virtual_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: p.wait() if p.returncode != 0: sys.stdout.buffer.write(p.stderr.read()) + sys.stdout.buffer.write(p.stdout.read()) raise RunnerError("[PythonRunner] Could not create virtualenv") else: logging.info(f"[PythonRunner] Virtualenv initialized at {self.virtual_dir}") diff --git a/alice-ci/src/alice/runners/pyutils.py b/alice-ci/src/alice/runners/pyutils.py index e37fb604100cf9ee6ded773110fd1b7e5d483df7..d8bb685a1d131326c08f61527a51a4cbfc6f4105 100644 --- a/alice-ci/src/alice/runners/pyutils.py +++ b/alice-ci/src/alice/runners/pyutils.py @@ -35,6 +35,7 @@ class PackageManager: installed = list(map(lambda x: x.decode("UTF-8").split("=="), filter(lambda x: b'==' in x, p.stdout.read().splitlines()))) for name, version in installed: packages[name] = parse_version(version) + logging.debug(f"[PackageManager] Picked up packages: {packages}") return packages def ensure_more(self, package_list, executable=sys.executable): @@ -51,6 +52,7 @@ class PackageManager: # Assumption: there are more hits in the long run, than misses def ensure(self, package_string, executable=sys.executable): if not self.__has_package(package_string): + logging.info(f"[PackageManager] Installing {package_string}") command = [executable, "-m", "pip", "install", package_string] with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: p.wait() @@ -58,6 +60,8 @@ class PackageManager: sys.stdout.buffer.write(p.stderr.read()) raise(RunnerError(f"[PackageManager] Could not install dependencies ({p.returncode})")) self.package_list = self.__get_packages() + else: + logging.info(f"[PackageManager] {package_string} already installed") def __has_package(self, package_string): package_data = re.split("==|>|>=|<|<=", package_string)