diff --git a/bin/rbpkg_ci_mux b/bin/rbpkg_ci_mux
index ddd883d..3a27a49 100755
--- a/bin/rbpkg_ci_mux
+++ b/bin/rbpkg_ci_mux
@@ -85,53 +85,7 @@ def rbpkg_ci_mux
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
- 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
+ Rbpkg.ci_mux
end
begin
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index 041e605..ffc6bcb 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -36,7 +36,7 @@ module Rbpkg
end
def self.ci_build_dir
- "#{ci_dir}/build"
+ "#{ci_dir}/build/#{os}/#{target}"
end
def self.ci_init
@@ -53,6 +53,99 @@ module Rbpkg
"#{ci_dir}/log/#{os}/#{target}/#{date}_#{$$}"
end
+ def self.ci_mux
+ status = {}
+ Dir.chdir("#{ci_dir}/status") do
+ Dir["*/*"].each do |d|
+ Dir.chdir(d) 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).strip
+ 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
+ log = {}
+ Dir.chdir("#{Rbpkg.ci_dir}/log") do
+ Dir["*/*"].each do |d|
+ Dir.chdir(d) 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|
+ File.open("#{name}.html", "w") do |output|
+ status_file = "#{Rbpkg.ci_dir}/status/#{name}.status"
+ s = File.read(status_file).strip
+ img = status_img(s)
+ output.puts <<-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>#{name.to_html}</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>
+ <div class="ci-header">
+ <a href="./"><i class="fas fa-asterisk"></i> All logs</a>
+ </div>
+ <h1>
+ <img src="#{img}" class="status-#{s.to_html}"/>
+ #{name.to_html}
+ </h1>
+ <ul class="list-group">
+EOF
+ logs = Dir["*/*/#{name}.log"].map do |subdir_file|
+ status_file = "#{Rbpkg.ci_dir}/status/#{subdir_file.gsub(/.log$/, ".status")}"
+ s = File.read(status_file).strip
+ img = status_img(s)
+ subdir_file_html = subdir_file.to_html
+ output.puts <<-EOF
+ <li class="list-group-item">
+ <img src="#{img}" class="status-#{s.to_html}"/>
+ <a href="#{subdir_file_html}">#{subdir_file_html}</a>
+ </li>
+EOF
+ end
+ output.puts <<-EOF
+ </ul>
+ </body>
+</html>
+EOF
+ end
+ end
+ end
+ end
+
def self.ci_remote(repo, branch, commit, host)
verbose(3, "Rbpkg.ci_remote(#{repo.inspect}, #{branch.inspect}, #{commit.inspect}, #{host.inspect})")
sh_host = sh_quote(host)
@@ -299,6 +392,13 @@ module Rbpkg
"#{dir}/src"
end
+ def self.status_img(status)
+ path = "#{File.dirname(File.dirname(__FILE__))}/share/icon/64x64/status_#{status}.png"
+ file = File.read(path)
+ base64 = Base64.encode64(file)
+ "data:image/png;base64,#{base64}"
+ end
+
def self.tag_dir
"#{target_dir}/tag"
end
diff --git a/lib/rbpkg/log.rb b/lib/rbpkg/log.rb
index 6ceab40..4037cd4 100644
--- a/lib/rbpkg/log.rb
+++ b/lib/rbpkg/log.rb
@@ -15,10 +15,7 @@ module Rbpkg
end
def img
- path = "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/share/icon/64x64/status_#{status}.png"
- file = File.read(path)
- base64 = Base64.encode64(file)
- "data:image/png;base64,#{base64}"
+ Rbpkg.status_img(status)
end
def put_layout