Skip to content

Commit c1bf2e1

Browse files
committed
CI: create dummy .benchmarkci/result-target.json and artifact when baseline/results missing (non-fatal on forks)
1 parent 1395f0a commit c1bf2e1

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

.github/workflows/benchmark.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,46 @@ jobs:
2424
run: |
2525
julia -e '
2626
using BenchmarkCI
27+
success = true
2728
try
2829
BenchmarkCI.judge()
2930
catch err
3031
@info "BenchmarkCI.judge failed (likely missing baseline)" err=err
31-
# allow workflow to continue
32+
success = false
33+
end
34+
if success
35+
try
36+
BenchmarkCI.displayjudgement()
37+
catch err
38+
@info "BenchmarkCI.displayjudgement failed (no results)" err=err
39+
success = false
40+
end
41+
end
42+
if !success
43+
mkpath(".benchmarkci")
44+
open(".benchmarkci/result-target.json", "w") do io
45+
write(io, "{}")
46+
end
47+
open("benchmark-result.artifact", "w") do io
48+
write(io, "Benchmark skipped on fork: missing baseline")
49+
end
3250
end
33-
BenchmarkCI.displayjudgement()
3451
'
3552

3653
# generate and record the benchmark result as markdown
3754
- name: generate benchmark result
3855
run: |
3956
body=$(julia -e '
40-
using BenchmarkCI
41-
42-
let
43-
judgement = BenchmarkCI._loadjudge(BenchmarkCI.DEFAULT_WORKSPACE)
44-
title = "Benchmark Result"
45-
ciresult = BenchmarkCI.CIResult(; judgement, title)
46-
BenchmarkCI.printcommentmd(stdout::IO, ciresult)
57+
try
58+
using BenchmarkCI
59+
let
60+
judgement = BenchmarkCI._loadjudge(BenchmarkCI.DEFAULT_WORKSPACE)
61+
title = "Benchmark Result"
62+
ciresult = BenchmarkCI.CIResult(; judgement, title)
63+
BenchmarkCI.printcommentmd(stdout::IO, ciresult)
64+
end
65+
catch err
66+
println("Benchmark skipped: $(err)")
4767
end
4868
')
4969
body="${body//'%'/'%25'}"

0 commit comments

Comments
 (0)