Skip to content
Snippets Groups Projects
Commit fec9263f authored by gyulaid's avatar gyulaid
Browse files

Added install test

parent 65a9cb50
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ steps: ...@@ -6,7 +6,7 @@ steps:
- name: static-test - name: static-test
image: alpine/flake8 image: alpine/flake8
commands: commands:
- python3 -m flake8 --ignore E501,W503 - python3 -m flake8 --ignore E501,W503 alice-ci/src
- name: build - name: build
image: python image: python
...@@ -14,6 +14,15 @@ steps: ...@@ -14,6 +14,15 @@ steps:
- python3 -m pip install build - python3 -m pip install build
- python3 -m build alice-ci - 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 - name: publish
image: python image: python
environment: environment:
......
import alice from .cli import main
if __name__ == '__main__': if __name__ == '__main__':
alice.cli.main() main()
...@@ -15,22 +15,24 @@ class PythonRunner: ...@@ -15,22 +15,24 @@ class PythonRunner:
self.workdir = config["workdir"] self.workdir = config["workdir"]
self.virtual_dir = os.path.abspath(os.path.join(self.workdir, "venv")) self.virtual_dir = os.path.abspath(os.path.join(self.workdir, "venv"))
self.config = config self.config = config
PackageManager.getInstance().ensure("build") PackageManager.getInstance().ensure("virtualenv")
self.__init_venv() self.__init_venv()
def __init_venv(self): def __init_venv(self):
if os.name == "nt": # Windows if os.name == "nt": # Windows
self.vpython = os.path.join(self.virtual_dir, "Scripts", "python.exe") self.vpython = os.path.join(self.virtual_dir, "Scripts", "python.exe")
else: # Linux & Mac 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): if not os.path.exists(self.vpython):
logging.debug(f"[PythonRunner] Venv not found at {self.vpython}")
logging.info("[PythonRunner] Initializing venv") logging.info("[PythonRunner] Initializing venv")
with subprocess.Popen([sys.executable, "-m", "virtualenv", self.virtual_dir], with subprocess.Popen([sys.executable, "-m", "virtualenv", self.virtual_dir],
stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
p.wait() p.wait()
if p.returncode != 0: if p.returncode != 0:
sys.stdout.buffer.write(p.stderr.read()) sys.stdout.buffer.write(p.stderr.read())
sys.stdout.buffer.write(p.stdout.read())
raise RunnerError("[PythonRunner] Could not create virtualenv") raise RunnerError("[PythonRunner] Could not create virtualenv")
else: else:
logging.info(f"[PythonRunner] Virtualenv initialized at {self.virtual_dir}") logging.info(f"[PythonRunner] Virtualenv initialized at {self.virtual_dir}")
......
...@@ -35,6 +35,7 @@ class PackageManager: ...@@ -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()))) 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: for name, version in installed:
packages[name] = parse_version(version) packages[name] = parse_version(version)
logging.debug(f"[PackageManager] Picked up packages: {packages}")
return packages return packages
def ensure_more(self, package_list, executable=sys.executable): def ensure_more(self, package_list, executable=sys.executable):
...@@ -51,6 +52,7 @@ class PackageManager: ...@@ -51,6 +52,7 @@ class PackageManager:
# Assumption: there are more hits in the long run, than misses # Assumption: there are more hits in the long run, than misses
def ensure(self, package_string, executable=sys.executable): def ensure(self, package_string, executable=sys.executable):
if not self.__has_package(package_string): if not self.__has_package(package_string):
logging.info(f"[PackageManager] Installing {package_string}")
command = [executable, "-m", "pip", "install", package_string] command = [executable, "-m", "pip", "install", package_string]
with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
p.wait() p.wait()
...@@ -58,6 +60,8 @@ class PackageManager: ...@@ -58,6 +60,8 @@ class PackageManager:
sys.stdout.buffer.write(p.stderr.read()) sys.stdout.buffer.write(p.stderr.read())
raise(RunnerError(f"[PackageManager] Could not install dependencies ({p.returncode})")) raise(RunnerError(f"[PackageManager] Could not install dependencies ({p.returncode})"))
self.package_list = self.__get_packages() self.package_list = self.__get_packages()
else:
logging.info(f"[PackageManager] {package_string} already installed")
def __has_package(self, package_string): def __has_package(self, package_string):
package_data = re.split("==|>|>=|<|<=", package_string) package_data = re.split("==|>|>=|<|<=", package_string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment