Skip to content

Commit 80dbed6

Browse files
authored
Add action for Benchmark on release (#391)
1 parent e92555c commit 80dbed6

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Benchmark on release
2+
3+
on:
4+
release:
5+
types: [published]
6+
jobs:
7+
bench:
8+
# Skip running on forks
9+
if: ${{ !github.event.repository.fork }}
10+
runs-on: ubuntu-latest
11+
permissions: contents: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- uses: julia-actions/setup-julia@v2
17+
with:
18+
version: '1'
19+
- uses: julia-actions/cache@v1
20+
- uses: julia-actions/julia-buildpkg@v1
21+
- name: Instantiate benchmark env
22+
run: julia --project=benchmark -e 'using Pkg; Pkg.instantiate()'
23+
- name: Install benchmark deps
24+
run: julia --project=benchmark -e 'using Pkg; pkg"add PkgBenchmark"'
25+
- name: Run PkgBenchmark and save results
26+
run: |
27+
julia --project=benchmark -e '
28+
using Dates, PkgBenchmark
29+
# Run benchmarks; adjust the script path if yours differs
30+
res = benchmarkpkg(pwd(); script="benchmark/benchmarks.jl")
31+
32+
# Save a machine-readable file
33+
writeresults("benchmark-result.json", res)
34+
35+
# Also emit a lightweight Markdown summary
36+
open("benchmark-result.md", "w") do io
37+
println(io, "# Benchmark results for $(get(ENV, "GITHUB_REF_NAME", "unknown"))")
38+
println(io, "")
39+
println(io, "> Tag: $(get(ENV, "GITHUB_REF_NAME", "unknown"))")
40+
println(io, "> Date: $(Dates.format(Dates.now(), "yyyy-mm-dd HH:MM")) UTC")
41+
println(io, "")
42+
show(io, "text/plain", res) # plain-text tree; renders fine in Markdown
43+
println(io)
44+
end
45+
'
46+
- name: Upload benchmark artifacts
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: benchmark-${{ github.event.release.tag_name }}
50+
path: |
51+
benchmark-result.json
52+
benchmark-result.md
53+
- name: Upload assets to the GitHub Release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
tag_name: ${{ github.event.release.tag_name }}
57+
files: |
58+
benchmark-result.json
59+
benchmark-result.md
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)