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

Fix charsh with missing env in config

parent fdc5982a
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,5 @@ from alice.runners.pythonrunner import PythonRunner
from alice.exceptions import NonZeroRetcode
from alice.exceptions import RunnerError
from alice.exceptions import ConfigException
from alice.__main__ import main
name = "alice"
\ No newline at end of file
......@@ -42,11 +42,13 @@ class PythonRunner():
if "dependencies" in config:
for dependency in config["dependencies"]:
# TODO: Check what happens with fixed version
with subprocess.Popen([self.vpython, "-m", "pip", "install", dependency, "--upgrade"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
command = [self.vpython, "-m", "pip", "install", dependency, "--upgrade"]
with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
p.wait()
if p.returncode != 0:
sys.stdout.buffer.write(p.stderr.read())
raise(RunnerError(f"PythonRunner: Could not install dependency: {dependency} ({p.returncode})"))
if "env" in config:
for env_var in config["env"]:
self.env_vars[env_var["name"]] = env_var["value"]
if "workdir" in config and config["workdir"] is not None:
......@@ -60,7 +62,6 @@ class PythonRunner():
base_name = os.path.basename(item)
if os.path.isdir(dir):
item_parts = base_name.split("*")
print(item_parts)
for file in os.listdir(dir):
# TODO: Fix ordering! A*B = B*A = AB*
if item_parts[0] in file and item_parts[1] in file:
......
......@@ -8,19 +8,23 @@ class ConfigParser:
with open(file_path) as f:
self.config = yaml.safe_load(f)
self.factory = factory
if "runners" in self.config:
if "global" in self.config["runners"]:
self.factory.set_globals(self.__gen_globals())
if "runners" in self.config:
self.factory.update_runners(self.config["runners"])
self.jobs = self.__get_jobs()
# Initialize env, workdir if not present
def __gen_globals(self):
globals = self.config["runners"]["global"]
if "env" not in globals:
globals["env"] = []
if "workdir" not in globals:
globals["workdir"] = None
globals = {
"env": [],
"workdir": None
}
if "runners" in self.config:
if "global" in self.config["runners"]:
if "env" in self.config["runners"]["global"]:
globals["env"] = self.config["runners"]["global"]["env"]
if "workdir" in self.config["runners"]["global"]:
globals["workdir"] = self.config["runners"]["global"]["workdir"]
return globals
def __get_jobs(self):
......
runners:
python:
dependencies:
- flake8
- build
- twine
jobs:
- name: selfcheck
type: python
workdir: ci
commands:
- "-m flake8 --ignore E501 --exclude venv"
- name: lint
type: python
workdir: alice-ci/src
commands:
- "-m flake8 --ignore E501"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment