Skip to content

Commit

Permalink
.github: replace actions-rs with dtolnay/rust-toolchain, add caching (#…
Browse files Browse the repository at this point in the history
…137)

* .github: bump actions/checkout to v4

* .github: do not fail fast

* .github: replace actions-rs with dtolnay/rust-toolchain

actions-rs is no longer maintained.

* .github: add rust cache action

This should reduce CI time.
  • Loading branch information
tamird authored Nov 17, 2023
1 parent d32127b commit b0a764f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 49 deletions.
59 changes: 26 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,30 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
run: cargo check --all-features --all-targets

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --tests -- -D warnings
run: cargo clippy --all-features --all-targets -- -D warnings

- name: Fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt -- --check

test:
name: Test crate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
Expand All @@ -59,40 +51,41 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: rustfmt, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Test
uses: actions-rs/cargo@v1
env:
CARGO_TERM_COLOR: never
SNAPSHOT_DIR: rust-${{ matrix.toolchain }}
with:
command: test
run: cargo test

msrv-build:
name: Build crate with documented MSRV
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust MSRV version
run: scripts/force-msrv-toolchain.sh
- name: Read crate metadata
id: metadata
run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ steps.metadata.outputs.rust-version }}

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
run: cargo build
16 changes: 0 additions & 16 deletions scripts/force-msrv-toolchain.sh

This file was deleted.

0 comments on commit b0a764f

Please sign in to comment.