Skip to content

Commit 08b8bd7

Browse files
ci: detect new spec files against the merged base, not the stale PR base
pull_request.base.sha is fixed when the PR opens and does not follow the base branch, so a long-lived branch attributes every spec the base gained since then to itself. HEAD is refs/pull/N/merge, whose first parent is the base tip actually merged onto.
1 parent 21ca5a3 commit 08b8bd7

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/ci-tests-e2e.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,16 @@ jobs:
268268
id: detect
269269
run: |
270270
git config --global --add safe.directory "$GITHUB_WORKSPACE"
271-
BASE_SHA="${{ github.event.pull_request.base.sha }}"
272-
NEW_FILES=$(git diff --name-only --diff-filter=A "$BASE_SHA"...HEAD -- browser_tests/tests | grep '\.spec\.ts$' || true)
271+
# HEAD is refs/pull/N/merge, so its first parent is the base tip the PR was merged
272+
# onto. pull_request.base.sha is recorded when the PR opens and does not follow the
273+
# base branch, so diffing against it attributes every spec the base gained since
274+
# then to this PR.
275+
if git rev-parse --verify --quiet HEAD^2 >/dev/null; then
276+
BASE_SHA=$(git rev-parse HEAD^1)
277+
else
278+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
279+
fi
280+
NEW_FILES=$(git diff --name-only --diff-filter=A "$BASE_SHA" HEAD -- browser_tests/tests | grep '\.spec\.ts$' || true)
273281
274282
if [ -z "$NEW_FILES" ]; then
275283
echo "has-new-tests=false" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)