Skip to content

Commit 576828e

Browse files
Sjorsryanofsky
andcommitted
ci: test-each-commit merge base optional
The ci "test-each-commit" job fetches the PR branch being tested with a depth of (# of commits in PR + 2), and then tries to run tests on commits after the most recent merge commit. When a PR is opened against a bitcoin core branch, a merge commit is always guaranteed to exist within the fetch depth, because bitcoin core branches always point at merge commits. However, in fork repositories, pull requests can be opened based on other branches that don't contain recent merge commits, and this will currently cause git rev-list to fail with fatal: bad revision '^^@'. Work around this problem by not requiring a recent merge commit, and just testing on all fetched commits if a merge commit can't be found. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
1 parent e9bfbb5 commit 576828e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ jobs:
5858
# and the ^ prefix is used to exclude these parents and all their
5959
# ancestors from the rev-list output as described in:
6060
# https://git-scm.com/docs/git-rev-list
61-
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD ^$(git rev-list -n1 --merges HEAD)^@ | head -1)" >> "$GITHUB_ENV"
61+
MERGE_BASE=$(git rev-list -n1 --merges HEAD)
62+
EXCLUDE_MERGE_BASE_ANCESTORS=
63+
# MERGE_BASE can be empty due to limited fetch-depth
64+
if test -n "$MERGE_BASE"; then
65+
EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@
66+
fi
67+
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
6268
- run: |
6369
sudo apt-get update
6470
sudo apt-get install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y

0 commit comments

Comments
 (0)