mypy compliant
This commit is contained in:
+18
-29
@@ -5,7 +5,7 @@ from dotenv import load_dotenv
|
||||
import logging
|
||||
import os
|
||||
|
||||
from utils import clone_repository, load_runner_script
|
||||
from utils import clone_repository, execute_runner_script
|
||||
from setup_logging import setup_logging
|
||||
from gitea_request import GiteaRequest
|
||||
|
||||
@@ -60,34 +60,23 @@ def handle_event(request: GiteaRequest):
|
||||
status_code=200,
|
||||
detail="no runner_script.yml in repository root"
|
||||
)
|
||||
# load runner script
|
||||
runner_script = load_runner_script(path=runner_script_path)
|
||||
# determine pipeline to run
|
||||
if branch_name not in runner_script.pipelines.keys():
|
||||
# get default pipeline
|
||||
if 'default' not in runner_script.pipelines.keys():
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail='no pipelines defined in runner_script.yml'
|
||||
)
|
||||
pipeline = runner_script.pipelines['default']
|
||||
else:
|
||||
# get custom pipeline
|
||||
pipeline = runner_script.pipelines[branch_name]
|
||||
logging.info(f'running pipeline {pipeline.name}')
|
||||
# TODO: create virtualenv?
|
||||
# install requirements
|
||||
assert pipeline.requirements is not None
|
||||
requirements_path = local_repo_dir / pipeline.requirements
|
||||
os.system(f'pip install -r {requirements_path}')
|
||||
for cmd in pipeline.script:
|
||||
try:
|
||||
os.system(cmd)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
detail=f'failed running {cmd}: {e}'
|
||||
)
|
||||
# execute runner script
|
||||
logging.info('rexecuting runner script')
|
||||
execute_runner_script(path=runner_script_path)
|
||||
|
||||
# # TODO: create virtualenv?
|
||||
# # install requirements
|
||||
# assert pipeline.requirements is not None
|
||||
# requirements_path = local_repo_dir / pipeline.requirements
|
||||
# os.system(f'pip install -r {requirements_path}')
|
||||
# for cmd in pipeline.script:
|
||||
# try:
|
||||
# os.system(cmd)
|
||||
# except Exception as e:
|
||||
# raise HTTPException(
|
||||
# status_code=503,
|
||||
# detail=f'failed running {cmd}: {e}'
|
||||
# )
|
||||
|
||||
# send response
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user