diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..43e1c09 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + + +jobs: + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.75.0 + profile: minimal + override: true + - uses: Swatinem/rust-cache@v2 + - uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --workspace + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.75.0 + profile: minimal + override: true + components: rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.75.0 + profile: minimal + override: true + components: clippy + - uses: Swatinem/rust-cache@v2 + - name: Clippy check + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-targets --all-features --workspace -- -D warnings + + docs: + name: Docs + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.75.0 + profile: minimal + override: true + - uses: Swatinem/rust-cache@v2 + - name: Check documentation + env: + RUSTDOCFLAGS: -D warnings + uses: actions-rs/cargo@v1 + with: + command: doc + args: --no-deps --document-private-items --all-features --workspace --examples + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e365bd7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,78 +0,0 @@ -language: rust -rust: - # error on #[non_exhaustive] being "experimental" - # - 1.36.0 - # - 1.37.0 - # error on cfg(doctest) - # - 1.38.0 - # - 1.39.0 - - 1.40.0 - - 1.41.0 - - 1.42.0 - - 1.43.0 - - 1.44.0 - - 1.45.0 - - 1.46.0 - - 1.47.0 - - 1.48.0 - - 1.49.0 - - 1.50.0 - - 1.51.0 - - 1.52.0 - - stable - - beta - - nightly -matrix: - allow_failures: - - rust: nightly - - include: - # Rustfmt - - rust: stable - install: - - rustup component add rustfmt-preview - before_script: - - cargo fmt --version - script: - - cargo fmt -- --check - env: - - CHECK_FORMAT=true - - # Clippy - - rust: stable - install: - - rustup component add clippy-preview - script: - # Fail if clippy output contains "error:" or "warning:" - - cargo clippy 2>&1 | tee ./clippy.out && ! grep -qe "error:\|warning:" ./clippy.out - env: - - CHECK_SYNTAX=true - - # Test coverage (with Tarpaulin) - - rust: stable - # To avoid "Error: EPERM: operation not permitted" error (see https://github.com/valery-barysok/session-file-store/issues/58) - sudo: true - install: - - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin --force - script: - - cargo tarpaulin -v --ciserver travis-ci --coveralls $TRAVIS_JOB_ID - env: - - COVERAGE_MEASUREMENT=true - -script: - - cargo test - -# Need to cache the whole `.cargo` directory to keep .crates.toml for -# cargo-update to work -cache: - directories: - - /home/travis/.cargo - -# But don't cache the cargo registry -before_cache: - - rm -rf /home/travis/.cargo/registry - -addons: - apt: - packages: - - libssl-dev # Required for tarpaulin diff --git a/yaserde/tests/deserializer.rs b/yaserde/tests/deserializer.rs index 71337a3..6ae06f7 100644 --- a/yaserde/tests/deserializer.rs +++ b/yaserde/tests/deserializer.rs @@ -4,10 +4,8 @@ extern crate yaserde; extern crate yaserde_derive; use log::debug; -use std::default; use std::io::Read; -use std::str::FromStr; -use yaserde::de::{self, from_str}; +use yaserde::de::from_str; use yaserde::YaDeserialize; fn init() { diff --git a/yaserde_derive/src/common/field.rs b/yaserde_derive/src/common/field.rs index 594a178..4330646 100644 --- a/yaserde_derive/src/common/field.rs +++ b/yaserde_derive/src/common/field.rs @@ -293,7 +293,7 @@ impl From<&Field> for String { Field::FieldU64 => "u64".to_string(), Field::FieldF32 => "f32".to_string(), Field::FieldF64 => "f64".to_string(), - Field::FieldStruct { struct_name } => quote!{#struct_name}.to_string(), + Field::FieldStruct { struct_name } => quote! {#struct_name}.to_string(), _ => panic!("Not a simple type: {:?}", field), } } diff --git a/yaserde_derive/src/de/expand_struct.rs b/yaserde_derive/src/de/expand_struct.rs index 28661c1..2c9d7a1 100644 --- a/yaserde_derive/src/de/expand_struct.rs +++ b/yaserde_derive/src/de/expand_struct.rs @@ -294,7 +294,7 @@ pub fn parse( Field::FieldStruct { struct_name } => visit_vec( "e! { .push(value) }, &Ident::new("visit_str", field.get_span()), - &build_visitor_ident(&label_name, field.get_span(), Some(&struct_name)), + &build_visitor_ident(&label_name, field.get_span(), Some(struct_name)), ), Field::FieldOption { .. } | Field::FieldVec { .. } => unimplemented!("Not supported"), simple_type => visit_vec(