Skip to content

Commit 4b829ab

Browse files
authored
Automatic toolchain upgrade improvements (rust-lang#2722)
1. Build and run regression tests, and create a labelled PR (Z-BenchCI) when these pass. 2. File an issue instead of creating a PR when either of the checks fail.
1 parent edd5751 commit 4b829ab

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

.github/workflows/toolchain-upgrade.yml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,35 @@ on:
88
- cron: "30 2 * * *" # Run this every day at 02:30 UTC
99
workflow_dispatch: # Allow manual dispatching for a custom branch / tag.
1010

11+
permissions:
12+
contents: read
13+
issues: write
14+
1115
jobs:
1216
create-toolchain-pr:
13-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-22.04
1418
steps:
1519
- name: Checkout Kani
1620
uses: actions/checkout@v3
1721

22+
- name: Setup Kani Dependencies
23+
uses: ./.github/actions/setup
24+
with:
25+
os: ubuntu-22.04
26+
1827
- name: Update toolchain config
1928
run: |
2029
current_toolchain_date=$(grep ^channel rust-toolchain.toml | sed 's/.*nightly-\(.*\)"/\1/')
2130
echo "current_toolchain_date=$current_toolchain_date" >> $GITHUB_ENV
2231
current_toolchain_epoch=$(date --date $current_toolchain_date +%s)
2332
next_toolchain_date=$(date --date "@$(($current_toolchain_epoch + 86400))" +%Y-%m-%d)
2433
echo "next_toolchain_date=$next_toolchain_date" >> $GITHUB_ENV
25-
if ! git ls-remote --exit-code origin toolchain-$next_toolchain_date ; then
26-
echo "branch_exists=false" >> $GITHUB_ENV
34+
if gh issue list -S \
35+
"Toolchain upgrade to nightly-$next_toolchain_date failed" \
36+
--json number,title | grep title ; then
37+
echo "next_step=none" >> $GITHUB_ENV
38+
elif ! git ls-remote --exit-code origin toolchain-$next_toolchain_date ; then
39+
echo "next_step=create_pr" >> $GITHUB_ENV
2740
sed -i "/^channel/ s/$current_toolchain_date/$next_toolchain_date/" rust-toolchain.toml
2841
git diff
2942
git clone --filter=tree:0 https://github.com/rust-lang/rust rust.git
@@ -39,17 +52,25 @@ jobs:
3952
echo "$EOF" >> $GITHUB_ENV
4053
cd ..
4154
rm -rf rust.git
55+
if ! cargo build-dev ; then
56+
echo "next_step=create_issue" >> $GITHUB_ENV
57+
else
58+
if ! ./scripts/kani-regression.sh ; then
59+
echo "next_step=create_issue" >> $GITHUB_ENV
60+
fi
61+
fi
4262
else
43-
echo "branch_exists=true" >> $GITHUB_ENV
63+
echo "next_step=none" >> $GITHUB_ENV
4464
fi
4565
- name: Create Pull Request
46-
if: ${{ env.branch_exists == 'false' }}
66+
if: ${{ env.next_step == 'create_pr' }}
4767
uses: peter-evans/create-pull-request@v5
4868
with:
4969
commit-message: Upgrade Rust toolchain to nightly-${{ env.next_toolchain_date }}
5070
branch: toolchain-${{ env.next_toolchain_date }}
5171
delete-branch: true
5272
title: 'Automatic toolchain upgrade to nightly-${{ env.next_toolchain_date }}'
73+
labels: Z-BenchCI
5374
body: >
5475
Update Rust toolchain from nightly-${{ env.current_toolchain_date }} to
5576
nightly-${{ env.next_toolchain_date }} without any other source changes.
@@ -61,4 +82,24 @@ jobs:
6182
https://github.com/rust-lang/rust/commit/${{ env.next_toolchain_hash }}. The log
6283
for this commit range is:
6384
85+
${{ env.git_log }}
86+
- name: Create Issue
87+
if: ${{ env.next_step == 'create_issue' }}
88+
uses: dacbd/create-issue-action@main
89+
with:
90+
token: ${{ github.token }}
91+
title: 'Toolchain upgrade to nightly-${{ env.next_toolchain_date }} failed'
92+
body: >
93+
Updating Rust toolchain from nightly-${{ env.current_toolchain_date }} to
94+
nightly-${{ env.next_toolchain_date }} requires source changes.
95+
96+
The failed automated run
97+
[can be found here.](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
98+
99+
Please review the changes at
100+
https://github.com/rust-lang/rust from
101+
https://github.com/rust-lang/rust/commit/${{ env.current_toolchain_hash }} up to
102+
https://github.com/rust-lang/rust/commit/${{ env.next_toolchain_hash }}. The log
103+
for this commit range is:
104+
64105
${{ env.git_log }}

0 commit comments

Comments
 (0)