|
| 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