Skip to content

Commit baa04e5

Browse files
authored
fix(ci): checkout a greater depth in regression workflow (#17604)
- Forces a greater depth when checking out the PR branch. - This can later be improved to try a smaller depth, and keep increasing that until the base sha is found.
1 parent 9395eba commit baa04e5

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

.github/workflows/regression.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,31 @@ jobs:
129129

130130
- uses: actions/checkout@v3
131131

132-
- name: Checkout PR branch (issue_comment)
132+
- name: Checkout PR (issue_comment)
133133
if: github.event_name == 'issue_comment'
134134
env:
135135
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136136
run: gh pr checkout ${{ github.event.issue.number }}
137137

138+
- name: Get PR branch name (issue_comment)
139+
id: get-pr-branch-name
140+
if: github.event_name == 'issue_comment'
141+
env:
142+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
run: |
144+
export BRANCH=$(git branch --show-current)
145+
echo "BRANCH=${BRANCH}"
146+
echo "BRANCH=${BRANCH}" >> $GITHUB_OUTPUT
147+
148+
- name: Checkout PR branch (issue_comment)
149+
if: github.event_name == 'issue_comment'
150+
uses: actions/checkout@v3
151+
with:
152+
# TODO: this can be done more elegantly in a follow-up by using a depth value and
153+
# increasing it until the merge-base is found.
154+
fetch-depth: 500
155+
ref: "${{ steps.get-pr-branch-name.outputs.BRANCH }}"
156+
138157
# If triggered by issue comment, the event payload doesn't directly contain the head and base sha from the PR.
139158
# But, we can retrieve this info from some commands.
140159
- name: Get PR metadata (issue_comment)
@@ -166,6 +185,21 @@ jobs:
166185
echo "comparison sha is: ${COMPARISON_SHA}"
167186
echo "comparison tag is: ${COMPARISON_TAG}"
168187
188+
if [ "${BASELINE_SHA}" = "" ] ; then
189+
echo "BASELINE_SHA not found, exiting."
190+
exit 1
191+
fi
192+
193+
if [ "${COMPARISON_SHA}" = "" ] ; then
194+
echo "COMPARISON_SHA not found, exiting."
195+
exit 1
196+
fi
197+
198+
if [ "${PR_NUMBER}" = "" ] ; then
199+
echo "PR_NUMBER not found, exiting."
200+
exit 1
201+
fi
202+
169203
# If triggered by merge queue, the PR number is not available in the payload. While we restrict the number of PRs in the
170204
# queue to 1, we can get the PR number by parsing the merge queue temp branch's ref.
171205
- name: Get PR metadata (merge queue)
@@ -195,6 +229,21 @@ jobs:
195229
echo "comparison sha is: ${COMPARISON_SHA}"
196230
echo "comparison tag is: ${COMPARISON_TAG}"
197231
232+
if [ "${BASELINE_SHA}" = "" ] ; then
233+
echo "BASELINE_SHA not found, exiting."
234+
exit 1
235+
fi
236+
237+
if [ "${COMPARISON_SHA}" = "" ] ; then
238+
echo "COMPARISON_SHA not found, exiting."
239+
exit 1
240+
fi
241+
242+
if [ "${PR_NUMBER}" = "" ] ; then
243+
echo "PR_NUMBER not found, exiting."
244+
exit 1
245+
fi
246+
198247
- name: Setup experimental metadata
199248
id: experimental-meta
200249
run: |

0 commit comments

Comments
 (0)