Jaypore CI

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

commit 1b581a9256eac7b3c4dc2d2f15c45f451e9445c9
parent 195af6d3cd2d95e8c45972fd9cb3d33eaf67a44d
Author: arjoonn <arjoonn@noreply.localhost>
Date:   Fri, 23 Dec 2022 15:37:15 +0000

clean_jci_logs (!14)

Diffstat:
Mcicd/build_and_publish_docs.sh | 7+------
Mjaypore_ci/jci.py | 20+++++++-------------
2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/cicd/build_and_publish_docs.sh b/cicd/build_and_publish_docs.sh @@ -19,9 +19,4 @@ publish() { } (build) -if [ $1 == "main" ] -then - (publish) -else - echo "Not publishing since branch is: $1" -fi +(publish) diff --git a/jaypore_ci/jci.py b/jaypore_ci/jci.py @@ -49,8 +49,9 @@ def __clean_logs__(logs): """ Clean logs so that they don't have HTML/ANSI color codes in them. """ - logs = logs.replace("<", r"\<").replace(">", r"\>") - return ansi_escape.sub("", logs) + for old, new in [("<", r"\<"), (">", r"\>"), ("`", '"'), ("\r", "\n")]: + logs = logs.replace(old, new) + return [line.strip() for line in ansi_escape.sub("", logs).split("\n")] class Job: # pylint: disable=too-many-instance-attributes @@ -146,7 +147,7 @@ class Job: # pylint: disable=too-many-instance-attributes job_name=self.name, ) logs = job_run.stdout.decode() - self.logs["stdout"] = __clean_logs__(logs).split("\n") + self.logs["stdout"] = __clean_logs__(logs) self.status = Status.FAILED else: self.logging().info("Trigger called but job already running") @@ -168,15 +169,7 @@ class Job: # pylint: disable=too-many-instance-attributes self.status = Status.RUNNING if not self.is_service else Status.PASSED else: self.status = Status.PASSED if exit_code == 0 else Status.FAILED - logs = __clean_logs__(logs) - log_lines = logs.split("\n") - for line in log_lines[len(self.logs["stdout"]) :]: - self.logging().debug( - f">>> {line.strip()}", - job_name=self.name, - run_id=self.run_id, - ) - self.logs["stdout"] = log_lines + self.logs["stdout"] = __clean_logs__(logs) if with_update_report: self.update_report() @@ -372,7 +365,8 @@ flowchart {self.graph_direction} """ all_logs = [] fake_job = namedtuple("fake_job", "name logs")( - "JayporeCi", {"stdout": jaypore_logs} + "JayporeCi", + {"stdout": __clean_logs__("\n".join(jaypore_logs))}, ) for job in [fake_job] + list(self.jobs.values()): job_log = []