forked from model-checking/verify-rust-std
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (111 loc) · 4.27 KB
/
update-subtree.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Subtree Update
on:
schedule:
- cron: '0 14 * * *' # Run at 14:00 UTC every day
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
update-subtree-library:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: verify-rust-std
- name: Checkout Kani
uses: actions/checkout@v4
with:
repository: model-checking/kani
path: kani-tmp
- name: Checkout Rust
uses: actions/checkout@v4
with:
repository: rust-lang/rust
fetch-depth: 0
path: rust-tmp
- name: Checkout git-filter-repo
uses: actions/checkout@v4
with:
repository: newren/git-filter-repo
path: git-filter-repo
- name: Fetch Kani toolchain version
run: |
cd kani-tmp
TOOLCHAIN_DATE=$(grep -oP 'channel = "nightly-\K\d{4}-\d{2}-\d{2}' rust-toolchain.toml)
COMMIT_HASH=$(curl https://static.rust-lang.org/dist/$TOOLCHAIN_DATE/channel-rust-nightly-git-commit-hash.txt)
if [ -z "$COMMIT_HASH" ]; then
echo "Could not find commit hash on static.rust-lang.org"
exit 1
fi
echo "Kani toolchain date: ${TOOLCHAIN_DATE}"
echo "TOOLCHAIN_DATE=${TOOLCHAIN_DATE}" >> $GITHUB_ENV
echo "Kani toolchain hash: ${COMMIT_HASH}"
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
- name: Update subtree/library locally
run: |
cd rust-tmp
# Ensure "upstream/master" branch contains the target commit
if ! git show ${COMMIT_HASH} --oneline --no-patch; then
echo "Rust commit ${COMMIT_HASH} cannot be found."
exit 1
fi
git checkout ${COMMIT_HASH}
../git-filter-repo/git-filter-repo --subdirectory-filter library --force
git checkout -b subtree/library
cd ../verify-rust-std
git remote add rust-filtered ../rust-tmp/
git fetch rust-filtered
git checkout -b update-subtree/library rust-filtered/subtree/library
git rebase origin/subtree/library
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: 'Update subtree/library'
body: |
This is an automated PR to update the subtree/library branch to the changes
up to and including ${{ env.COMMIT_HASH }} of ${{ env.TOOLCHAIN_DATE }}.
branch: update-subtree/library
delete-branch: true
base: subtree/library
path: verify-rust-std
- name: Merge subtree/library changes
run: |
cd verify-rust-std
SYNC_BRANCH="sync-$TOOLCHAIN_DATE"
git checkout -t -b ${SYNC_BRANCH} origin/main
git submodule update --init
# This command may fail, which will require human intervention.
if ! git subtree merge --prefix=library update-subtree/library --squash; then
echo "MERGE_CONFLICTS=yes" >> $GITHUB_ENV
git commit -a -m "Merge from $COMMIT_HASH with conflicts"
else
echo "MERGE_CONFLICTS=no" >> $GITHUB_ENV
fi
sed -i "s/^channel = \"nightly-.*\"/channel = \"${TOOLCHAIN_DATE}\"/" rust-toolchain.toml
git commit "Update toolchain to ${TOOLCHAIN_DATE}" rust-toolchain.toml
- name: Create Pull Request without conflicts
if: ${{ env.MERGE_CONFLICTS == 'no' }}
uses: peter-evans/create-pull-request@v7
with:
title: 'Merge subtree update'
body: |
This is an automated PR to merge library subtree updates
up to and including ${{ env.COMMIT_HASH }} of ${{ env.TOOLCHAIN_DATE }}
into main. This is a clean merge, no conflicts were detected.
delete-branch: true
path: verify-rust-std
- name: Create Pull Request with conflicts
if: ${{ env.MERGE_CONFLICTS == 'yes' }}
uses: peter-evans/create-pull-request@v7
with:
title: 'Merge subtree update'
body: |
This is an automated PR to merge library subtree updates
up to and including ${{ env.COMMIT_HASH }} of ${{ env.TOOLCHAIN_DATE }}
into main. `git merge` resulted in conflicts, which require manual resolution.
Files were commited with merge conflict markers.
delete-branch: true
path: verify-rust-std