commit:     469d7fd1f99ae38627dbd3ef90877c85af56f96f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 21 16:30:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Feb 21 16:31:08 2019 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=469d7fd1

scripts/auto-bootstraps: try to keep timing information

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/auto-bootstraps/analyse_result.py  | 24 +++++++++++++++++++++---
 scripts/auto-bootstraps/dobootstrap        |  4 ++++
 scripts/auto-bootstraps/process_uploads.sh |  1 +
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/scripts/auto-bootstraps/analyse_result.py 
b/scripts/auto-bootstraps/analyse_result.py
index 885c7fc9e7..08762d5b9c 100755
--- a/scripts/auto-bootstraps/analyse_result.py
+++ b/scripts/auto-bootstraps/analyse_result.py
@@ -115,7 +115,17 @@ with os.scandir(resultsdir) as it:
             continue
         arch = f.name
         fail, state, suc = analyse_arch(os.path.join(resultsdir, arch))
-        archs[arch] = (fail, state, suc)
+
+        elapsedtime = None
+        if suc:
+            elapsedf = os.path.join(resultsdir, arch, suc, "elapsedtime")
+            if os.path.exists(elapsedf):
+                with open(elapsedf, 'rb') as f:
+                    l = f.readline()
+                    if l not is '':
+                        elapsedtime = int(l)
+
+        archs[arch] = (fail, state, suc, elapsedtime)
         if not suc:
             color = '\033[1;31m'  # red
         elif fail and suc < fail:
@@ -136,7 +146,7 @@ with open(os.path.join(resultsdir, 'index.html'), "w") as h:
     h.write("<th>last successful run</th><th>last failed run</th>")
     h.write("<th>failure</th>")
     for arch in archs:
-        fail, errcode, suc = archs[arch]
+        fail, errcode, suc, et = archs[arch]
         if not suc:
             state = 'red'
         elif fail and suc < fail:
@@ -152,7 +162,15 @@ with open(os.path.join(resultsdir, 'index.html'), "w") as 
h:
 
         h.write("<td>")
         if suc:
-            h.write('<a href="%s/%s">%s</a>' % (arch, suc, suc))
+            etxt = ''
+            if et:
+                if et > 86400:
+                    etxt = ' (%.1f days)' % (et / 86400)
+                elif et > 3600:
+                    etxt = ' (%.1f hours)' % (et / 3600)
+                else
+                    etxt = ' (%d minutes)' % (et / 60)
+            h.write('<a href="%s/%s">%s</a>%s' % (arch, suc, suc, etxt))
         else:
             h.write('<i>never</i>')
         h.write("</td>")

diff --git a/scripts/auto-bootstraps/dobootstrap 
b/scripts/auto-bootstraps/dobootstrap
index 521f644acf..0073ab176e 100755
--- a/scripts/auto-bootstraps/dobootstrap
+++ b/scripts/auto-bootstraps/dobootstrap
@@ -104,6 +104,7 @@ do_prepare() {
        keepalive=$(type -P caffeinate)
        [[ -x ${keepalive} ]] && keepalive+=" -i -m -s" || keepalive=
 
+       starttime=${SECONDS}
        env -i \
                HOME=${EPREFIX} \
                SHELL=/bin/bash \
@@ -117,8 +118,10 @@ do_prepare() {
                ${LATEST_TREE_YES+LATEST_TREE_YES=1} \
                ${TREE_FROM_SRC+TREE_FROM_SRC=}${TREE_FROM_SRC} \
                ${keepalive} /bin/bash -l -c "${BASH} ${bootstrapscript} 
bootstrap"
+       endtime=${SECONDS}
 
        if [[ -n ${DOPUBLISH} ]] ; then
+               echo $((endtime - starttime)) > elapsedtime
                rsync -q /dev/null ${UPLOAD}/${HOSTNAME}-$$/
                rsync -q /dev/null ${UPLOAD}/${HOSTNAME}-$$/${chost}/
                rsync -rltv \
@@ -130,6 +133,7 @@ do_prepare() {
                        {stage,.stage}* \
                        bootstrap-prefix.sh \
                        startprefix \
+                       elapsedtime \
                        usr/portage/distfiles \
                        var/tmp/portage \
                        var/log/emerge.log \

diff --git a/scripts/auto-bootstraps/process_uploads.sh 
b/scripts/auto-bootstraps/process_uploads.sh
index 52bb09ed7f..402f9e4ae6 100755
--- a/scripts/auto-bootstraps/process_uploads.sh
+++ b/scripts/auto-bootstraps/process_uploads.sh
@@ -35,6 +35,7 @@ for d in ${UPLOADDIR}/* ; do
                bootstrap-prefix.sh \
                emerge.log \
                startprefix \
+               elapsedtime \
                distfiles ;
        do
                [[ -e "${d}/${dir}/${f}" ]] && \

Reply via email to