Commit d1c10c04f731e3b4ba9718bc754cbae205521f43

Thomas de Grivel 2023-02-16T13:07:25

ci

diff --git a/bin/shpkg_ci_mux b/bin/shpkg_ci_mux
index 74f08a5..7eee74c 100755
--- a/bin/shpkg_ci_mux
+++ b/bin/shpkg_ci_mux
@@ -43,28 +43,81 @@ shpkg_ci_status2png () {
 main () {
     SHPKG_REPO="$1"
     shift
-    for SHPKG_CI_MUX_HOST; do
-        shpkg_ci_remote "${SHPKG_CI_MUX_HOST}" "${SHPKG_REPO}" &
-    done
-    for SHPKG_CI_MUX_HOST; do
-        wait
-    done
-    if [ "x${SHPKG_REPO}" == "x--upgrade" ] ||
-       [ "x${SHPKG_REPO}" == "x--clean" ]; then
-        exit
+    if [ "x${SHPKG_REPO}" != "x--no-remote" ]; then
+        for SHPKG_CI_MUX_HOST; do
+            shpkg_ci_remote "${SHPKG_CI_MUX_HOST}" "${SHPKG_REPO}" &
+        done
+        for SHPKG_CI_MUX_HOST; do
+            wait
+        done
+        if [ "x${SHPKG_REPO}" == "x--upgrade" ] ||
+               [ "x${SHPKG_REPO}" == "x--clean" ]; then
+            exit
+        fi
     fi
     ( cd "${SHPKG_CI_DIR}/status" &&
-          for S in $(ls */*/*.status | cut -d / -f 3 | sort -u); do
+          for I in $(ls */*/*.status | cut -d / -f 3 | sort -u); do
               {
-                  if grep -q running */*/"$S"; then
+                  if grep -q running */*/"$I"; then
                       echo running
-                  elif grep -q ko */*/"$S"; then
+                  elif grep -q ko */*/"$I"; then
                       echo ko
                   else
                       echo ok
                   fi
-              } > "${SHPKG_CI_DIR}/status/$S"
+              } > "${SHPKG_CI_DIR}/status/$I"
+          done; )
+    ( cd "${SHPKG_CI_DIR}/log" &&
+          for I in $(ls */*/*.log | cut -d / -f 3 | sort -u); do
+              TITLE="$I"
+              STATUS="$(cat "${SHPKG_CI_DIR}/status/$(basename "$I" .log).status" || echo unknown)"
+              IMG="$(basename "$I" .log).png"
+              {
+                  cat <<EOF
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+    <title>${TITLE}</title>
+    <link rel="stylesheet" href="/_assets/app.css">
+    <script defer type="text/javascript" src="/_assets/app.js"></script>
+    <link rel="icon" type="image/png" sizes="64x64" href="${IMG}">
+  </head>
+  <body>
+    <h1>
+      <img src="${IMG}" class="status-${STATUS}"/>
+      ${TITLE}
+    </h1>
+    <ul class="list-group">
+EOF
+                  for F in */*/"$I"; do
+                      F_STATUS="$(cat "${SHPKG_CI_DIR}/status/$(echo "$F" | sed -e 's/[.]log$/.status/')" || echo unknown)"
+                      F_IMG="$(echo "$F" | sed -e 's/[.]log$/.png/')"
+                      cat <<EOF
+      <li class="list-group-item">
+        <a href="$F">
+          <img src="${F_IMG}" class="status-${F_STATUS}"/>
+          $F
+        </a>
+      </li>
+      <li class="list-group-item">
+        <a href="$F.html">
+          <img src="${F_IMG}" class="status-${F_STATUS}"/>
+          $F.html
+        </a>
+      </li>
+EOF
+                  done
+                  cat <<EOF
+    </ul>
+  </body>
+</html>
+EOF
+              } > "${SHPKG_CI_DIR}/log/$I.html"
           done; )
+    verbose 2 shpkg_ci_status2png
 }
 
 shpkg_log shpkg_ci_mux main "$@"