Skip to content

Commit b92f8c9

Browse files
committed
ci: add cron-update-rust.yml
1 parent acccb59 commit b92f8c9

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.github/workflows/cont_integration.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ name: CI
44

55
jobs:
66

7+
prepare:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
11+
steps:
12+
- name: "Checkout repo"
13+
uses: actions/checkout@v4
14+
- name: "Read rust version"
15+
id: read_toolchain
16+
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT
17+
718
build-test:
819
name: Build and test
920
runs-on: ubuntu-latest
@@ -116,12 +127,13 @@ jobs:
116127
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check
117128

118129
clippy_check:
130+
needs: prepare
119131
runs-on: ubuntu-latest
120132
steps:
121133
- uses: actions/checkout@v1
122134
- uses: actions-rs/toolchain@v1
123135
with:
124-
toolchain: 1.78.0
136+
toolchain: ${{ needs.prepare.outputs.rust_version }}
125137
components: clippy
126138
override: true
127139
- name: Rust Cache
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update rust version
2+
on:
3+
schedule:
4+
- cron: "0 0 15 * *" # At 00:00 on day-of-month 15.
5+
workflow_dispatch: # allows manual triggering
6+
jobs:
7+
format:
8+
name: Update rustc
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: dtolnay/rust-toolchain@stable
13+
- name: Update rust-version to use latest stable
14+
run: |
15+
set -x
16+
# Extract the version from whatever version of the compiler dtolnay/rust-toolchain gives us.
17+
RUST_VERSION=$(rustc --verbose --version | sed -ne 's/^release: //p')
18+
# Update the version in the reference file.
19+
echo "${RUST_VERSION}" > rust-version
20+
echo "rust_version=${RUST_VERSION}" >> $GITHUB_ENV
21+
# In case of no new version don't make an empty PR.
22+
if ! git diff --exit-code > /dev/null; then
23+
echo "Updated rustc. Opening PR."
24+
echo "changes_made=true" >> $GITHUB_ENV
25+
else
26+
echo "Attempted to update rustc but the latest stable date did not change. Not opening any PR."
27+
echo "changes_made=false" >> $GITHUB_ENV
28+
fi
29+
- name: Create Pull Request
30+
if: env.changes_made == 'true'
31+
uses: peter-evans/create-pull-request@v6
32+
with:
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
author: Update Rustc Bot <[email protected]>
35+
committer: Update Rustc Bot <[email protected]>
36+
branch: create-pull-request/update-rust-version
37+
title: |
38+
ci: automated update to rustc ${{ env.rust_version }}
39+
commit-message: |
40+
ci: automated update to rustc ${{ env.rust_version }}
41+
body: |
42+
Automated update to Github CI workflow `cont_integration.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

rust-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.79.0

0 commit comments

Comments
 (0)