Jaypore CI

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

commit 76da48174276d7738f4b2c3e44f753fedc1211f0
parent 0db01dc8bb59a6d6a44ec775152e60036b9b47ec
Author: arjoonn <arjoonn@noreply.localhost>
Date:   Thu,  2 Feb 2023 08:47:19 +0000

Jobs can report custom metrics (!33)

Branch auto created by JayporeCI

```jayporeci
╔ 🟢 : JayporeCI       [sha 6c9fb44bfa]
┏━ Docker
┃
┃ 🟢 : Jci             [c0261bc7]  10: 5
┃ 🟢 : JciEnv          [a64d0fe2]   9:58
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Jobs
┃
┃ 🟢 : black           [55eba111]   0: 0
┃ 🟢 : pylint          [2091da71]   0: 9
┃ 🟢 : pytest          [660a559d]   0: 2 [Cov: 65%  ]
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Publish
┃
┃ 🟢 : DockerHubJci    [718e5c63]   1: 0
┃ 🟢 : DockerHubJcienv [0c9cdd9c]   1:13
┃ 🟢 : PublishDocs     [de820ab2]   0: 6
┃ 🟢 : PublishPypi     [d512cefc]   0: 6
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
```

Co-authored-by: arjoonn sharma <arjoonn@midpathsoftware.com>
Reviewed-on: https://gitea.midpathsoftware.com/midpath/jaypore_ci/pulls/33

Diffstat:
M.gitignore | 1+
Mcicd/run_tests.sh | 1+
Mdocs/source/index.rst | 8+++++++-
Mjaypore_ci/reporters/text.py | 13+++++++++++++
Mpyproject.toml | 2+-
5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -3,3 +3,4 @@ *.age dist/ .hypothesis/ +.coverage diff --git a/cicd/run_tests.sh b/cicd/run_tests.sh @@ -9,6 +9,7 @@ main() { python -m coverage run --source=. -m pytest -vv coverage html coverage report + echo "Cov: $(coverage report --format=total)%" > "/jaypore_ci/run/pytest.txt" } (main) diff --git a/docs/source/index.rst b/docs/source/index.rst @@ -74,7 +74,7 @@ This would produce a CI report like:: ┃ ┃ 🟢 : Black [ffcda0a9] 0: 3 ┃ 🟢 : Pylint [2417ad58] 0: 9 - ┃ 🟢 : PyTest [28d4985f] 0:15 + ┃ 🟢 : PyTest [28d4985f] 0:15 [Cov: 65% ] ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - `edcb193bae` is the SHA that the report is for. @@ -83,6 +83,12 @@ This would produce a CI report like:: - `Black`, `Pylint`, and `PyTest` are the job names. - `[ffcda0a9]` is the docker container ID for that job. - `1: 3` is the time taken by the job. +- `[Cov: 65% ]` is custom reporting done by the job. Any job can create a file + `/jaypore_ci/run/<job name>.txt` and the first 10 characters from that file + will be displayed in the report. + - Although this is used for coverage reports you could potentially use this for anything you want. A few ideas: + - You could report error codes here to indicate WHY a job failed. + - Report information about artifacts created. To see the pipelines on your machine you can run: diff --git a/jaypore_ci/reporters/text.py b/jaypore_ci/reporters/text.py @@ -20,6 +20,11 @@ def __get_time_format__(job): return time +def get_job_report(jobname): + with open(f"/jaypore_ci/run/{jobname}.txt", "r", encoding="utf-8") as fl: + return fl.read() + + __ST_MAP__ = { Status.RUNNING: "🔵", Status.FAILED: "🔴", @@ -34,6 +39,7 @@ class Text(Reporter): """ max_name = max(len(job.name) for job in pipeline.jobs.values()) max_name = max(max_name, len("jayporeci")) + max_report = 10 name = ("JayporeCI" + " " * max_name)[:max_name] graph = [ "", @@ -59,6 +65,13 @@ class Text(Reporter): status = __ST_MAP__.get(n.status, "🟡") run_id = f"{n.run_id}"[:8] if n.run_id is not None else "" graph += [f"┃ {status} : {name} [{run_id:<8}] {__get_time_format__(n)}"] + try: + report = get_job_report(n.name) + report = " ".join(report.strip().split()) + report = (report + " " * max_report)[:max_report] + graph[-1] += f" [{report}]" + except FileNotFoundError: + pass if n.parents: graph[-1] += f" ❮-- {n.parents}" graph += [closer] diff --git a/pyproject.toml b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "jaypore_ci" -version = "0.2.3" +version = "0.2.4" description = "" authors = ["arjoonn sharma <arjoonn.94@gmail.com>"]