diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index f8a6b5b..e3d657d 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -20,37 +20,49 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout + - name: ๐Ÿ“ฅ Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up the toolchain + - name: โœจ Set up the toolchain uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable components: rustfmt, clippy - - name: Rust Cache + - name: โšก๏ธ Rust Cache uses: Swatinem/rust-cache@v1 with: cache-on-failure: true - - name: Test + - name: ๐Ÿงช Test without optional features uses: actions-rs/cargo@v1 with: command: test - args: --doc + args: --all-targets - - name: Clippy + - name: ๐Ÿงช Test all features + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-targets --all-features + + - name: ๐Ÿงช Test docs + uses: actions-rs/cargo@v1 + with: + command: test + args: --doc --all-features + + - name: ๐Ÿช„ Clippy uses: actions-rs/clippy-check@v1 continue-on-error: true with: token: ${{ secrets.GITHUB_TOKEN }} args: --all-targets --all-features --tests -- -D warnings - - name: Publish the crates (dry run) + - name: ๐Ÿ“ค Publish the crates (dry run) run: | cargo publish --allow-dirty --dry-run env: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 903a680..39f3b0f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,12 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout the repository + - name: ๐Ÿ“ฅ Checkout the repository uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set the versions + - name: ๐Ÿช„ Set the versions run: | sed -i -e 's/version = "0\.0\.0"/version = "${{ github.ref_name }}"/g' Cargo.toml - name: Rustup @@ -29,13 +29,13 @@ jobs: profile: minimal toolchain: stable - - name: Build the changelog + - name: ๐Ÿ“ Build the changelog id: changelog uses: Bullrich/generate-release-changelog@master env: REPO: ${{ github.repository }} - - name: Update the release + - name: ๐Ÿช„ Update the release uses: tubone24/update_release@v1.3.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -43,7 +43,7 @@ jobs: release_name: ${{ github.ref_name }} body: ${{ steps.changelog.outputs.changelog }} - - name: Publish the crates + - name: ๐Ÿ“ค Publish the crates run: | cargo publish --allow-dirty env: diff --git a/Cargo.toml b/Cargo.toml index 40114c0..d0e2967 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,13 +12,14 @@ categories = ["parsing"] [features] default = [] +meta = ["dep:serde_json"] [dependencies] prost = "0.11.3" serde = { version = "1.0.148", features = ["derive"] } serde_bytes = "0.11.7" serde-pickle = "1.1.1" -serde_json = "1.0.96" +serde_json = { version = "1.0.96", optional = true } thiserror = "1.0.37" zip = { version = "0.6.3", default-features = false, features = ["deflate"] } diff --git a/src/error.rs b/src/error.rs index 21ff47d..40d9f04 100644 --- a/src/error.rs +++ b/src/error.rs @@ -14,6 +14,7 @@ pub enum Error { #[error("failed to un-pickle")] UnpickleFailed(#[source] serde_pickle::Error), + #[cfg(feature = "meta")] #[error("failed to decode JSON")] JsonDecodeFailed(#[source] serde_json::Error), } diff --git a/src/models.rs b/src/models.rs index 75eb77e..6afdb02 100644 --- a/src/models.rs +++ b/src/models.rs @@ -4,4 +4,5 @@ mod meta; pub use self::battle_results::*; pub use self::battle_results_dat::*; +#[cfg(feature = "meta")] pub use self::meta::*; diff --git a/src/models/meta.rs b/src/models/meta.rs index 84178d0..dbca09b 100644 --- a/src/models/meta.rs +++ b/src/models/meta.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "meta")] + use std::io::Read; use serde::Deserialize; diff --git a/src/replay.rs b/src/replay.rs index ce0416c..c78f83e 100644 --- a/src/replay.rs +++ b/src/replay.rs @@ -3,7 +3,9 @@ use std::io::{Read, Seek}; use zip::ZipArchive; use crate::error::Error; -use crate::models::{BattleResults, BattleResultsDat, Meta}; +#[cfg(feature = "meta")] +use crate::models::Meta; +use crate::models::{BattleResults, BattleResultsDat}; use crate::result::Result; /// Opened (but not yet parsed) replay. @@ -31,6 +33,7 @@ impl Replay { BattleResultsDat::from_reader(pickled_battle_results) } + #[cfg(feature = "meta")] pub fn read_meta(&mut self) -> Result { Meta::from_reader( self.0 diff --git a/tests/meta.rs b/tests/meta.rs index 37570ef..f33eab7 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "meta")] + use std::fs::File; use anyhow::Result;