Skip to content

Commit 4f3c5d5

Browse files
committed
Subtree update automation: use fast version of subtree split
repo-filter does not produce consistent SHA hashes. While we were aware of this, we hadn't realized that this made incremental non-interactive updates of the branch a matter of luck as git may or may not be able to automatically resolve conflicts. (It worked for the update to 2025-02-10, but failed for the next one.) git-subtree-split does produce consistent SHA hashes, but the native `git-subtree-split` implementation is a shell script, and thus was found to be too slow (which is why we chose repo-filter in the first place). splitsh-lite is an implementation of just the `subtree split` command in Go and libgit2. This makes `subtree split` even faster than `repo-filter` at 35 seconds vs 50 seconds (on a GitHub runner).
1 parent 05d9d56 commit 4f3c5d5

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

.github/workflows/update-subtree.yml

+28-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ defaults:
1111

1212
jobs:
1313
update-subtree-library:
14-
runs-on: ubuntu-latest
14+
# Changing the host platform may alter the libgit2 version as used by
15+
# splitsh-lite, which will require changing the version of git2go.
16+
# See https://github.com/jeffWelling/git2go?tab=readme-ov-file#which-go-version-to-use
17+
runs-on: ubuntu-24.04
1518

1619
steps:
1720
- name: Checkout Repository
@@ -34,12 +37,6 @@ jobs:
3437
fetch-depth: 0
3538
path: rust-tmp
3639

37-
- name: Checkout git-filter-repo
38-
uses: actions/checkout@v4
39-
with:
40-
repository: newren/git-filter-repo
41-
path: git-filter-repo
42-
4340
- name: Fetch toolchain versions
4441
run: |
4542
CURRENT_TOOLCHAIN_DATE=$(grep -oP 'channel = "nightly-\K\d{4}-\d{2}-\d{2}' verify-rust-std/rust-toolchain.toml)
@@ -77,6 +74,24 @@ jobs:
7774
env:
7875
GH_TOKEN: ${{ github.token }}
7976

77+
- name: Checkout splitsh-lite
78+
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
79+
uses: actions/checkout@v4
80+
with:
81+
repository: splitsh/lite
82+
path: splitsh-lite
83+
84+
- name: Build splitsh-lite
85+
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
86+
run: |
87+
cd splitsh-lite
88+
sudo apt-get install -y libgit2-dev
89+
sed -i 's#github.com/libgit2/git2go#github.com/jeffwelling/git2go#' go.mod splitter/*
90+
sed -i -e 's/v34/v37/g' go.mod splitter/*.go
91+
sed -i 's/v37.0.0/v37.0.4/' go.mod
92+
go mod tidy
93+
go build -o splitsh-lite github.com/splitsh/lite
94+
8095
- name: Update subtree/library locally
8196
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
8297
run: |
@@ -89,16 +104,13 @@ jobs:
89104
fi
90105
91106
git checkout ${NEXT_COMMIT_HASH}
92-
../git-filter-repo/git-filter-repo --subdirectory-filter library --force
93-
git checkout -b subtree/library
107+
/usr/bin/time -v ../splitsh-lite/splitsh-lite --progress --prefix=library --target subtree/library
108+
git checkout -b subtree/library subtree/library
94109
95110
cd ../verify-rust-std
96111
git remote add rust-filtered ../rust-tmp/
97112
git fetch rust-filtered
98113
git checkout -b subtree/library rust-filtered/subtree/library
99-
# The filter-subtree operation adds an extraneous `library/` folder containing the submodules
100-
# (c.f. https://github.com/model-checking/verify-rust-std/issues/249), so remove that before committing.
101-
rm -rf library
102114
SUBTREE_HEAD_MSG=$(git log --format=%s -n 1 origin/subtree/library)
103115
UPSTREAM_FROM=$(git log --grep="${SUBTREE_HEAD_MSG}" -n 1 --format=%H rust-filtered/subtree/library)
104116
UPSTREAM_HEAD=$(git log --format=%H -n 1 rust-filtered/subtree/library)
@@ -107,7 +119,6 @@ jobs:
107119
echo "MERGE_CONFLICTS=noop" >> $GITHUB_ENV
108120
else
109121
git branch --set-upstream-to=origin/subtree/library
110-
git -c user.name=gitbot -c user.email=git@bot rebase
111122
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
112123
fi
113124
@@ -130,12 +141,15 @@ jobs:
130141
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.MERGE_PR_EXISTS == 'no' }}
131142
run: |
132143
cd verify-rust-std
144+
if ! git rev-parse --verify subtree/library; then
145+
git checkout -t -b subtree/library origin/update-subtree/library
146+
fi
133147
git checkout main
134148
135149
# This command may fail, which will require human intervention.
136150
if ! git \
137151
-c user.name=gitbot -c user.email=git@bot \
138-
subtree merge --prefix=library update-subtree/library --squash; then
152+
subtree merge --prefix=library subtree/library --squash; then
139153
echo "MERGE_CONFLICTS=yes" >> $GITHUB_ENV
140154
git -c user.name=gitbot -c user.email=git@bot commit -a -m "Merge from $NEXT_COMMIT_HASH with conflicts"
141155
else

0 commit comments

Comments
 (0)