Skip to content

Commit 3a7f84f

Browse files
committed
try merge
1 parent ed6ff04 commit 3a7f84f

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

.github/workflows/benchmarks.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ jobs:
3333
run: bundle install
3434
- name: Run benchmarks
3535
run: bundle exec rake
36-
- name: Generate Markdown page for all versions
37-
run: bundle exec rake generate_versions_html
36+
- name: Generate HTML files for each benchmark
37+
run: |
38+
for v in $(ls reports); do
39+
mkdir -p html_reports/$v
40+
for f in $(ls reports/$v/*.txt); do
41+
ruby scripts/generate_benchmarks_html.rb "$f" "html_reports/$v/$(basename $f .txt).html"
42+
done
43+
done
44+
- name: Upload HTML reports as artifacts
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: html-reports
48+
path: html_reports/**/*
3849

3950
publish:
4051
needs: rake
@@ -43,9 +54,14 @@ jobs:
4354
- uses: actions/checkout@v3
4455
with:
4556
fetch-depth: 0
46-
- name: Copy generated Markdown page
57+
- name: Download HTML reports
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: html-reports
61+
path: all_html_reports
62+
- name: Merge all HTML files into one
4763
run: |
48-
cp all_versions_benchmarks.html ./
64+
ruby scripts/merge_html_reports.rb all_html_reports merged_benchmarks.html
4965
touch .nojekyll
5066
- name: Prepare gh-pages branch
5167
run: |
@@ -54,10 +70,10 @@ jobs:
5470
git fetch origin gh-pages || git checkout --orphan gh-pages
5571
git checkout gh-pages || git checkout --orphan gh-pages
5672
rm -rf *
57-
cp all_versions_benchmarks.html ./
73+
cp merged_benchmarks.html ./
5874
touch .nojekyll
59-
- name: Commit and push Markdown page
75+
- name: Commit and push merged HTML page
6076
run: |
6177
git add .
62-
git commit -m "Update all versions benchmark HTML [ci skip]" || echo "No changes to commit"
78+
git commit -m "Update merged benchmark HTML [ci skip]" || echo "No changes to commit"
6379
git push origin gh-pages

scripts/merge_html_reports.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# scripts/merge_html_reports.rb
2+
# Merges all HTML files in a directory tree into a single HTML file with collapsible blocks.
3+
4+
require 'find'
5+
require 'pathname'
6+
7+
input_dir = ARGV[0] || 'all_html_reports'
8+
output = ARGV[1] || 'merged_benchmarks.html'
9+
10+
html_files = []
11+
Find.find(input_dir) do |path|
12+
html_files << path if path =~ /\.html$/
13+
end
14+
15+
blocks = html_files.sort.map do |file|
16+
name = Pathname(file).each_filename.to_a[-2..-1].join(' / ')
17+
content = File.read(file)
18+
"<details><summary>#{name}</summary>\n#{content}\n</details>"
19+
end
20+
21+
page = <<-HTML
22+
<!DOCTYPE html>
23+
<html lang="en">
24+
<head>
25+
<meta charset="UTF-8">
26+
<title>All Ruby Benchmarks</title>
27+
<style>
28+
body { font-family: Arial, sans-serif; margin: 2em; }
29+
details { margin-bottom: 1em; }
30+
summary { font-weight: bold; cursor: pointer; }
31+
pre { background: #f4f4f4; padding: 1em; border-radius: 5px; }
32+
</style>
33+
</head>
34+
<body>
35+
<h1>All Ruby Benchmarks</h1>
36+
#{blocks.join("\n\n")}
37+
</body>
38+
</html>
39+
HTML
40+
41+
File.write(output, page)
42+
puts "Merged HTML written to #{output}"

0 commit comments

Comments
 (0)