From caac9c4b377abdb2bea2ebc6fc87e9fc966596d4 Mon Sep 17 00:00:00 2001 From: Al Liu Date: Tue, 17 Oct 2023 22:06:03 +0800 Subject: [PATCH] fix CI --- .github/workflows/ci.yml | 6 +++--- ci/miri.sh | 2 +- ci/sanitizer.sh | 2 +- ci/test-stable.sh | 20 -------------------- src/cache.rs | 1 + src/cache/builder.rs | 2 +- src/ring.rs | 3 +++ src/store.rs | 4 ++-- 8 files changed, 12 insertions(+), 28 deletions(-) delete mode 100755 ci/test-stable.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 738c17e..f7ead4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Install cargo-hack run: cargo install cargo-hack - name: Apply clippy lints - run: cargo hack clippy --each-feature + run: cargo hack clippy --each-feature --include-features sync,async --exclude-no-default-features # Run tests on some extra platforms cross: @@ -134,7 +134,7 @@ jobs: path: ~/.cargo key: ${{ runner.os }}-coverage-dotcargo - name: Run build - run: cargo hack build --feature-powerset + run: cargo hack build --feature-powerset --include-features sync,async --exclude-no-default-features test: name: test @@ -168,7 +168,7 @@ jobs: path: ~/.cargo key: ${{ runner.os }}-coverage-dotcargo - name: Run test - run: cargo hack test --feature-powerset + run: cargo hack test --feature-powerset --include-features sync,async --exclude-no-default-features sanitizer: name: sanitizer diff --git a/ci/miri.sh b/ci/miri.sh index 7ea1a2c..6e0637f 100755 --- a/ci/miri.sh +++ b/ci/miri.sh @@ -7,5 +7,5 @@ cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check" -cargo hack miri test --each-feature +cargo hack miri test --each-feature --include-features sync,async --exclude-no-default-features diff --git a/ci/sanitizer.sh b/ci/sanitizer.sh index a21beb3..22ff3d5 100755 --- a/ci/sanitizer.sh +++ b/ci/sanitizer.sh @@ -14,4 +14,4 @@ cargo hack test --lib --each-feature # Run thread sanitizer with cargo-hack RUSTFLAGS="-Z sanitizer=thread" \ -cargo hack -Zbuild-std test --lib --each-feature +cargo hack -Zbuild-std test --lib --each-feature --include-features sync,async --exclude-no-default-features diff --git a/ci/test-stable.sh b/ci/test-stable.sh deleted file mode 100755 index 2b95e2a..0000000 --- a/ci/test-stable.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -ex - -cmd="${1:-test}" - -# Run with all features -cargo "${cmd}" --all-features - -cargo doc --no-deps --all-features - -if [[ "${RUST_VERSION}" == "nightly"* ]]; then - # Check benchmarks - cargo check --benches - - # Check minimal versions - cargo clean - cargo update -Zminimal-versions - cargo check --all-features -fi \ No newline at end of file diff --git a/src/cache.rs b/src/cache.rs index dfd6d0d..0761dc3 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -198,6 +198,7 @@ macro_rules! impl_builder { }; } +#[cfg(feature = "sync")] macro_rules! impl_cache { ($cache: ident, $builder: ident, $item: ident) => { use crate::store::UpdateResult; diff --git a/src/cache/builder.rs b/src/cache/builder.rs index c79d218..4547d83 100644 --- a/src/cache/builder.rs +++ b/src/cache/builder.rs @@ -176,7 +176,7 @@ where /// This is a fine-tuning mechanism and you probably won't have to touch this. #[inline] pub fn set_buffer_size(mut self, sz: usize) -> Self { - self.insert_buffer_size = sz; + self.insert_buffer_size = sz; self } diff --git a/src/ring.rs b/src/ring.rs index d260457..4fc2da2 100644 --- a/src/ring.rs +++ b/src/ring.rs @@ -4,14 +4,17 @@ use parking_lot::Mutex; #[cfg(feature = "async")] use crate::policy::AsyncLFUPolicy; +#[cfg(feature = "sync")] use crate::policy::LFUPolicy; +#[cfg(feature = "sync")] pub struct RingStripe { cons: Arc>, data: Mutex>, capa: usize, } +#[cfg(feature = "sync")] impl RingStripe where S: BuildHasher + Clone + 'static, diff --git a/src/store.rs b/src/store.rs index b327ebc..610ac3d 100644 --- a/src/store.rs +++ b/src/store.rs @@ -1,4 +1,3 @@ -use crate::policy::LFUPolicy; use crate::ttl::{ExpirationMap, Time}; use crate::utils::{change_lifetime_const, SharedValue, ValueRef, ValueRefMut}; use crate::{CacheError, DefaultUpdateValidator, Item as CrateItem, UpdateValidator}; @@ -238,9 +237,10 @@ impl< .map(|val| val.expiration) } + #[cfg(feature = "sync")] pub fn try_cleanup( &self, - policy: Arc>, + policy: Arc>, ) -> Result>, CacheError> { let now = Time::now(); Ok(self