Skip to content

Commit 3083b7e

Browse files
committed
Create nightly ci to prevent nightly CI failures in contrib PRs
1 parent 96965a8 commit 3083b7e

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update Nightly rustc
2+
on:
3+
push:
4+
schedule:
5+
- cron: "5 0 * * 6" # Saturday at 00:05
6+
workflow_dispatch: # allows manual triggering
7+
jobs:
8+
format:
9+
name: Update nightly rustc
10+
runs-on: ubuntu-24.04
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: dtolnay/rust-toolchain@nightly
14+
- name: Update rust.yml to use latest nightly
15+
run: |
16+
set -x
17+
# Not every night has a nightly, so extract the date from whatever
18+
# version of the compiler dtolnay/rust-toolchain gives us.
19+
NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p')
20+
# Update the nightly version in the reference file.
21+
echo -e "[toolchain]\nchannel = \"nightly-${NIGHTLY_DATE}\"\ncomponents = [\"rust-analyzer\", \"rust-src\", \"rustfmt\", \"clippy\"]" > rust-toolchain.toml
22+
echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV
23+
# Some days there is no new nightly. In this case don't make an empty PR.
24+
if ! git diff --exit-code > /dev/null; then
25+
echo "Updated nightly. Opening PR."
26+
echo "changes_made=true" >> $GITHUB_ENV
27+
else
28+
echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR."
29+
echo "changes_made=false" >> $GITHUB_ENV
30+
fi
31+
- name: Create Pull Request
32+
if: env.changes_made == 'true'
33+
uses: peter-evans/create-pull-request@v7
34+
with:
35+
token: ${{ secrets.BENALLENG_CREATE_PR_TOKEN }}
36+
author: Update Nightly Rustc Bot <bot@example.com>
37+
committer: Update Nightly Rustc Bot <bot@example.com>
38+
title: Automated daily update to rustc (to nightly-${{ env.nightly_date }})
39+
body: |
40+
Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
41+
commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }}
42+
branch: create-pull-request/weekly-nightly-ci-check
43+
delete-branch: true

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly"
3-
components = ["rust-analyzer", "rust-src"]
2+
channel = "nightly-2025-10-09"
3+
components = ["rust-analyzer", "rust-src", "rustfmt", "clippy"]

0 commit comments

Comments
 (0)