Skip to content

Commit 12635fd

Browse files
authored
Upgrade toolchain to 2024-04-18 and improve toolchain workflow (rust-lang#3149)
The toolchain upgrade itself didn't require any modification, but it looks like the rust toolchain script includes any untracked files to the PR, which is the root cause of the rust-lang#3146 CI failure. Thus, I made the following changes (each one of them in its own commit): 1. Moved the upgrade step to its own script. 2. Added a bit of debugging and doc to the script. 3. Added a new step that cleans the workspace before the PR creation. 4. Actually update the toolchain. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 299b0b3 commit 12635fd

File tree

4 files changed

+75
-37
lines changed

4 files changed

+75
-37
lines changed

.github/workflows/toolchain-upgrade.yml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,11 @@ jobs:
3030
env:
3131
GH_TOKEN: ${{ github.token }}
3232
run: |
33-
current_toolchain_date=$(grep ^channel rust-toolchain.toml | sed 's/.*nightly-\(.*\)"/\1/')
34-
echo "current_toolchain_date=$current_toolchain_date" >> $GITHUB_ENV
35-
current_toolchain_epoch=$(date --date $current_toolchain_date +%s)
36-
next_toolchain_date=$(date --date "@$(($current_toolchain_epoch + 86400))" +%Y-%m-%d)
37-
echo "next_toolchain_date=$next_toolchain_date" >> $GITHUB_ENV
38-
if gh issue list -S \
39-
"Toolchain upgrade to nightly-$next_toolchain_date failed" \
40-
--json number,title | grep title ; then
41-
echo "next_step=none" >> $GITHUB_ENV
42-
elif ! git ls-remote --exit-code origin toolchain-$next_toolchain_date ; then
43-
echo "next_step=create_pr" >> $GITHUB_ENV
44-
sed -i "/^channel/ s/$current_toolchain_date/$next_toolchain_date/" rust-toolchain.toml
45-
git diff
46-
git clone --filter=tree:0 https://github.com/rust-lang/rust rust.git
47-
cd rust.git
48-
current_toolchain_hash=$(curl https://static.rust-lang.org/dist/$current_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
49-
echo "current_toolchain_hash=$current_toolchain_hash" >> $GITHUB_ENV
50-
next_toolchain_hash=$(curl https://static.rust-lang.org/dist/$next_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
51-
echo "next_toolchain_hash=$next_toolchain_hash" >> $GITHUB_ENV
52-
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
53-
echo "git_log<<$EOF" >> $GITHUB_ENV
54-
git log --oneline $current_toolchain_hash..$next_toolchain_hash | \
55-
sed 's#^#https://github.com/rust-lang/rust/commit/#' >> $GITHUB_ENV
56-
echo "$EOF" >> $GITHUB_ENV
57-
cd ..
58-
rm -rf rust.git
59-
if ! cargo build-dev ; then
60-
echo "next_step=create_issue" >> $GITHUB_ENV
61-
else
62-
if ! ./scripts/kani-regression.sh ; then
63-
echo "next_step=create_issue" >> $GITHUB_ENV
64-
fi
65-
fi
66-
else
67-
echo "next_step=none" >> $GITHUB_ENV
68-
fi
33+
source scripts/toolchain_update.sh
34+
35+
- name: Clean untracked files
36+
run: git clean -f
37+
6938
- name: Create Pull Request
7039
if: ${{ env.next_step == 'create_pr' }}
7140
uses: peter-evans/create-pull-request@v6

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ no_llvm_build
4848
/tmp/
4949
# Created by default with `src/ci/docker/run.sh`
5050
/obj/
51+
# Created by kani-compiler
52+
*.rlib
53+
*.rmeta
54+
*.mir
5155

5256
## Temporary files
5357
*~

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2024-04-15"
5+
channel = "nightly-2024-04-18"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

scripts/toolchain_update.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# Copyright Kani Contributors
3+
# SPDX-License-Identifier: Apache-2.0 OR MIT
4+
5+
# This script is part of our CI nightly job to bump the toolchain version.
6+
# It will potentially update the rust-toolchain.toml file, and run the
7+
# regression.
8+
#
9+
# In order to manually run this script, you will need to do the following:
10+
#
11+
# 1. Set $GITHUB_ENV to point to an output file.
12+
# 2. Install and configure GitHub CLI
13+
14+
set -eu
15+
16+
current_toolchain_date=$(grep ^channel rust-toolchain.toml | sed 's/.*nightly-\(.*\)"/\1/')
17+
echo "current_toolchain_date=$current_toolchain_date" >> $GITHUB_ENV
18+
19+
current_toolchain_epoch=$(date --date $current_toolchain_date +%s)
20+
next_toolchain_date=$(date --date "@$(($current_toolchain_epoch + 86400))" +%Y-%m-%d)
21+
echo "next_toolchain_date=$next_toolchain_date" >> $GITHUB_ENV
22+
23+
echo "------ Start upgrade ------"
24+
echo "- current: ${current_toolchain_date}"
25+
echo "- next: ${next_toolchain_date}"
26+
echo "---------------------------"
27+
28+
if gh issue list -S \
29+
"Toolchain upgrade to nightly-$next_toolchain_date failed" \
30+
--json number,title | grep title
31+
then
32+
echo "Skip update: Found existing issue"
33+
echo "next_step=none" >> $GITHUB_ENV
34+
elif ! git ls-remote --exit-code origin toolchain-$next_toolchain_date
35+
then
36+
echo "next_step=create_pr" >> $GITHUB_ENV
37+
38+
# Modify rust-toolchain file
39+
sed -i "/^channel/ s/$current_toolchain_date/$next_toolchain_date/" rust-toolchain.toml
40+
41+
git diff
42+
git clone --filter=tree:0 https://github.com/rust-lang/rust rust.git
43+
cd rust.git
44+
current_toolchain_hash=$(curl https://static.rust-lang.org/dist/$current_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
45+
echo "current_toolchain_hash=$current_toolchain_hash" >> $GITHUB_ENV
46+
47+
next_toolchain_hash=$(curl https://static.rust-lang.org/dist/$next_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
48+
echo "next_toolchain_hash=$next_toolchain_hash" >> $GITHUB_ENV
49+
50+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
51+
echo "git_log<<$EOF" >> $GITHUB_ENV
52+
53+
git log --oneline $current_toolchain_hash..$next_toolchain_hash | \
54+
sed 's#^#https://github.com/rust-lang/rust/commit/#' >> $GITHUB_ENV
55+
echo "$EOF" >> $GITHUB_ENV
56+
57+
cd ..
58+
rm -rf rust.git
59+
if ! ./scripts/kani-regression.sh ; then
60+
echo "next_step=create_issue" >> $GITHUB_ENV
61+
fi
62+
else
63+
echo "Skip update: Found existing branch"
64+
echo "next_step=none" >> $GITHUB_ENV
65+
fi

0 commit comments

Comments
 (0)