Skip to content

Commit 01b1188

Browse files
committed
Fix commit comparison in benchmark pr basic
1 parent 54fbd7d commit 01b1188

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

.github/workflows/benchmark_pr.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Install and Build Benchmarking Tools
6060
run: |
6161
julia -e 'using Pkg; Pkg.add("AirspeedVelocity"); Pkg.build("AirspeedVelocity")'
62-
echo "$HOME/.julia/bin" >> $GITHUB_ENV
62+
echo "PATH=$PATH:$HOME/.julia/bin" >> $GITHUB_ENV
6363
ls $HOME/.julia/bin
6464
6565
- name: Run Benchmarks
@@ -68,11 +68,15 @@ jobs:
6868
mkdir results
6969
benchpkg --rev="${{ github.sha }},$(git rev-parse HEAD^1)" --bench-on="${{ github.sha }}" --output-dir=results/ --tune
7070
71-
- name: Generate and Upload Benchmark Plots
72-
run: |
73-
mkdir plots
74-
benchpkgplot --rev="${{ github.sha }},$(git rev-parse HEAD^1)" --npart=10 --format=png --input-dir=results/ --output-dir=plots/
75-
if: always()
71+
- name: Generate and Upload Benchmark Plots
72+
run: |
73+
mkdir -p plots
74+
git fetch origin main:refs/remotes/origin/main
75+
LAST_MAIN_COMMIT=$(git rev-parse origin/main)
76+
CURRENT_COMMIT=$(git rev-parse HEAD)
77+
echo "Comparing CURRENT_COMMIT ($CURRENT_COMMIT) with LAST_MAIN_COMMIT ($LAST_MAIN_COMMIT)"
78+
benchpkgplot --rev="$LAST_MAIN_COMMIT,$CURRENT_COMMIT" --npart=10 --format=png --input-dir=results/ --output-dir=plots/
79+
if: always()
7680
7781
- name: Upload Plots as Artifacts
7882
uses: actions/upload-artifact@v4
@@ -82,13 +86,21 @@ jobs:
8286

8387
- name: Create and Display Benchmark Table
8488
run: |
85-
benchpkgtable --rev="${{ github.sha }},$(git rev-parse HEAD^1)" --input-dir=results/ > table.md
86-
cat table.md
89+
git fetch origin main:refs/remotes/origin/main # Ensures you have the latest main branch
90+
if [ $(git rev-list --count HEAD) -gt 1 ]; then
91+
PREV_COMMIT=$(git rev-parse HEAD^1)
92+
else
93+
PREV_COMMIT=$(git rev-parse HEAD) # Fallback to the current commit if there's no previous commit
94+
fi
95+
LAST_MAIN_COMMIT=$(git rev-parse origin/main) # Ensures comparison against the latest commit in main
96+
echo "Using revisions: $LAST_MAIN_COMMIT and $PREV_COMMIT for benchmark comparison."
97+
benchpkgtable --rev="$LAST_MAIN_COMMIT,$PREV_COMMIT" --input-dir=results/ > table.md
8798
echo '### Benchmark Results' > body.md
8899
cat table.md >> body.md
89100
echo '### Benchmark Plots' >> body.md
90101
echo 'A plot of the benchmark results has been uploaded as an artifact to this workflow run.' >> body.md
91102
cat body.md # Print the markdown table to the log for review.
103+
if: always()
92104

93105
- name: Upload Benchmark Results Table
94106
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)