RFC: mp-buildbot failcache

Rainer Müller raimue at macports.org
Mon Sep 12 09:12:00 PDT 2016


On 2016-09-12 14:41, Clemens Lang wrote:
> here's a patch against mp-buildbot that would add a fail cache for use
> on the buildbots. Unfortunately I don't have a test setup yet, so I'm
> hesitating to commit this immediately. I'd welcome feedback, a code
> review, or testing by somebody with a working builbot setup.
> 
> Basically, I'm keeping failcache per tuple of (portname, canonical
> variants, checksum) where
>  - I need one additional call to a custom port client to dump the
>    canonical variants
>  - calculate the checksum as
>    sha256(sort(sha256(Portfile), sha256(files/*)))
>    which will make the buildbots re-try a dependency if, for example, a
>    maintainer forgot to commit a patch file

Should the PortGroups be included in this hash as well?

We should put the buildername/buildnumber/URL of the failing build into
the failcache to be reported back on a match. The current output would
not be helpful to find the reason why it failed. I added this
information to the build environment [1].

During setup for a quick test I made a small mistake with the new files.
This failure in execution of tools/canonical_variants.tcl should not
have been a success. The return code of failcache_failure/success was
not handled. I also added a missing mkdir and fixed the reversed logic
in failcache_test and another classic bash problem [2].

Now this works for me. To save bandwidth, I am only attaching my changes
on top of your patch.

Rainer

[1] https://trac.macports.org/changeset/152554
[2] http://mywiki.wooledge.org/BashFAQ/024
-------------- next part --------------
diff -u functions functions
--- functions	(working copy)
+++ functions	(working copy)
@@ -83,8 +83,8 @@
 ## Test whether a given port with variants has previously failed.
 #
 # Valid arguments are a port name, optionally followed by a variant
-# specification. Succeeds if the port did not previsouly fail to build, fails
-# if the port is known to fail.
+# specification. Succeeds if the port did not previously fail to build,
+# fails if the port is known to fail.
 failcache_test() {
     local key
     key=$(failcache_key "$@")
@@ -93,7 +93,7 @@
         return 1
     fi
 
-    test -f "${option_failcache_dir}/${key}"
+    test ! -f "${option_failcache_dir}/${key}"
 }
 
 ## Mark a build of a given port with variants as successful.
@@ -125,4 +125,6 @@
     fi
 
+    mkdir -p "${option_failcache_dir}"
+
     touch "${option_failcache_dir}/${key}"
 }
diff -u mpbb-install-dependencies mpbb-install-dependencies
--- mpbb-install-dependencies	(working copy)
+++ mpbb-install-dependencies	(working copy)
@@ -76,7 +76,8 @@
     echo >> "$log_status_dependencies"
 
     # Check whether any of the dependencies have previously failed
-    echo "$dependencies" | while read -r dependency; do
+    failcachecounter=0
+    while read -r dependency; do
         # Split portname +variant1+variant2 into portname and variants, where
         # the variants are optional.
         depname=${dependency%% *}
@@ -89,9 +90,14 @@
             echo "$text" >&2
             echo "$text" >> "$log_status_dependencies"
             echo "Building '$port' ... [ERROR] (failed to install dependency '${depname}') maintainers: $(get-maintainers "$port" "${depname}")." >> "$log_subports_progress"
-            return 1
+            failcachecounter=$((failcachecounter + 1))
         fi
-    done
+    done < <(echo "$dependencies")
+
+    if [ $failcachecounter != 0 ]; then
+        echo "Aborting build due to $failcachecounter previously failed dependencies." >&2
+        return 1
+    fi
 
     echo "$dependencies" | while read -r dependency; do
         # Split portname +variant1+variant2 into portname and variants, where
@@ -113,6 +119,10 @@
             # $depvariants isn't quoted on purpose
             # shellcheck disable=SC2086
             failcache_failure "$depname" $depvariants
+            if [ $? -ne 0 ]; then
+                err "failcache_failure failed."
+                return 1
+            fi
             return 1
         else
             echo "[OK]" >> "$log_status_dependencies"
@@ -120,6 +130,10 @@
             # $depvariants isn't quoted on purpose
             # shellcheck disable=SC2086
             failcache_success "$depname" $depvariants
+            if [ $? -ne 0 ]; then
+                err "failcache_success failed."
+                return 1
+            fi
             dependencies_counter=$((dependencies_counter + 1))
         fi
     done
diff -u mpbb-install-port mpbb-install-port
--- mpbb-install-port	(working copy)
+++ mpbb-install-port	(working copy)
@@ -58,12 +58,20 @@
     if "${option_prefix}/bin/port" -dk install "$@"; then
         # Remove failcache if it exists
         failcache_success "$@"
+        if [ $? -ne 0 ]; then
+            err "failcache_success failed."
+            return 1
+        fi
     else
         echo "Build of '$port' failed."
         # log: summary for the portwatcher
         echo "Building '$port' ... [ERROR] maintainers: $(get-maintainers "$port")." >> "$log_subports_progress"
         # update failcache
         failcache_failure "$@"
+        if [ $? -ne 0 ]; then
+            err "failcache_failure failed."
+            return 1
+        fi
         return 1
     fi
     time_stop=$(date +%s)


More information about the macports-dev mailing list