Skip to content

Commit

Permalink
check MSRV in CI
Browse files Browse the repository at this point in the history
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 helix-editor#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 helix-editor#2482.
  • Loading branch information
the-mikedavis committed May 23, 2022
1 parent f7dbd8f commit 36e2cba
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 26 deletions.
63 changes: 37 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@ on:
schedule:
- cron: '00 01 * * *'

env:
# increment this key to bust the caches
CACHE_VERSION: "1"

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:
Expand All @@ -25,22 +36,22 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-registry-
key: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-registry-

- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-index-
key: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-index-

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-build-target-
key: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-v${{ env.CACHE_VERSION }}-cargo-build-target-

- name: Run cargo check
uses: actions-rs/cargo@v1
Expand All @@ -64,22 +75,22 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-registry-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-

- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-index-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-build-target-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-

- name: Copy minimal languages config
run: cp .github/workflows/languages.toml ./languages.toml
Expand All @@ -88,8 +99,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
Expand Down Expand Up @@ -119,22 +130,22 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-registry-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-

- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-index-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-build-target-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-

- name: Run cargo fmt
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -165,22 +176,22 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-registry-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-registry-

- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-index-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-index-

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-v2-cargo-build-target-
key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-cargo-build-target-

- name: Generate docs
uses: actions-rs/cargo@v1
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/msrv-rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.60.0"
components = ["rustfmt", "rust-src"]

0 comments on commit 36e2cba

Please sign in to comment.