Commit a72143de96ccd70474c1e1c7212c61d841b8a2e4

Thomas de Grivel 2023-02-26T01:47:22

rbpkg_ci_mux

diff --git a/bin/rbpkg_ci_mux b/bin/rbpkg_ci_mux
index ebb80f6..ddd883d 100755
--- a/bin/rbpkg_ci_mux
+++ b/bin/rbpkg_ci_mux
@@ -33,6 +33,7 @@ end
 
 def rbpkg_ci_mux
   clean = false
+  remote = true
   upgrade = false
   while case $ARGS[0]
         when "--clean"
@@ -42,6 +43,9 @@ def rbpkg_ci_mux
           usage
         when "--help"
           usage
+        when "--no-remote"
+          remote = false
+          shift
         when "--upgrade"
           Rbpkg.upgrade_self
           shift
@@ -59,23 +63,74 @@ def rbpkg_ci_mux
     verbose(1, cmd)
     raise "command failed: #{cmd.inspect}" unless system(cmd)
     Rbpkg.ci_init
-    hosts.each do |host|
-      cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg_ci --clean"
+    if remote
+      hosts.each do |host|
+        cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg_ci --clean"
+      end
     end
-  end      
-  if upgrade
+  end
+  if upgrade && remote
     hosts.each do |host|
       cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg upgrade"
     end
   end
-  hosts.each do |host|
-    Thread.report_on_exception = false
-    threads << Thread.new do
-      Rbpkg.ci_remote(repo, branch, commit, host)
+  if remote
+    hosts.each do |host|
+      Thread.report_on_exception = false
+      threads << Thread.new do
+        Rbpkg.ci_remote(repo, branch, commit, host)
+      end
+    end
+    threads.each do |t|
+      t.join
+    end
+  end
+  status = {}
+  Dir.chdir("#{Rbpkg.ci_dir}/status") do
+    Dir["*/*"].each do |dir|
+      Dir.chdir(dir) do
+        Dir["*/*.status"].each do |subdir_file|
+          name = File.basename(subdir_file, ".status")
+          file = "#{name}.status"
+          if ! status[name] || ! FileUtils.uptodate?(file, [subdir_file])
+            FileUtils.cp(subdir_file, file)
+            case File.read(file)
+            when "running"
+              status[name] = :running
+            when "ko"
+              if status[name] != :running
+                status[name] = :ko
+              end
+            when "ok"
+              if ! status[name]
+                status[name] = :ok
+              end
+            end
+          end
+        end
+      end
+    end
+    status.each do |name, status|
+      File.write("#{name}.status", status)
     end
   end
-  threads.each do |t|
-    t.join
+  log = {}
+  Dir.chdir("#{Rbpkg.ci_dir}/log") do
+    Dir["*/*"].each do |dir|
+      Dir.chdir(dir) do
+        Dir["*/*.log"].each do |subdir_file|
+          name = File.basename(subdir_file, ".log")
+          file = "#{name}.log"
+          if ! log[name] || ! FileUtils.uptodate?(file, [subdir_file])
+            FileUtils.cp(subdir_file, file)
+            log[name] = true
+          end
+        end
+      end
+    end
+    log.each do |name, l|
+      puts name
+    end
   end
 end