Skip to content

Commit

Permalink
Check dependencies minimal versions on CI (#175)
Browse files Browse the repository at this point in the history
Additionally:
- make Clippy happy on latest nightly

Co-authored-by: Kai Ren <tyranron@gmail.com>
  • Loading branch information
ilslv and tyranron authored Nov 10, 2021
1 parent 52fe1c9 commit efbe824
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 189 deletions.
85 changes: 61 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,73 @@
on: [push, pull_request]

name: CI

on: [push, pull_request]

jobs:
test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
name: Test Rust ${{ matrix.toolchain }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
toolchain: [stable, nightly, 1.36.0]
os: [ubuntu, macOS, windows]
steps:
- uses: actions/checkout@master
- name: Install rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
toolchain: ${{ matrix.toolchain }}
override: true
- name: Remove lockfile

- name: Remove .lock file
run: rm Cargo.lock

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --features testing-helpers


test_features_separate:
name: Test features
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install tomljson
run: go get github.com/pelletier/go-toml/cmd/tomljson
- name: Install rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Install tomljson
run: go get github.com/pelletier/go-toml/cmd/tomljson

- name: Test
run: |
export GOBIN=$HOME/go/bin
export PATH=$PATH:$GOBIN
ci/test_all_features.sh
doc_test:
name: Doc tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Install cargo-external-doc
uses: actions-rs/cargo@v1
with:
command: install
args: --git https://github.com/JelteF/cargo-external-doc --force

- name: Build library
uses: actions-rs/cargo@v1
with:
command: build

- name: Run cargo-external-doc
uses: actions-rs/cargo@v1
with:
Expand All @@ -72,9 +78,8 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install minimal nightly with clippy and rustfmt
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
Expand All @@ -87,13 +92,12 @@ jobs:
command: clippy
args: --all-features -- -D warnings


rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install minimal nightly with clipy
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
Expand All @@ -105,3 +109,36 @@ jobs:
with:
command: fmt
args: --all -- --check


msrv:
# TODO: Use MSRV once it understands new `Cargo.lock` format.
# name: MSRV
name: Minimal crates versions
strategy:
fail-fast: false
matrix:
# msrv: ["1.36.0"]
msrv: [stable]
os: [ubuntu, macOS, windows]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.msrv }}
override: true

- name: Install minimal dependecies versions
run: cargo +nightly update -Z minimal-versions

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --features testing-helpers
51 changes: 12 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ name = "derive_more"
proc-macro = true

[dependencies]
proc-macro2 = "1"
quote = "1"
syn = { version = "1" }
proc-macro2 = "1.0"
quote = "1.0"
syn = "1.0.3"
convert_case = { version = "0.4", optional = true}

[build-dependencies]
peg = { version = "0.5", optional = true }
rustc_version = {version = "0.3", optional = true }
rustc_version = { version = "0.4", optional = true }

[badges]
github = { repository = "JelteF/derive_more", workflow = "CI" }
Expand Down
8 changes: 2 additions & 6 deletions src/add_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ fn enum_content(
matches.push(matcher);
}
Fields::Unit => {
let message =
format!("Cannot {}() unit variants", method_ident.to_string());
let message = format!("Cannot {}() unit variants", method_ident);
matches.push(quote!((#subtype, #subtype) => ::core::result::Result::Err(#message)));
}
}
Expand All @@ -129,10 +128,7 @@ fn enum_content(
if data_enum.variants.len() > 1 {
// In the strange case where there's only one enum variant this is would be an unreachable
// match.
let message = format!(
"Trying to {} mismatched enum variants",
method_ident.to_string()
);
let message = format!("Trying to {} mismatched enum variants", method_ident);
matches.push(quote!(_ => ::core::result::Result::Err(#message)));
}
quote!(
Expand Down
7 changes: 4 additions & 3 deletions src/is_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
field: vec!["ignore"],
},
)?;
if state.derive_type != DeriveType::Enum {
panic!("IsVariant can only be derived for enums");
}
assert!(
state.derive_type == DeriveType::Enum,
"IsVariant can only be derived for enums"
);

let enum_name = &input.ident;
let (imp_generics, type_generics, where_clause) = input.generics.split_for_impl();
Expand Down
3 changes: 1 addition & 2 deletions src/not_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ fn enum_output_type_and_content(
matches.push(matcher);
}
Fields::Unit => {
let message =
format!("Cannot {}() unit variants", method_ident.to_string());
let message = format!("Cannot {}() unit variants", method_ident);
matches.push(quote!(#subtype => ::core::result::Result::Err(#message)));
}
}
Expand Down
Loading

0 comments on commit efbe824

Please sign in to comment.