]> Untitled Git - bdk/commitdiff
ci: add cron-update-rust.yml
authorvalued mammal <valuedmammal@protonmail.com>
Wed, 21 Aug 2024 03:04:07 +0000 (23:04 -0400)
committervalued mammal <valuedmammal@protonmail.com>
Fri, 23 Aug 2024 00:46:06 +0000 (20:46 -0400)
.github/workflows/cont_integration.yml
.github/workflows/cron-update-rust.yml [new file with mode: 0644]
rust-version [new file with mode: 0644]

index ef6fc8da12ef655fadc02d81d9da823ce0499595..b4140661777d60ff2cfcd5a09fe5e3e9133da312 100644 (file)
@@ -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
@@ -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
diff --git a/.github/workflows/cron-update-rust.yml b/.github/workflows/cron-update-rust.yml
new file mode 100644 (file)
index 0000000..3801f78
--- /dev/null
@@ -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
diff --git a/rust-version b/rust-version
new file mode 100644 (file)
index 0000000..b3a8c61
--- /dev/null
@@ -0,0 +1 @@
+1.79.0