From 92df5a542509e49a5ff71087b65fca2a17d5d25e Mon Sep 17 00:00:00 2001
From: Michael Davis <mcarsondavis@gmail.com>
Date: Sat, 21 May 2022 21:27:08 -0500
Subject: [PATCH] check MSRV in CI

It's very easy to use new rust features without realizing it since
the CI and local development workflows may use the latest rust version.
We try to keep some backwards compatibility with rust versions to make
packaging easier for some OS-level package-managers like Void Linux's.
See #1881.

This change runs the "Check" step for the pinned version of rust in
the rust-toolchain.toml file as well as the MSRV version in a matrix.
In order to bump the MSRV, we need to edit

    .github/workflows/msrv-rust-toolchain.toml

This commit sets the MSRV as 1.60.0 but a later child commit will
reduce the MSRV back to 1.57.0.

Closes #2482.
---
 .github/workflows/build.yml                | 11 +++++++++--
 .github/workflows/msrv-rust-toolchain.toml |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 .github/workflows/msrv-rust-toolchain.toml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f3cd128a..1368d1bc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,10 +11,17 @@ jobs:
   check:
     name: Check
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        rust: [stable, msrv]
     steps:
       - name: Checkout sources
         uses: actions/checkout@v3
 
+      - name: Use MSRV rust toolchain
+        if: matrix.rust == 'msrv'
+        run: cp .github/workflows/msrv-rust-toolchain.toml rust-toolchain.toml
+
       - name: Install stable toolchain
         uses: helix-editor/rust-toolchain@v1
         with:
@@ -50,8 +57,8 @@ jobs:
         uses: actions/cache@v3
         with:
           path: runtime/grammars
-          key: ${{ runner.os }}-v2-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
-          restore-keys: ${{ runner.os }}-v2-tree-sitter-grammars-
+          key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+          restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-tree-sitter-grammars-
 
       - name: Run cargo test
         uses: actions-rs/cargo@v1
diff --git a/.github/workflows/msrv-rust-toolchain.toml b/.github/workflows/msrv-rust-toolchain.toml
new file mode 100644
index 00000000..958edb45
--- /dev/null
+++ b/.github/workflows/msrv-rust-toolchain.toml
@@ -0,0 +1,3 @@
+[toolchain]
+channel = "1.60.0"
+components = ["rustfmt", "rust-src"]