Skip to content

Commit

Permalink
Merge #1564: ci: add cron-update-rust.yml
Browse files Browse the repository at this point in the history
b92f8c9 ci: add cron-update-rust.yml (valued mammal)

Pull request description:

  This adds a cronjob to watch for updates to rust stable once a month. If the latest version changed, then a pull request is opened to see if clippy passes CI using the new toolchain.

  ### Notes to the reviewers

  Let me know what you think @notmandatory

  fixes #1431

  ### Changelog notice

  ### Checklists

  #### TODO

  * [ ] Setup access token for [create-pull-request](https://github.com/marketplace/actions/create-pull-request)

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  oleonardolima:
    tACK b92f8c9

Tree-SHA512: e251fb8d0456c30a244f4611131baea1afc4f8323a3bdc8d9536d276a8b4bb2c0269beba6b04b72ab2ea96897e421a16c3e8e6065a755d62ff98bfe13d0b02bd
  • Loading branch information
notmandatory committed Aug 23, 2024
2 parents 6008897 + b92f8c9 commit 9e6ac72
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ name: CI

jobs:

prepare:
runs-on: ubuntu-latest
outputs:
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Read rust version"
id: read_toolchain
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT

build-test:
name: Build and test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,12 +127,13 @@ jobs:
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check

clippy_check:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.78.0
toolchain: ${{ needs.prepare.outputs.rust_version }}
components: clippy
override: true
- name: Rust Cache
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/cron-update-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update rust version
on:
schedule:
- cron: "0 0 15 * *" # At 00:00 on day-of-month 15.
workflow_dispatch: # allows manual triggering
jobs:
format:
name: Update rustc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Update rust-version to use latest stable
run: |
set -x
# Extract the version from whatever version of the compiler dtolnay/rust-toolchain gives us.
RUST_VERSION=$(rustc --verbose --version | sed -ne 's/^release: //p')
# Update the version in the reference file.
echo "${RUST_VERSION}" > rust-version
echo "rust_version=${RUST_VERSION}" >> $GITHUB_ENV
# In case of no new version don't make an empty PR.
if ! git diff --exit-code > /dev/null; then
echo "Updated rustc. Opening PR."
echo "changes_made=true" >> $GITHUB_ENV
else
echo "Attempted to update rustc but the latest stable date did not change. Not opening any PR."
echo "changes_made=false" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: env.changes_made == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
author: Update Rustc Bot <bot@example.com>
committer: Update Rustc Bot <bot@example.com>
branch: create-pull-request/update-rust-version
title: |
ci: automated update to rustc ${{ env.rust_version }}
commit-message: |
ci: automated update to rustc ${{ env.rust_version }}
body: |
Automated update to Github CI workflow `cont_integration.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
1 change: 1 addition & 0 deletions rust-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.79.0

0 comments on commit 9e6ac72

Please sign in to comment.