commit f6816e4d24d6646444f3d69d9422e47431474043
parent f75b4eaa76f36040373beed818145255102d7a0f
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Sep 2026 01:55:06 +0530
parent f75b4eaa76f36040373beed818145255102d7a0f
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Sep 2026 01:55:06 +0530
Append running and restarted jobs
2 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/main.c b/main.c @@ -772,21 +772,43 @@ get_single_html(struct kreq *r, const struct report *p) } struct jobstate { - int fail; - int running; - int jobs; + char name[50][65]; + char status[50][17]; + size_t sz; }; static void count_job(const struct job *p, void *arg) { struct jobstate *state = arg; + size_t i; + + for (i = 0; i < state->sz; i++) + if (strcmp(state->name[i], p->name) == 0) + break; + if (i == state->sz) { + if (state->sz == 50) + return; + strlcpy(state->name[i], p->name, sizeof(state->name[i])); + state->sz++; + } + strlcpy(state->status[i], is_running(p) ? "running" : p->status, + sizeof(state->status[i])); +} + +static const char * +get_run_status(const struct jobstate *state) +{ + size_t i; + int fail = 0; - state->jobs++; - if (is_running(p)) - state->running = 1; - else if (strcmp(p->status, "pass")) - state->fail = 1; + for (i = 0; i < state->sz; i++) { + if (strcmp(state->status[i], "running") == 0) + return "running"; + if (strcmp(state->status[i], "pass") != 0) + fail = 1; + } + return fail ? "fail" : "pass"; } static void @@ -816,7 +838,7 @@ get_run_row(const struct run *p, void *arg) khtml_closeelem(r->html, 1); db_job_iterate_byrun(r->r->arg, count_job, &state, p->id); - status = state.running ? "running" : state.fail ? "fail" : "pass"; + status = get_run_status(&state); khtml_attr(r->html, KELEM_DIV, KATTR_CLASS, "cell report-status", KATTR__MAX); khtml_attr(r->html, KELEM_SPAN, KATTR_CLASS,
diff --git a/minci.sh b/minci.sh @@ -1,11 +1,12 @@ #! /bin/sh # Usage: -# minci.sh [-fnrv] [repo...] +# minci.sh [-fnrv] [-H runhash] [repo[/job]...] # -f: force updates # -n: don't do anything, but show what would be done # -r: run full check, but don't upload results # -v: more data while running +# -H: append selected repo/job work to an existing run hash # Use ~/.minci or /etc/minci for configuration, whichever comes first. MAKE="make" @@ -28,6 +29,7 @@ CONFIG_GLOBAL="/etc/minci" PROGNAME="$0" FORCE= BRANCH="master" +RUN_HASH= msg() { @@ -87,7 +89,8 @@ postjob() finish=$5 log=$6 [ -n "$NOOP" -o -n "$NOREP" ] && return 0 - runhash=$(printf '%s|%s|%s|%s|%s' "$project" "$FETCH_HEAD" "$BRANCH" "${TARGET:-$(uname -n)}" "$TIME_start" | md5text) + runhash="$RUN_HASH" + [ -n "$runhash" ] || runhash=$(printf '%s|%s|%s|%s|%s' "$project" "$FETCH_HEAD" "$BRANCH" "${TARGET:-$(uname -n)}" "$TIME_start" | md5text) loghash=$(md5file "$log") QUERY="artifact-name=${artifact_name:-}" QUERY="$QUERY&artifact-sha256=${artifact_sha256:-}" @@ -133,10 +136,10 @@ joblist() done } -args=$(getopt fnrv $*) +args=$(getopt H:fnrv $*) if [ $? -ne 0 ] then - echo "usage: $PROGNAME [-fnrv] [repo ...]" 1>&2 + echo "usage: $PROGNAME [-fnrv] [-H runhash] [repo[/job] ...]" 1>&2 exit 1 fi @@ -150,6 +153,8 @@ do NOOP=1 ; shift ;; -r) NOREP=1 ; shift ;; + -H) + RUN_HASH=$2 ; shift 2 ;; -f) FORCE=1 ; shift ;; -v) @@ -385,19 +390,20 @@ do fi # Iterate through the command-line arguments, only if specified, - # to see if we want to run this. + # to see if we want to run this. Arguments may be repo or repo/job. + RUNJOBS= if [ $# -gt 0 ] then + found= for prog in "$@" do - if [ "$prog" = "$reponame" ] - then - prog="" - break - fi + case "$prog" in + "$reponame") found=1 ;; + "$reponame"/*) found=1 ; RUNJOBS="$RUNJOBS ${prog#*/}" ;; + esac done - if [ -n "$prog" ] + if [ -z "$found" ] then debug "ignoring: $reponame" continue @@ -479,7 +485,8 @@ do # If the FETCH_HEAD commit doesn't change when we freshen the # repository, then doing re-test it unless -f was passed. - if [ -z "$FORCE" ] && [ -n "$head" ] && [ "$head" = "$FETCH_HEAD" ] + if [ -z "$FORCE" ] && [ -z "$RUNJOBS" ] && + [ -n "$head" ] && [ "$head" = "$FETCH_HEAD" ] then debug "repository is fresh: $reponame" TIME_start=0 @@ -504,6 +511,7 @@ do export srcdir workdir pkgdir destdir target . "$jf" jobs=$(joblist) + [ -z "$RUNJOBS" ] || jobs="$RUNJOBS" if [ -n "$jobs" ] then JOBFILE_DONE=1 @@ -511,11 +519,18 @@ do mkdir -p "$workdir" "$pkgdir" "$destdir" for job in $jobs do - [ -n "$NOOP" ] || exec 3>/tmp/minci.log jobstart=$(date +%s) artifact_name= artifact_url= artifact_sha256= + if [ -z "$NOOP" ] + then + printf '%s: %s: %s: started\n' \ + "$PROGNAME" "$reponame/$job" \ + "$(date +"%F %T")" >/tmp/minci.log + fi + postjob "$project" "$job" running "$jobstart" 0 /tmp/minci.log + [ -n "$NOOP" ] || exec 3>/tmp/minci.log if run "$job" "$reponame/$job" then postjob "$project" "$job" pass "$jobstart" "$(date +%s)" /tmp/minci.log
: nply/minci