Use onrun handler to perform memory_set.
[goaljobs-goals.git] / libguestfs_upstream.ml
index 1ea64a1..01b2a68 100644 (file)
@@ -12,6 +12,17 @@ open Goaljobs
 open Printf
 open Config
 
+(* Enable debugging. *)
+let () =
+  Unix.putenv "LIBGUESTFS_DEBUG" "1";
+  Unix.putenv "LIBGUESTFS_TRACE" "1"
+
+(* Log program output. *)
+let from = "rjones@redhat.com"
+let to_ = "rjones@redhat.com"
+let logfile = log_program_output ()
+let () = eprintf "logging to %s\n%!" logfile
+
 let package = "libguestfs"
 
 (* Helper object which stores everything about a version. *)
@@ -58,17 +69,18 @@ let rec goal website_updated version =
 and website_rsync_done version =
   let key = sprintf "libguestfs_website_rsync_done_%s" version.version in
   target (memory_exists key);
+  onrun (fun () -> memory_set key "1");
 
   sh "
     cd %s
     echo NOT RUNNING: . .rsync
-  " libguestfs_website_cvs;
-  memory_set key "1"
+  " libguestfs_website_cvs
 
 (* Goal: Tarball added to CVS and CVS checked in. *)
 and website_cvs_checked_in version =
   let key = sprintf "libguestfs_website_cvs_checked_in_%s" version.version in
   target (memory_exists key);
+  onrun (fun () -> memory_set key "1");
 
   require (tarball_created version);
   require (tarball_tested version);
@@ -97,9 +109,11 @@ and website_built version =
   sh "
     tar zxf %s/tarballs/%s
     cd %s
+
     echo %s > localconfigure
     chmod +x localconfigure
-    echo %s > localenv .
+    echo %s > localenv
+
     ./localconfigure
     make
     make website
@@ -114,15 +128,18 @@ and website_built version =
 and tarball_tested version =
   let key = sprintf "libguestfs_tarball_tested_%s" version.version in
   target (memory_exists key);
+  onrun (fun () -> memory_set key "1");
 
   require (tarball_created version);
 
   sh "
     tar zxf %s/tarballs/%s
     cd %s
+
     echo %s > localconfigure
     chmod +x localconfigure
-    echo %s > localenv .
+    echo %s > localenv
+
     ./localconfigure
     make
     make check-release
@@ -146,7 +163,7 @@ and tarball_created version =
 
     echo %s > localconfigure
     chmod +x localconfigure
-    echo %s > localenv .
+    echo %s > localenv
 
     ./localconfigure
     make
@@ -160,8 +177,15 @@ and tarball_created version =
 
 (* Goal: test a commit. *)
 and commit_tested branch commit =
+  onfail (
+    fun _ ->
+      let subject = sprintf "goal: %s: FAILED" goalname in
+      mailto ~from ~subject ~attach:[logfile] to_
+  );
+
   let key = sprintf "libguestfs_commit_tested_%s" commit in
   target (memory_exists key);
+  onrun (fun () -> memory_set key "1");
 
   let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
   require (directory_exists repodir);
@@ -181,9 +205,7 @@ and commit_tested branch commit =
   " repodir
     commit
     (quote (libguestfs_localconfigure `Git))
-    (quote libguestfs_localenv);
-
-  memory_set key "1"
+    (quote libguestfs_localenv)
 
 (* Helper function to make a full 'info' object from a version
  * number.
@@ -252,7 +274,7 @@ let git_force url branch =
 
 let () =
   (* Add a periodic job to check for new git commits and test them. *)
-  every 5 minutes ~name:"new libguestfs commit" (
+  every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
     fun () ->
       git_force "https://github.com/libguestfs/libguestfs.git" "master";
 
@@ -261,7 +283,7 @@ let () =
   );
 
   (* Periodic job to build new tarballs. *)
-  every 5 minutes ~name:"new libguestfs version" (
+  every libguestfs_query_mins minutes ~name:"new libguestfs version" (
     fun () ->
       git_force "https://github.com/libguestfs/libguestfs.git" "master";