Jaypore CI

> Jaypore CI: Minimal, Offline, Local CI system.
Log | Files | Refs | README

commit 4593eec67c679651edca5cea92e63fb393eba49d
Author: arjoonn sharma <arjoonn@midpathsoftware.com>
Date:   Sat, 26 Nov 2022 16:18:32 +0530

define graphs in py

Diffstat:
ADockerfile | 8++++++++
AREADME.md | 15+++++++++++++++
Acicd/__init__.py | 13+++++++++++++
Acompose/cicd.yml | 0
Ajaypore_ci/__init__.py | 1+
Ajaypore_ci/jci.py | 1+
Ajaypore_ci/primitives.py | 11+++++++++++
Apyproject.toml | 15+++++++++++++++
Atests/__init__.py | 0
Atests/test_jaypore_ci.py | 5+++++
10 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -0,0 +1,8 @@ +from python:3.11 +run python3 -m pip install --upgrade pip +run python3 -m pip install poetry +workdir /app +add pyproject.toml . +add poetry.lock . +run poetry export --with dev > req.txt +run python3 -m pip install -r req.txt diff --git a/README.md b/README.md @@ -0,0 +1,15 @@ +# Jaypore CI + +## Ideas + +1. Use developer laptop as a CI runner + - Cloud runners should be added on demand / only if needed. +2. Report logs / status in any pull request tracker as a comment. + - Store files / etc in special git branches + +## Usage + +1. Add `jaypore_ci` as python dependency in your project. +2. Define pipelines in Python however you want. See `cicd` folder in current project for examples. +3. Add a docker-compose file to add a runner for the project. + diff --git a/cicd/__init__.py b/cicd/__init__.py @@ -0,0 +1,13 @@ +from jaypore_ci import jci + +pipe = jci.Pipeline(image="python:3.11", timeout="15m") +assert pipe.job("python3 -m cicd.commit_msg_has_issue_number").run().ok() +assert ( + pipe.parallel( + pipe.job("python3 -m black ."), + pipe.job("python3 -m pylint src"), + pipe.job("python3 -m pytest tests"), + ) + .run() + .ok() +) diff --git a/compose/cicd.yml b/compose/cicd.yml diff --git a/jaypore_ci/__init__.py b/jaypore_ci/__init__.py @@ -0,0 +1 @@ +__version__ = '0.1.0' diff --git a/jaypore_ci/jci.py b/jaypore_ci/jci.py @@ -0,0 +1 @@ +from jaypore_ci.primitives import Pipeline, Job diff --git a/jaypore_ci/primitives.py b/jaypore_ci/primitives.py @@ -0,0 +1,11 @@ +class Pipeline: + def __init__(self, image="python:3.11", timeout="15m"): + self.image = image + self.timeout = timeout + self.__history__ = [] + + def job(self, *commands, *, image=None, timeout=None): + return self + + def ok(self): + return self.last_command.exit_code == 0 diff --git a/pyproject.toml b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "jaypore_ci" +version = "0.1.0" +description = "" +authors = ["arjoonn sharma <arjoonn.94@gmail.com>"] + +[tool.poetry.dependencies] +python = "^3.8" + +[tool.poetry.dev-dependencies] +pytest = "^5.2" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/tests/__init__.py b/tests/__init__.py diff --git a/tests/test_jaypore_ci.py b/tests/test_jaypore_ci.py @@ -0,0 +1,5 @@ +from jaypore_ci import __version__ + + +def test_version(): + assert __version__ == '0.1.0'