Skip to content

Commit 3022f03

Browse files
committed
Get reliable base ref for push-triggered "Compare Performance" workflow
The "Compare Performance" GitHub Actions workflow is intended to assist in the evaluation of performance impact of proposed changes to the tool. It does this by comparing the duration of a run of the engine at the head ref of the proposal against a base ref. In the case where the workflow is triggered by a `push` event from a commit, the base ref should be the parent commit. The previous approach of using the `github.event.before` context item was unreliable because this is set to the fake ref `0000000000000000000000000000000000000000` when there has not been a previous workflow run on the branch (as is the case when branch and commit are pushed from a local to the remote).
1 parent 53e02d4 commit 3022f03

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.github/workflows/compare-performance.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ jobs:
3636
steps:
3737
# Repo is required to get the previous tag ref that is the base of the comparison on tag push triggered run.
3838
- name: Checkout repository
39-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
39+
if: github.event_name == 'push'
4040
uses: actions/checkout@v2
41+
with:
42+
# Parent commit is needed for determining the base ref on commit push trigg.
43+
fetch-depth: 2
4144

4245
- name: Determine comparison ref
4346
id: base-ref
@@ -60,7 +63,7 @@ jobs:
6063
head -1
6164
)"
6265
else
63-
COMPARISON_REF="${{ github.event.before }}"
66+
COMPARISON_REF="$(git rev-parse ${{ github.sha }}^)"
6467
fi
6568
6669
if [[ "$COMPARISON_REF" == "" ]]; then

0 commit comments

Comments
 (0)