Skip to content

Commit 999a71c

Browse files
committed
Automate updates of subtree/library branch
There should not be a need for manual processes for this stage of the subtree update. Merge conflicts (which might require a human to intervene) will only happen once attempting to merge from subtree/library back into main. Automation for that step will follow in a separate PR.
1 parent 3cc0686 commit 999a71c

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Kani Metrics Update
2+
3+
on:
4+
schedule:
5+
- cron: '0 14 * * *' # Run at 14:00 UTC every day
6+
workflow_dispatch:
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
jobs:
13+
update-subtree-library:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Fetch Kani toolchain version
21+
run: |
22+
mkdir kani-tmp
23+
cd kani-tmp
24+
git init
25+
git remote add origin https://github.com/model-checking/kani
26+
git fetch --depth 1 origin main
27+
git checkout main
28+
TOOLCHAIN_DATE=$(grep -oP 'channel = "nightly-\K\d{4}-\d{2}-\d{2}' rust-toolchain.toml)
29+
COMMIT_HASH=$(curl https://static.rust-lang.org/dist/$TOOLCHAIN_DATE/channel-rust-nightly-git-commit-hash.txt)
30+
if [ -z "$COMMIT_HASH" ]; then
31+
echo "Could not find commit hash on static.rust-lang.org"
32+
exit 1
33+
fi
34+
echo "Kani toolchain date: ${TOOLCHAIN_DATE}"
35+
echo "TOOLCHAIN_DATE=${TOOLCHAIN_DATE}" >> $GITHUB_ENV
36+
echo "Kani toolchain hash: ${COMMIT_HASH}"
37+
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
38+
cd ..
39+
rm -r kani-tmp
40+
41+
- name: Update subtree/library locally
42+
run: |
43+
git remote add upstream https://github.com/rust-lang/rust
44+
git fetch upstream
45+
46+
# Ensure "upstream/master" branch contains the target commit
47+
if ! git show ${COMMIT_HASH} --oneline --no-patch; then
48+
echo "Rust commit ${COMMIT_HASH} cannot be found."
49+
exit 1
50+
fi
51+
52+
# subtree/library has the subtree-split variant of a commit that previously
53+
# went into upstream/master. Running `git subtree split` on top of the
54+
# original commit is much faster (my experiment when working on 280k+
55+
# commits: 113 seconds vs 613 seconds) than using the HEAD commit from
56+
# subtree/library as base.
57+
SUBTREE_HEAD=$(git log --format=%s -n 1 origin/subtree/library)
58+
echo "SUBTREE_HEAD: ${SUBTREE_HEAD}"
59+
UPSTREAM_ONTO=$(git log --grep=$SUBTREE_HEAD -n 1 --format=%H upstream/master)
60+
echo "UPSTREAM_ONTO: ${UPSTREAM_ONTO}"
61+
62+
git checkout ${COMMIT_HASH}
63+
git subtree split --prefix=library --onto $UPSTREAM_ONTO -b subtree/library
64+
65+
- name: Create Pull Request
66+
uses: peter-evans/create-pull-request@v7
67+
with:
68+
commit-message: Update Kani metrics
69+
title: 'Update subtree/library'
70+
body: |
71+
This is an automated PR to update the subtree/library branch to the changes
72+
up to and including ${{ env.COMMIT_HASH }} of ${{ env.TOOLCHAIN_DATE }}.
73+
branch: update-subtree/library
74+
delete-branch: true
75+
base: subtree/library

0 commit comments

Comments
 (0)