11name : Benchmarking
22
33on :
4- push :
5- branches :
6- - master
4+ pull_request :
75
86jobs :
9- benchmark :
7+ benchmarks :
108 runs-on : ubuntu-latest
119
1210 steps :
1311 - name : Checkout Repository
1412 uses : actions/checkout@v4
13+ with :
14+ ref : ${{ github.event.pull_request.head.sha }}
1515
1616 - name : Set up Julia
1717 uses : julia-actions/setup-julia@v2
@@ -21,12 +21,46 @@ jobs:
2121 - name : Install Dependencies
2222 run : julia --project=benchmarks/ -e 'using Pkg; Pkg.instantiate()'
2323
24- - name : Run Benchmarks and Generate Reports
25- run : julia --project=benchmarks/ -e 'using DynamicPPLBenchmarks; weave_benchmarks()'
24+ - name : Run Benchmarks
25+ id : run_benchmarks
26+ run : |
27+ # Capture version info into a variable, print it, and set it as an env var for later steps
28+ version_info=$(julia -e 'using InteractiveUtils; versioninfo()')
29+ echo "$version_info"
30+ echo "VERSION_INFO<<EOF" >> $GITHUB_ENV
31+ echo "$version_info" >> $GITHUB_ENV
32+ echo "EOF" >> $GITHUB_ENV
33+
34+ # Capture benchmark output into a variable
35+ echo "Running Benchmarks..."
36+ benchmark_output=$(julia --project=benchmarks benchmarks/benchmarks.jl)
37+
38+ # Print benchmark results directly to the workflow log
39+ echo "Benchmark Results:"
40+ echo "$benchmark_output"
41+
42+ # Set the benchmark output as an env var for later steps
43+ echo "BENCHMARK_OUTPUT<<EOF" >> $GITHUB_ENV
44+ echo "$benchmark_output" >> $GITHUB_ENV
45+ echo "EOF" >> $GITHUB_ENV
46+
47+ - name : Find Existing Comment
48+ uses : peter-evans/find-comment@v3
49+ id : find_comment
50+ with :
51+ issue-number : ${{ github.event.pull_request.number }}
52+ comment-author : github-actions[bot]
2653
27- - name : Deploy to GitHub Pages
28- uses : peaceiris/actions-gh-pages@v3
54+ - name : Post Benchmark Results as PR Comment
55+ uses : peter-evans/create-or-update-comment@v4
2956 with :
30- github_token : ${{ secrets.GITHUB_TOKEN }}
31- publish_dir : ./benchmarks/results
32- publish_branch : gh-pages
57+ issue-number : ${{ github.event.pull_request.number }}
58+ body : |
59+ ## Computer Information
60+ ```
61+ ${{ env.VERSION_INFO }}
62+ ```
63+ ## Benchmark Report
64+ ${{ env.BENCHMARK_OUTPUT }}
65+ comment-id : ${{ steps.find_comment.outputs.comment-id }}
66+ edit-mode : replace
0 commit comments