Skip to content

Commit 9c70ea9

Browse files
committed
build: guard against missing commit hash
1 parent 896bdee commit 9c70ea9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/run_affected_benchmarks.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ jobs:
9999
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
100100
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
101101
else
102-
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
103-
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
104-
files=$(git diff --diff-filter=AM --name-only HEAD~ ${{ github.event.after }})
102+
# Check if the commit SHA exists:
103+
if git rev-parse ${{ github.event.before }} >/dev/null 2>&1 && git rev-parse ${{ github.event.after }} >/dev/null 2>&1; then
104+
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
105+
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
106+
files=$(git diff --diff-filter=AM --name-only HEAD~ ${{ github.event.after }})
107+
else
108+
files=$(git diff --diff-filter=AM --name-only ${{ github.event.before }} ${{ github.event.after }})
109+
fi
105110
else
106-
files=$(git diff --diff-filter=AM --name-only ${{ github.event.before }} ${{ github.event.after }})
111+
echo "Commit SHA not found, skipping file changes detection..."
112+
files=""
107113
fi
108114
fi
109115
# Keep only benchmark files:

0 commit comments

Comments
 (0)