Skip to content

Commit

Permalink
Cleanup features and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Sep 15, 2024
1 parent 3cffe4d commit 6bb9ff1
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 170 deletions.
3 changes: 2 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ ignore:
- "**/integration/"
- "**/examples/"
- "**/benches/"
- "src/tests.rs"
- "src/error.rs"
- "src/swmr/generic/traits/impls/"
- "src/swmr/generic/traits/impls.rs"
- "src/tests.rs"
- "src/swmr/generic/tests.rs"
- "src/swmr/generic/tests/"
- "src/swmr/wal/tests.rs"
Expand Down
68 changes: 22 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,22 @@ jobs:
with:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run test
run: cargo test --all-features

- name: Run test (Unix)
run: RUSTFLAGS="--cfg all_tests" cargo test --all-features
if: matrix.os != 'windows-latest'
- name: Run test (Windows)
shell: pwsh
run: |
$env:RUSTFLAGS="--cfg all_tests"
cargo test --all-features
if: matrix.os == 'windows-latest'

sanitizer:
name: sanitizer
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -217,58 +222,29 @@ jobs:
run: ci/sanitizer_generic.sh
if: matrix.os != 'ubuntu-latest'

# miri-tb-unsync:
# name: miri-tb-unsync
# strategy:
# matrix:
# os:
# - ubuntu-latest
# # - macos-latest
# # - windows-latest
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
# - name: Cache cargo build and registry
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-miri-
# - name: Install cargo-hack
# run: cargo install cargo-hack
# - name: Miri (Linux)
# run: ci/miri_tb_unsync.sh
# if: matrix.os == 'ubuntu-latest'

miri-tb:
name: miri-tb-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.features }}
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
features:
- test-unsync-insert
- test-unsync-iters
- test-unsync-get
- test-unsync-constructor
- test-swmr-insert
- test-swmr-iters
- test-swmr-get
- test-swmr-constructor
- test-swmr-generic-insert
- test-swmr-generic-iters
- test-swmr-generic-get
- test-swmr-generic-constructor
- unsync_insert
- unsync_iters
- unsync_get
- unsync_constructor
- swmr_insert
- swmr_iters
- swmr_get
- swmr_constructor
- swmr_generic_insert
- swmr_generic_iters
- swmr_generic_get
- swmr_generic_constructor
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
36 changes: 19 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ std = ["rarena-allocator/default", "crossbeam-skiplist/default", "bitflags/defau
xxhash3 = ["dbutils/xxhash3", "std"]
xxhash64 = ["dbutils/xxhash64", "std"]

## only for miri testing
test-unsync-insert = ["std"]
test-unsync-iters = ["std"]
test-unsync-get = ["std"]
test-unsync-constructor = ["std"]

test-swmr-insert = ["std"]
test-swmr-iters = ["std"]
test-swmr-get = ["std"]
test-swmr-constructor = ["std"]

test-swmr-generic-insert = ["std"]
test-swmr-generic-iters = ["std"]
test-swmr-generic-get = ["std"]
test-swmr-generic-constructor = ["std"]


[dependencies]
among = { version = "0.1", default-features = false, features = ["either"] }
bitflags = { version = "1", default-features = false }
Expand Down Expand Up @@ -76,3 +59,22 @@ rpath = false
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(all_tests)',
'cfg(test_unsync_constructor)',
'cfg(test_unsync_insert)',
'cfg(test_unsync_iters)',
'cfg(test_unsync_get)',
'cfg(test_swmr_constructor)',
'cfg(test_swmr_insert)',
'cfg(test_swmr_iters)',
'cfg(test_swmr_get)',
'cfg(test_swmr_generic_constructor)',
'cfg(test_swmr_generic_insert)',
'cfg(test_swmr_generic_iters)',
'cfg(test_swmr_generic_get)',
] }
10 changes: 6 additions & 4 deletions ci/miri_tb.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#!/bin/bash
set -e

# Check if TARGET and FEATURES are provided, otherwise panic
# Check if TARGET and CONFIG_FLAGS are provided, otherwise panic
if [ -z "$1" ]; then
echo "Error: TARGET is not provided"
exit 1
fi

if [ -z "$2" ]; then
echo "Error: FEATURES are not provided"
echo "Error: CONFIG_FLAGS are not provided"
exit 1
fi

TARGET=$1
FEATURES=$2
CONFIG_FLAGS=$2

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows -Zmiri-ignore-leaks"

cargo miri test --tests --target $TARGET --features $FEATURES --lib
export RUSTFLAGS="--cfg miri_$CONFIG_FLAGS"

cargo miri test --tests --target $TARGET --lib

6 changes: 3 additions & 3 deletions ci/sanitizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ set -ex
export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0"

# Run address sanitizer
RUSTFLAGS="-Z sanitizer=address" \
RUSTFLAGS="-Z sanitizer=address --cfg all_tests" \
cargo test -Z build-std --all --release --tests --target x86_64-unknown-linux-gnu --all-features --exclude benchmarks -- --test-threads=1

# Run memory sanitizer
RUSTFLAGS="-Z sanitizer=memory" \
RUSTFLAGS="-Z sanitizer=memory --cfg all_tests" \
cargo test -Z build-std --all --release --tests --target x86_64-unknown-linux-gnu --all-features --exclude benchmarks -- --test-threads=1

# Run thread sanitizer
cargo clean
TSAN_OPTIONS="suppressions=$(pwd)/ci/tsan" \
RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=thread" \
RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=thread --cfg all_tests" \
cargo test -Z build-std --all --release --target x86_64-unknown-linux-gnu --all-features --tests --exclude benchmarks -- --test-threads=1
14 changes: 0 additions & 14 deletions ci/sanitizer_generic.sh

This file was deleted.

8 changes: 4 additions & 4 deletions examples/zero_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ struct PersonRef<'a> {
name: &'a str,
}

impl<'a> PartialEq for PersonRef<'a> {
impl PartialEq for PersonRef<'_> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id && self.name == other.name
}
}

impl<'a> Eq for PersonRef<'a> {}
impl Eq for PersonRef<'_> {}

impl<'a> PartialOrd for PersonRef<'a> {
impl PartialOrd for PersonRef<'_> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl<'a> Ord for PersonRef<'a> {
impl Ord for PersonRef<'_> {
fn cmp(&self, other: &Self) -> cmp::Ordering {
self
.id
Expand Down
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,24 @@ const MAGIC_TEXT_SIZE: usize = MAGIC_TEXT.len();
const MAGIC_VERSION_SIZE: usize = mem::size_of::<u16>();
const HEADER_SIZE: usize = MAGIC_TEXT_SIZE + MAGIC_VERSION_SIZE;

#[cfg(test)]
#[cfg(all(
test,
any(
all_tests,
test_unsync_constructor,
test_unsync_insert,
test_unsync_get,
test_unsync_iters,
test_swmr_constructor,
test_swmr_insert,
test_swmr_get,
test_swmr_iters,
test_swmr_generic_constructor,
test_swmr_generic_insert,
test_swmr_generic_get,
test_swmr_generic_iters,
)
))]
#[macro_use]
mod tests;

Expand Down
3 changes: 2 additions & 1 deletion src/swmr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod wal;
/// The ordered write-ahead log only supports bytes.
pub mod wal;
pub use wal::OrderWal;

/// The generic implementation of the ordered write-ahead log.
Expand Down
Loading

0 comments on commit 6bb9ff1

Please sign in to comment.