Skip to content

Commit e9aa2a4

Browse files
committed
cargo: MSRV and GitHub Actions
The aim of this change is to ensure that `nonempty` maintains its minimal supported rust version (MSRV). This is declared in the `Cargo.toml`, and is currently `1.79.0`. However, this version differs depending on which features are used: - `serialize` requires 1.81.0 - `bincode` requires 1.85.1 The GitHub actions are changed so that we split these checks up into their categories: - MSRV performs the full check using the 1.79.0 toolchain - `Serde Build` ensures that the `serialize` feature builds and tests - `Bincode Build` ensures that the `bincode` feature builds and tests - `no-std` ensures that no-std builds and tests While changing the actions, it is important to note that `actions-rs` has been unmaintained, and so a switch to [`dtolnay/rust-toolchain`](https://github.com/dtolnay/rust-toolchain) is made, as it is better maintained by a prominent Rust developer – and the project is still active.
1 parent 95d5cb1 commit e9aa2a4

File tree

3 files changed

+219
-34
lines changed

3 files changed

+219
-34
lines changed

.github/workflows/actions.yml

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,82 @@ on:
88

99
jobs:
1010
build:
11-
name: Build and test
11+
name: MSRV
1212
strategy:
1313
matrix:
1414
os: ['ubuntu-latest', 'macos-latest']
1515
runs-on: ${{ matrix.os }}
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
18+
- uses: dtolnay/rust-toolchain@1.79.0
19+
with:
20+
components: rustfmt, clippy
21+
- name: Cache cargo registry
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.cargo/registry
25+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
1826
- name: Build
1927
run: cargo build --verbose
2028
env:
2129
RUSTFLAGS: -D warnings
22-
- name: Run tests
30+
- name: Clippy
31+
run: cargo clippy --all --tests
32+
env:
33+
RUSTFLAGS: -D warnings
34+
- name: Test
35+
run: cargo test --all --verbose
36+
- name: Formatting
37+
run: cargo fmt --all -- --check
38+
- name: Docs
39+
run: cargo doc --workspace --no-deps
40+
env:
41+
RUSTFLAGS: -D warnings
42+
43+
build-serde:
44+
name: Serde Build
45+
strategy:
46+
matrix:
47+
os: ['ubuntu-latest', 'macos-latest']
48+
runs-on: ${{ matrix.os }}
49+
steps:
50+
- uses: actions/checkout@v5
51+
- uses: dtolnay/rust-toolchain@1.81.0
52+
- name: Build
53+
run: cargo build --verbose --features serialize
54+
env:
55+
RUSTFLAGS: -D warnings
56+
- name: Test
2357
run: cargo test --all --verbose --features serialize,arbitrary
24-
no-std:
25-
name: no-std build and test
58+
59+
build-bincode:
60+
name: Bincode Build
2661
strategy:
2762
matrix:
2863
os: ['ubuntu-latest', 'macos-latest']
2964
runs-on: ${{ matrix.os }}
3065
steps:
31-
- uses: actions/checkout@v4
66+
- uses: actions/checkout@v5
67+
- uses: dtolnay/rust-toolchain@1.85.1
3268
- name: Build
33-
run: cargo build --verbose --no-default-features
69+
run: cargo build --verbose --features serialize
3470
env:
3571
RUSTFLAGS: -D warnings
36-
- name: Run tests
37-
run: cargo test --all --verbose --no-default-features
72+
- name: Test
73+
run: cargo test --all --verbose --features bincode,arbitrary
3874

39-
rustfmt_and_clippy:
40-
name: Check rustfmt style && run clippy
41-
runs-on: ubuntu-latest
75+
no-std:
76+
name: no-std
77+
strategy:
78+
matrix:
79+
os: ['ubuntu-latest', 'macos-latest']
80+
runs-on: ${{ matrix.os }}
4281
steps:
43-
- uses: actions/checkout@v4
44-
- uses: actions-rs/toolchain@v1
45-
with:
46-
toolchain: stable
47-
profile: minimal
48-
components: clippy, rustfmt
49-
override: true
50-
- name: Cache cargo registry
51-
uses: actions/cache@v4
52-
with:
53-
path: ~/.cargo/registry
54-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
55-
- name: Run clippy
56-
uses: actions-rs/cargo@v1
57-
with:
58-
command: clippy
59-
args: --all --tests --features serialize,arbitrary
82+
- uses: actions/checkout@v5
83+
- uses: dtolnay/rust-toolchain@1.79.0
84+
- name: Build
85+
run: cargo build --verbose --no-default-features
6086
env:
6187
RUSTFLAGS: -D warnings
62-
- name: Check formating
63-
uses: actions-rs/cargo@v1
64-
with:
65-
command: fmt
66-
args: --all -- --check
88+
- name: Test
89+
run: cargo test --all --verbose --no-default-features

Cargo.lock

Lines changed: 161 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ authors = ["Alexis Sellier <self@cloudhead.io>"]
66
edition = "2021"
77
license = "MIT"
88
repository = "https://github.com/cloudhead/nonempty"
9+
rust-version = "1.79"
910

1011
[dependencies]
1112
serde = { features = ["derive", "alloc"], default-features = false, optional = true, version = "1" }

0 commit comments

Comments
 (0)