[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible trbo system health check: refactor, make some output conditional

Holger Levsen gitlab at salsa.debian.org
Wed Jul 22 20:07:13 BST 2020



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
eb395650 by Holger Levsen at 2020-07-22T21:06:54+02:00
reproducible trbo system health check: refactor, make some output conditional

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- bin/reproducible_system_health.sh


Changes:

=====================================
bin/reproducible_system_health.sh
=====================================
@@ -204,6 +204,12 @@ echo "$(date -u) - SCORE  = $SCORE"
 echo "$(date -u) - STATUS = $STATUS"
 echo $STATUS > $HEALTH_FILE
 echo "$(date -u) - $HEALTH_FILE updated."
+
+SUSPICIOUS_TEXT=""
+if [ $SUSPICIOUS -gt 0 ] ; then
+	SUSPICIOUS_TEXT="(including $SUSPICIOUS on nodes automatically marked offline)"
+fi
+
 cat > $HEALTH_FILE.html <<- EOF
 <html><meta http-equiv="refresh" content="300"><head></head><body style="background-color: rgb($RED, $GREEN, 0);">
  <h1>tests.reproducible-builds.org Status</h1>
@@ -214,53 +220,35 @@ cat > $HEALTH_FILE.html <<- EOF
   Score: $SCORE (a stable jobs adds 3, an unstable job adds 1 and a failed job substracts something between 1 and 500 (indicated in brackets after the job name below), depending on the importance of the job for the setup.)
   <br/>
   Jobs considered: $INPUTS
-  (including $SUSPICIOUS on nodes automatically marked offline)
+  ${SUSPICIOUS_TEXT}
   <br/>
   Jobs ignored: $INVALID
  </p>
- <p>
-  Failed jobs:
-  <ul>
-   $(cat ${FAILED_JOBS} | sort -t '|' -n -r | cut -d '|' -f2- | sort)
-  </ul>
- </p>
- <p>
-  Unstable jobs:
-  <ul>
-   $(cat ${UNSTABLE_JOBS})
-  </ul>
- </p>
- <p>
-  Failed jobs on nodes automatically marked down by jenkins:
-  <ul>
-   $(cat ${FAILED_SUSPECTS} | sort -t '|' -n -r | cut -d '|' -f2- | sort)
-  </ul>
- </p>
- <p>
-  Unstable jobs on nodes automatically marked down by jenkins:
-  <ul>
-   $(cat ${UNSTABLE_SUSPECTS})
-  </ul>
- </p>
- <p>
-  Ignored jobs (because these nodes are known and
-  <a href="https://salsa.debian.org/qa/jenkins.debian.net/-/blob/master/jenkins-home/offline_nodes">documented</a>
-  to be offline):
-  <ul>
-   $(cat ${IGNORED_JOBS})
-  </ul>
- </p>
- <p>
-  Ignored jobs (because they are known to be non-funtional):
-  <ul>
-   $(cat ${BAD_JOBS})
-  </ul>
- </p>
- <p>
-  <small>last updated: $(date -u) by the <a href="https://jenkins.debian.net/job/reproducible_system_health/">reproducible_system_health</a> job on jenkins.debian.net.</small>
- </p>
-</body></html>
 EOF
+
+write2healthfile() {
+	echo "$1" >> $HEALTH_FILE.html
+}
+
+conditional_paragraph() {
+	if [ -s $1 ] ; then
+		write2healthfile " <p>"
+		write2healthfile "  $2:"
+		write2healthfile "  <ul>"
+		write2healthfile "   $3"
+		write2healthfile "  </ul>"
+		write2healthfile " </p>"
+	fi
+}
+
+conditional_paragraph ${FAILED_JOBS} "Failed jobs" "$(cat ${FAILED_JOBS} | sort -t '|' -n -r | cut -d '|' -f2- | sort)"
+conditional_paragraph ${UNSTABLE_JOBS} "Unstable jobs" "$(cat ${UNSTABLE_JOBS})"
+conditional_paragraph ${FAILED_SUSPECTS} "Failed jobs on nodes automatically marked down by jenkins" "$(cat ${FAILED_SUSPECTS} | sort -t '|' -n -r | cut -d '|' -f2- | sort)"
+conditional_paragraph ${UNSTABLE_SUSPECTS} "Unstable jobs on nodes automatically marked down by jenkins" "$(cat ${UNSTABLE_SUSPECTS})"
+conditional_paragraph ${IGNORED_JOBS} "Ignored jobs (because these nodes are known and <a href=\"https://salsa.debian.org/qa/jenkins.debian.net/-/blob/master/jenkins-home/offline_nodes\">documented</a> to be offline)" "$(cat ${IGNORED_JOBS})"
+conditional_paragraph ${BAD_JOBS} "Ignored jobs (because they are known to be non-funtional)" "$(cat ${BAD_JOBS})"
+write2healthfile "<p><small>last updated: $(date -u) by the <a href=\"https://jenkins.debian.net/job/reproducible_system_health/\">reproducible_system_health</a> job on jenkins.debian.net.</small></p>"
+write2healthfile "</body></html>"
 echo "$(date -u) - $(basename $HEALTH_FILE).html updated, visible at $REPRODUCIBLE_URL/$(basename $HEALTH_FILE).html."
 echo "$(date -u) - the end."
 rm -f ${FAILED_JOBS} ${UNSTABLE_JOBS} ${IGNORED_JOBS} ${BAD_JOBS} ${FAILED_SUSPECTS} ${UNSTABLE_SUSPECTS}



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/eb3956508feaa1c721d82f0a9675d2ab8ffdeb4b

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/eb3956508feaa1c721d82f0a9675d2ab8ffdeb4b
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20200722/85c5b351/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list