: nply/minci

commit f75b4eaa76f36040373beed818145255102d7a0f
parent f38fcc1e22279e006186e90bed5f09ad9a6d5f89
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Sep 2026 01:39:03 +0530

Render running jobs distinctly
2 files changed, 49 insertions(+), 15 deletions(-)
M
main.c
|
63
++++++++++++++++++++++++++++++++++++++++++++++++---------------
M
minci.css
|
1
+
diff --git a/main.c b/main.c
@@ -306,6 +306,24 @@ get_html_header(struct khtmlreq *req, const char *classes,
 	khtml_closeelem(req, 1); /* header */
 }
 
+static const char *
+get_status_class(const char *status, int detail)
+{
+
+	if (strcmp(status, "pass") == 0)
+		return detail ? "report-success" : "report-pass";
+	if (strcmp(status, "running") == 0)
+		return "report-running";
+	return detail ? "report-failure" : "report-fail";
+}
+
+static int
+is_running(const struct job *p)
+{
+
+	return strcmp(p->status, "running") == 0 || p->finish == 0;
+}
+
 static void
 get_html_artifact(const struct artifact *p, void *arg)
 {

@@ -344,8 +362,7 @@ get_html_job(const struct job *p, void *arg)
 	khtml_attr(&r->html, KELEM_DIV, KATTR_CLASS,
 		"cell report-status", KATTR__MAX);
 	khtml_attr(&r->html, KELEM_SPAN, KATTR_CLASS,
-		strcmp(p->status, "pass") == 0 ? "report-pass" : "report-fail",
-		KATTR__MAX);
+		get_status_class(p->status, 0), KATTR__MAX);
 	khtml_puts(&r->html, p->status);
 	khtml_closeelem(&r->html, 1);
 	khtml_closeelem(&r->html, 1);

@@ -754,13 +771,22 @@ get_single_html(struct kreq *r, const struct report *p)
 	free(urlcommit);
 }
 
+struct jobstate {
+	int fail;
+	int running;
+	int jobs;
+};
+
 static void
 count_job(const struct job *p, void *arg)
 {
-	int *fail = arg;
+	struct jobstate *state = arg;
 
-	if (strcmp(p->status, "pass"))
-		*fail = 1;
+	state->jobs++;
+	if (is_running(p))
+		state->running = 1;
+	else if (strcmp(p->status, "pass"))
+		state->fail = 1;
 }
 
 static void

@@ -769,7 +795,10 @@ get_run_row(const struct run *p, void *arg)
 	struct runreq *r = arg;
 	struct tm tm;
 	char datebuf[32], commitshort[8], *urlrun, *urlproj;
-	int fail = 0;
+	struct jobstate state;
+	const char *status;
+
+	memset(&state, 0, sizeof(struct jobstate));
 
 	urlrun = khttp_urlpartx(r->r->pname,
 		ksuffixes[KMIME_TEXT_HTML], pages[PAGE_INDEX],

@@ -786,12 +815,13 @@ get_run_row(const struct run *p, void *arg)
 	khtml_closeelem(r->html, 1);
 	khtml_closeelem(r->html, 1);
 
-	db_job_iterate_byrun(r->r->arg, count_job, &fail, p->id);
+	db_job_iterate_byrun(r->r->arg, count_job, &state, p->id);
+	status = state.running ? "running" : state.fail ? "fail" : "pass";
 	khtml_attr(r->html, KELEM_DIV, KATTR_CLASS,
 		"cell report-status", KATTR__MAX);
 	khtml_attr(r->html, KELEM_SPAN, KATTR_CLASS,
-		fail ? "report-fail" : "report-pass", KATTR__MAX);
-	khtml_puts(r->html, fail ? "fail" : "pass");
+		get_status_class(status, 0), KATTR__MAX);
+	khtml_puts(r->html, status);
 	khtml_closeelem(r->html, 1);
 	khtml_closeelem(r->html, 1);
 

@@ -854,8 +884,7 @@ get_dash_job(const struct job *p, void *arg)
 	khtml_attr(r->html, KELEM_DIV, KATTR_CLASS,
 		"cell report-status", KATTR__MAX);
 	khtml_attr(r->html, KELEM_SPAN, KATTR_CLASS,
-		strcmp(p->status, "pass") == 0 ? "report-pass" : "report-fail",
-		KATTR__MAX);
+		get_status_class(p->status, 0), KATTR__MAX);
 	khtml_puts(r->html, p->status);
 	khtml_closeelem(r->html, 1);
 	khtml_closeelem(r->html, 1);

@@ -1012,8 +1041,7 @@ get_job_html(struct kreq *r, const struct job *p)
 
 	khtml_attr(&req, KELEM_DIV, KATTR_CLASS, "singleton", KATTR__MAX);
 	khtml_attr(&req, KELEM_SPAN, KATTR_CLASS,
-		strcmp(p->status, "pass") == 0 ? "report-success" : "report-failure",
-		KATTR__MAX);
+		get_status_class(p->status, 1), KATTR__MAX);
 	khtml_puts(&req, p->status);
 	khtml_closeelem(&req, 1);
 	khtml_attr(&req, KELEM_DIV, KATTR_CLASS, "lefthead report-run", KATTR__MAX);

@@ -1021,8 +1049,12 @@ get_job_html(struct kreq *r, const struct job *p)
 	khtml_int(&req, p->runid);
 	khtml_closeelem(&req, 1);
 	khtml_closeelem(&req, 1);
-	kutil_epoch2str(p->finish, buf, sizeof(buf));
 	khtml_attr(&req, KELEM_DIV, KATTR_CLASS, "lefthead report-start", KATTR__MAX);
+	if (is_running(p)) {
+		kutil_epoch2str(p->start, buf, sizeof(buf));
+		khtml_puts(&req, "running since ");
+	} else
+		kutil_epoch2str(p->finish, buf, sizeof(buf));
 	khtml_puts(&req, buf);
 	khtml_closeelem(&req, 1);
 	db_artifact_iterate_byjob(r->arg, count_artifact, &artc, p->id);

@@ -1598,7 +1630,8 @@ post_job(struct kreq *r)
 	}
 	if (strcmp(kpjs->parsed.s, "pass") != 0 &&
 	    strcmp(kpjs->parsed.s, "fail") != 0 &&
-	    strcmp(kpjs->parsed.s, "skip") != 0) {
+	    strcmp(kpjs->parsed.s, "skip") != 0 &&
+	    strcmp(kpjs->parsed.s, "running") != 0) {
 		kutil_warnx(r, NULL, "invalid job status");
 		http_open(r, KHTTP_403, KMIME__MAX, 0);
 		goto out;
diff --git a/minci.css b/minci.css
@@ -48,6 +48,7 @@ div.table > :first-child		{ display: none;
 					  color: #fff; }
 .report-pass				{ color: green; }
 .report-fail				{ color: red; }
+.report-running				{ color: #8a5a00; }
 .row					{ padding: 0.5rem;
 					  white-space: nowrap; 
 					  text-overflow: hidden;