From 0f3cecb9e7a0913f758476db0370cd774dd0e51b Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Wed, 3 Jan 2024 17:53:16 +0100 Subject: [PATCH 1/2] ci: add github actions CI --- .github/dependabot.yml | 7 ++++ .github/workflows/ci.yml | 90 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2d450de --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 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 + From 6c7b8254e60183318570e98461b65c70d272808c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Thu, 4 Jan 2024 08:53:10 +0100 Subject: [PATCH 2/2] build: fix fmt and correct unit tests --- xml_schema_derive/src/xsd/element.rs | 2 +- xml_schema_derive/src/xsd/extension.rs | 6 +++--- xml_schema_derive/src/xsd/schema.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xml_schema_derive/src/xsd/element.rs b/xml_schema_derive/src/xsd/element.rs index 17832e2..efee534 100644 --- a/xml_schema_derive/src/xsd/element.rs +++ b/xml_schema_derive/src/xsd/element.rs @@ -123,7 +123,7 @@ impl Element { } else { name }; - + let attribute_name = Ident::new(&name, Span::call_site()); let yaserde_rename = &self.name; diff --git a/xml_schema_derive/src/xsd/extension.rs b/xml_schema_derive/src/xsd/extension.rs index 536787f..7a3c5b8 100644 --- a/xml_schema_derive/src/xsd/extension.rs +++ b/xml_schema_derive/src/xsd/extension.rs @@ -36,7 +36,7 @@ impl Implementation for Extension { .map(|attribute| attribute.implement(namespace_definition, prefix, context)) .collect(); -let inner_attribute = if format!("{rust_type}") == "String" { + let inner_attribute = if format!("{rust_type}") == "String" { quote!(#[yaserde(text)]) } else { TokenStream::new() @@ -102,7 +102,7 @@ mod tests { let expected = TokenStream::from_str( r#" #[yaserde(text)] - pub content: String, + pub base: String, "#, ) .unwrap(); @@ -145,7 +145,7 @@ mod tests { let expected = TokenStream::from_str( r#" #[yaserde(text)] - pub content: String, + pub base: String, #[yaserde(attribute)] pub attribute_1: String, #[yaserde(attribute)] diff --git a/xml_schema_derive/src/xsd/schema.rs b/xml_schema_derive/src/xsd/schema.rs index e14ec5f..6c33ccd 100644 --- a/xml_schema_derive/src/xsd/schema.rs +++ b/xml_schema_derive/src/xsd/schema.rs @@ -1,4 +1,4 @@ - use crate::xsd::{ +use crate::xsd::{ attribute, attribute_group, complex_type, element, group, import, qualification, simple_type, Implementation, XsdContext, };