Skip to content

Commit abf0bcf

Browse files
authored
use AirspeedVelocity for benchmark CI (#502)
1 parent 899eeb1 commit abf0bcf

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/benchmark_pr.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Benchmark a pull request
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
pull-requests: write
8+
9+
jobs:
10+
generate_plots:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: julia-actions/setup-julia@v1
16+
with:
17+
version: "1"
18+
- uses: julia-actions/cache@v1
19+
- name: Extract Package Name from Project.toml
20+
id: extract-package-name
21+
run: |
22+
PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/')
23+
echo "::set-output name=package_name::$PACKAGE_NAME"
24+
- name: Build AirspeedVelocity
25+
env:
26+
JULIA_NUM_THREADS: 2
27+
run: |
28+
# Lightweight build step, as sometimes the runner runs out of memory:
29+
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add("AirspeedVelocity")'
30+
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")'
31+
- name: Add ~/.julia/bin to PATH
32+
run: |
33+
echo "$HOME/.julia/bin" >> $GITHUB_PATH
34+
- name: Run benchmarks
35+
run: |
36+
echo $PATH
37+
ls -l ~/.julia/bin
38+
mkdir results
39+
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune
40+
- name: Create plots from benchmarks
41+
run: |
42+
mkdir -p plots
43+
benchpkgplot ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --npart=10 --format=png --input-dir=results/ --output-dir=plots/
44+
- name: Upload plot as artifact
45+
uses: actions/upload-artifact@v2
46+
with:
47+
name: plots
48+
path: plots
49+
- name: Create markdown table from benchmarks
50+
run: |
51+
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md
52+
echo '### Benchmark Results' > body.md
53+
echo '' >> body.md
54+
echo '' >> body.md
55+
cat table.md >> body.md
56+
echo '' >> body.md
57+
echo '' >> body.md
58+
echo '### Benchmark Plots' >> body.md
59+
echo 'A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.' >> body.md
60+
echo 'Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).' >> body.md
61+
62+
- name: Find Comment
63+
uses: peter-evans/find-comment@v2
64+
id: fcbenchmark
65+
with:
66+
issue-number: ${{ github.event.pull_request.number }}
67+
comment-author: 'github-actions[bot]'
68+
body-includes: Benchmark Results
69+
70+
- name: Comment on PR
71+
uses: peter-evans/create-or-update-comment@v3
72+
with:
73+
comment-id: ${{ steps.fcbenchmark.outputs.comment-id }}
74+
issue-number: ${{ github.event.pull_request.number }}
75+
body-path: body.md
76+
edit-mode: replace

0 commit comments

Comments
 (0)