5858 echo "NEXT_TOOLCHAIN_DATE=${NEXT_TOOLCHAIN_DATE}" >> $GITHUB_ENV
5959 echo "CURRENT_COMMIT_HASH=${CURRENT_COMMIT_HASH}" >> $GITHUB_ENV
6060 echo "NEXT_COMMIT_HASH=${NEXT_COMMIT_HASH}" >> $GITHUB_ENV
61+ KANI_COMMIT_HASH=$(git -C kani-tmp rev-parse HEAD)
62+ echo "KANI_COMMIT_HASH=${KANI_COMMIT_HASH}" >> $GITHUB_ENV
63+
64+ - name : Check for existing pull requests
65+ run : |
66+ cd verify-rust-std
67+ if gh pr list --json title --jq '.[] | select(.title | startswith("Update subtree/library to")) | .title' | grep -q .; then
68+ echo "SUBTREE_PR_EXISTS=yes" >> $GITHUB_ENV
69+ else
70+ echo "SUBTREE_PR_EXISTS=no" >> $GITHUB_ENV
71+ fi
72+ if gh pr list --json title --jq '.[] | select(.title | startswith("Merge subtree update for toolchain nightly-")) | .title' | grep -q .; then
73+ echo "MERGE_PR_EXISTS=yes" >> $GITHUB_ENV
74+ else
75+ echo "MERGE_PR_EXISTS=no" >> $GITHUB_ENV
76+ fi
77+ env :
78+ GH_TOKEN : ${{ github.token }}
6179
6280 - name : Update subtree/library locally
81+ if : ${{ env.SUBTREE_PR_EXISTS == 'no' }}
6382 run : |
6483 cd rust-tmp
6584
7796 git remote add rust-filtered ../rust-tmp/
7897 git fetch rust-filtered
7998 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
80102 SUBTREE_HEAD_MSG=$(git log --format=%s -n 1 origin/subtree/library)
81103 UPSTREAM_FROM=$(git log --grep="${SUBTREE_HEAD_MSG}" -n 1 --format=%H rust-filtered/subtree/library)
82104 UPSTREAM_HEAD=$(git log --format=%H -n 1 rust-filtered/subtree/library)
@@ -89,22 +111,23 @@ jobs:
89111 echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
90112 fi
91113
92- - name : Create Pull Request
93- if : ${{ env.MERGE_CONFLICTS != 'noop' }}
114+ - name : Create Pull Request to update subtree/library
115+ if : ${{ env.MERGE_CONFLICTS != 'noop' && env.SUBTREE_PR_EXISTS == 'no' }}
94116 uses : peter-evans/create-pull-request@v7
95117 with :
96118 title : ' Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}'
97119 body : |
98120 This is an automated PR to update the subtree/library branch to the changes
99121 from ${{ env.CURRENT_TOOLCHAIN_DATE }} (${{ env.CURRENT_COMMIT_HASH }})
100122 to ${{ env.NEXT_TOOLCHAIN_DATE }} (${{ env.NEXT_COMMIT_HASH }}), inclusive.
123+ **Do not merge this PR using the merge queue. Instead, use the rebase strategy.**
101124 branch : update-subtree/library
102125 delete-branch : true
103126 base : subtree/library
104127 path : verify-rust-std
105128
106129 - name : Merge subtree/library changes
107- if : ${{ env.MERGE_CONFLICTS != 'noop' }}
130+ if : ${{ env.MERGE_CONFLICTS != 'noop' && env.MERGE_PR_EXISTS == 'no' }}
108131 run : |
109132 cd verify-rust-std
110133 git checkout main
@@ -119,12 +142,15 @@ jobs:
119142 echo "MERGE_CONFLICTS=no" >> $GITHUB_ENV
120143 fi
121144
122- sed -i "s/^channel = \"nightly-.*\"/channel = \"${NEXT_TOOLCHAIN_DATE}\"/" rust-toolchain.toml
145+ sed -i "s/^channel = \"nightly-.*\"/channel = \"nightly- ${NEXT_TOOLCHAIN_DATE}\"/" rust-toolchain.toml
123146 git -c user.name=gitbot -c user.email=git@bot \
124147 commit -m "Update toolchain to ${NEXT_TOOLCHAIN_DATE}" rust-toolchain.toml
125-
148+ # Update kani-version.toml with the new Kani commit hash
149+ sed -i "s/commit = .*/commit = \"${KANI_COMMIT_HASH}\"/" tool_config/kani-version.toml
150+ git -c user.name=gitbot -c user.email=git@bot \
151+ commit -m "Update Kani version to ${KANI_COMMIT_HASH}" tool_config/kani-version.toml
126152 - name : Create Pull Request without conflicts
127- if : ${{ env.MERGE_CONFLICTS == 'no' }}
153+ if : ${{ env.MERGE_CONFLICTS == 'no' && env.MERGE_PR_EXISTS == 'no' }}
128154 uses : peter-evans/create-pull-request@v7
129155 with :
130156 title : ' Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}'
@@ -139,7 +165,7 @@ jobs:
139165 path : verify-rust-std
140166
141167 - name : Create Pull Request with conflicts
142- if : ${{ env.MERGE_CONFLICTS == 'yes' }}
168+ if : ${{ env.MERGE_CONFLICTS == 'yes' && env.MERGE_PR_EXISTS == 'no' }}
143169 uses : peter-evans/create-pull-request@v7
144170 with :
145171 title : ' Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}'
0 commit comments