commit 58962a3e8424ffc5cc9e2ba8c5aba8be167bad7b
parent 68ce9e74dac5e5a4e4fe8a62132c49fa19c78056
Author: kristapsdz <kristaps@bsd.lv>
Date: Sat, 7 Mar 2020 11:05:03 +0000
parent 68ce9e74dac5e5a4e4fe8a62132c49fa19c78056
Author: kristapsdz <kristaps@bsd.lv>
Date: Sat, 7 Mar 2020 11:05:03 +0000
Add links to repository and per-date view.
3 files changed, 76 insertions(+), 35 deletions(-)
diff --git a/db.ort b/db.ort @@ -20,6 +20,11 @@ struct project { }; struct user { + comment "Users can be totally anonymous and are just used for + authenticating reports. + To create a user, you can `echo $RANDOM` for the apikey + and `jot -r -c 32 'A' '{' | rs -g0` for the secret."; + field email email comment "Only used for logging purposes."; field apikey int limit gt 0 unique @@ -40,6 +45,15 @@ struct user { }; struct report { + comment "Test runner results for a single repository. The epoch + fields are sequential, so they're either a time of + completion of zero on failure. On failure, all + subsequent fields (e.g., build after depend) must fail + as well. + The log should be the standard error and output of + everything that has happened in the sequence---not just + the last failure."; + field project struct projectid; field projectid:project.id;
diff --git a/main.c b/main.c @@ -32,6 +32,10 @@ #include "extern.h" +#ifndef REPO_BASE +#define REPO_BASE "https://github.com/kristapsdz" +#endif + enum page { PAGE_INDEX, PAGE__MAX @@ -166,7 +170,13 @@ get_html_last_report(const struct report *p, void *arg) { struct req *r = arg; struct tm tm; - char *urlid, *urlproj; + int64_t date; + char *urlid, *urlproj, *urldate; + + memset(&tm, 0, sizeof(struct tm)); + KUTIL_EPOCH2TM(p->ctime, &tm); + date = kutil_date2epoch + (tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900); urlid = kutil_urlpartx(NULL, r->r->pname, @@ -180,6 +190,12 @@ get_html_last_report(const struct report *p, void *arg) pages[PAGE_INDEX], valid_keys[VALID_PROJECT_NAME].name, KATTRX_STRING, p->project.name, NULL); + urldate = kutil_urlpartx(NULL, + r->r->pname, + ksuffixes[KMIME_TEXT_HTML], + pages[PAGE_INDEX], + valid_keys[VALID_REPORT_CTIME].name, + KATTRX_INT, date, NULL); memset(&tm, 0, sizeof(struct tm)); KUTIL_EPOCH2TM(p->start, &tm); @@ -203,6 +219,8 @@ get_html_last_report(const struct report *p, void *arg) khtml_attr(&r->html, KELEM_DIV, KATTR_CLASS, "cell report-start", KATTR__MAX); + khtml_attr(&r->html, KELEM_A, + KATTR_HREF, urldate, KATTR__MAX); khtml_attrx(&r->html, KELEM_TIME, KATTR_DATETIME, KATTRX_INT, p->start, KATTR__MAX); khtml_int(&r->html, tm.tm_year + 1900); @@ -215,6 +233,7 @@ get_html_last_report(const struct report *p, void *arg) khtml_int(&r->html, 0); khtml_int(&r->html, tm.tm_mday); khtml_closeelem(&r->html, 1); /* time */ + khtml_closeelem(&r->html, 1); /* a */ khtml_closeelem(&r->html, 1); /* cell */ khtml_attr(&r->html, KELEM_DIV, KATTR_CLASS, @@ -251,6 +270,7 @@ get_html_last_report(const struct report *p, void *arg) khtml_closeelem(&r->html, 1); /* row */ free(urlid); free(urlproj); + free(urldate); } /* @@ -271,10 +291,19 @@ get_single_html(struct kreq *r, const struct report *p) { struct khtmlreq req; char buf[64]; - char *url; + char *url = NULL, *repo = NULL, *urlproj; const char *cp; size_t count; + urlproj = kutil_urlpartx(NULL, + r->pname, + ksuffixes[KMIME_TEXT_HTML], + pages[PAGE_INDEX], + valid_keys[VALID_PROJECT_NAME].name, + KATTRX_STRING, p->project.name, NULL); + kasprintf(&repo, "%s/%s", + REPO_BASE, p->project.name); + khtml_open(&req, r, 0); html_open(&req, "Minimal CI Report"); @@ -293,7 +322,14 @@ get_single_html(struct kreq *r, const struct report *p) khtml_attr(&req, KELEM_DIV, KATTR_CLASS, "lefthead project-name", KATTR__MAX); + khtml_attr(&req, KELEM_A, KATTR_HREF, urlproj, KATTR__MAX); khtml_puts(&req, p->project.name); + khtml_closeelem(&req, 1); /* a */ + khtml_closeelem(&req, 1); /* div */ + + khtml_attr(&req, KELEM_A, KATTR_CLASS, + "lefthead project-repo", + KATTR_HREF, repo, KATTR__MAX); khtml_closeelem(&req, 1); /* div */ khtml_attr(&req, KELEM_DIV, KATTR_CLASS, @@ -372,13 +408,15 @@ get_single_html(struct kreq *r, const struct report *p) KATTR_HREF, url, KATTR__MAX); khtml_closeelem(&req, 1); /* a */ khtml_closeelem(&req, 1); /* div */ - free(url); } khtml_closeelem(&req, 1); /* div */ khtml_closeelem(&req, 1); /* body */ khtml_closeelem(&req, 1); /* html */ khtml_close(&req); + free(url); + free(urlproj); + free(repo); } /* @@ -421,6 +459,10 @@ static void get_last(struct kreq *r) { struct req req; + struct kpair *kpn, *kpd; + + kpn = r->fieldmap[VALID_PROJECT_NAME]; + kpd = r->fieldmap[VALID_REPORT_CTIME]; req.r = r; http_open(r, KHTTP_200, r->mime); @@ -430,38 +472,20 @@ get_last(struct kreq *r) khtml_attr(&req.html, KELEM_DIV, KATTR_CLASS, "table", KATTR__MAX); get_html_last_header(&req.html); - db_report_iterate_last(r->arg, - get_html_last_report, &req); - khtml_closeelem(&req.html, 1); /* table */ - khtml_closeelem(&req.html, 1); /* body */ - khtml_closeelem(&req.html, 1); /* html */ - khtml_close(&req.html); -} - -/* - * List the last *n* records, sorted by time of accept. - * Always outputs HTTP 200. - */ -static void -get_lastproj(struct kreq *r) -{ - struct req req; - struct kpair *kp; - kp = r->fieldmap[VALID_PROJECT_NAME]; - assert(kp != NULL); - - req.r = r; - http_open(r, KHTTP_200, r->mime); + if (kpn != NULL) + db_report_iterate_lastname(r->arg, + get_html_last_report, &req, + kpn->parsed.s); /* project.name */ + else if (kpd != NULL) + db_report_iterate_lastdate(r->arg, + get_html_last_report, &req, + kpd->parsed.i, /* ctime ge */ + kpd->parsed.i + 86400); /* ctime le */ + else + db_report_iterate_last(r->arg, + get_html_last_report, &req); - khtml_open(&req.html, r, 0); - html_open(&req.html, "Recent Minimal CI Reports"); - khtml_attr(&req.html, KELEM_DIV, - KATTR_CLASS, "table", KATTR__MAX); - get_html_last_header(&req.html); - db_report_iterate_lastproj(r->arg, - get_html_last_report, &req, - kp->parsed.s); /* project.name */ khtml_closeelem(&req.html, 1); /* table */ khtml_closeelem(&req.html, 1); /* body */ khtml_closeelem(&req.html, 1); /* html */ @@ -477,8 +501,6 @@ get(struct kreq *r) if (r->fieldmap[VALID_REPORT_ID] != NULL) get_single(r); - else if (r->fieldmap[VALID_PROJECT_NAME] != NULL) - get_lastproj(r); else get_last(r); }
diff --git a/minci.css b/minci.css @@ -12,9 +12,14 @@ body { font-family: sans-serif; } color: #fff; } .lefthead.report-id, .lefthead.project-name, +.lefthead.project-repo, .cell.report-id, .cell.report-start, .cell.project-name { display: inline-block; } +.lefthead.project-name { border-right: thin solid #888; + padding-right: 0.5rem; + margin-right: 0.5rem; } +.lefthead.project-repo::before { content: 'repository'; } .lefthead.report-id::after, .cell.report-start::after, .cell.report-id::after { content: ', ';
: nply/minci