Compare commits
5
Commits
3187248fb9
...
87a738461c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a738461c | ||
|
|
40c9b7442d | ||
|
|
c1aa6f3c41 | ||
|
|
9102d03ef4 | ||
|
|
5c21aa767f |
+5
-2
@@ -6,7 +6,7 @@ import logging
|
|||||||
from typing import List
|
from typing import List
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from utils import clone_repository
|
from utils import clone_repository, load_runner_script
|
||||||
from setup_logging import setup_logging
|
from setup_logging import setup_logging
|
||||||
from gitea_request import GiteaRequest
|
from gitea_request import GiteaRequest
|
||||||
|
|
||||||
@@ -59,7 +59,10 @@ def handle_event(request: GiteaRequest):
|
|||||||
detail="no runner_script.yml in repository root"
|
detail="no runner_script.yml in repository root"
|
||||||
)
|
)
|
||||||
# load runner commands
|
# load runner commands
|
||||||
|
runner_script = load_runner_script(path=runner_script_path)
|
||||||
|
for pipeline_name, pipeline_step in runner_script.items():
|
||||||
|
print(pipeline_name)
|
||||||
|
print(pipeline_step)
|
||||||
|
|
||||||
# send response
|
# send response
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
from typing import List, Dict
|
||||||
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
class Pipeline(BaseModel):
|
||||||
|
name: str
|
||||||
|
requirements: str
|
||||||
|
script: List[str]
|
||||||
|
|
||||||
|
class RunnerScript(BaseModel):
|
||||||
|
pipelines: List[Dict[str, Pipeline]]
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
path = Path(__file__).parent.parent / 'runner_script.yml'
|
||||||
|
with open(path, 'r') as fh:
|
||||||
|
script = yaml.safe_load(fh)
|
||||||
|
runner_script = RunnerScript.parse_obj(script)
|
||||||
|
print(runner_script)
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
from pydantic import AnyHttpUrl
|
from pydantic import AnyHttpUrl
|
||||||
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from git import Repo
|
from git import Repo
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
|
import yaml
|
||||||
|
from runner_script import RunnerScript
|
||||||
|
|
||||||
def clone_repository(repo_url: AnyHttpUrl) -> Path:
|
def clone_repository(repo_url: AnyHttpUrl) -> Path:
|
||||||
# extract repo name
|
# extract repo name
|
||||||
@@ -19,3 +22,11 @@ def clone_repository(repo_url: AnyHttpUrl) -> Path:
|
|||||||
Repo.clone_from(url=repo_url, to_path=dst_dir)
|
Repo.clone_from(url=repo_url, to_path=dst_dir)
|
||||||
logging.debug('finished')
|
logging.debug('finished')
|
||||||
return dst_dir
|
return dst_dir
|
||||||
|
|
||||||
|
def load_runner_script(path: Path) -> RunnerScript:
|
||||||
|
assert path.exists()
|
||||||
|
with open(path, 'r') as fh:
|
||||||
|
script = yaml.safe_load(fh)
|
||||||
|
runner_script = RunnerScript.parse_obj(script)
|
||||||
|
return runner_script
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ pydantic==1.10.11
|
|||||||
Pygments==2.15.1
|
Pygments==2.15.1
|
||||||
python-dateutil==2.8.2
|
python-dateutil==2.8.2
|
||||||
python-dotenv==1.0.0
|
python-dotenv==1.0.0
|
||||||
|
PyYAML==6.0
|
||||||
pyzmq==25.1.0
|
pyzmq==25.1.0
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
smmap==5.0.0
|
smmap==5.0.0
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ uvicorn==0.16.0
|
|||||||
fastapi==0.99.1
|
fastapi==0.99.1
|
||||||
GitPython==3.1.31
|
GitPython==3.1.31
|
||||||
python-dotenv==1.0.0
|
python-dotenv==1.0.0
|
||||||
|
PyYAML==6.0
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
definitions:
|
||||||
|
steps:
|
||||||
|
step: &step-test
|
||||||
|
name: test
|
||||||
|
requirements: req-prod.txt
|
||||||
|
script:
|
||||||
|
- command arg1 arg2
|
||||||
|
- command2 arg1 arg2
|
||||||
|
|
||||||
|
pipelines:
|
||||||
|
- default:
|
||||||
|
<<: *step-test
|
||||||
Reference in New Issue
Block a user