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 8aab7e7
Show file tree
Hide file tree
Showing 28 changed files with 316 additions and 282 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
133 changes: 76 additions & 57 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,44 @@ 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 }}
name: miri-tb-${{ matrix.target }}-${{ matrix.cfg }}
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
- x86_64-apple-darwin
- aarch64-apple-darwin
cfg:
- 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
# Exclude invalid combinations
exclude:
- os: ubuntu-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: aarch64-apple-darwin
# - os: macos-latest
# target: x86_64-unknown-linux-gnu
# - os: macos-latest
# target: i686-unknown-linux-gnu
# - os: macos-latest
# target: powerpc64-unknown-linux-gnu
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -284,19 +275,48 @@ jobs:
${{ runner.os }}-miri-
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
- name: Miri
run: |
bash ci/miri_tb.sh ${{ matrix.target }} ${{ matrix.features }}
if: matrix.os == 'ubuntu-latest'
bash ci/miri_tb.sh ${{ matrix.target }} ${{ matrix.cfg }}
# miri-sb:
# name: miri-sb
# name: miri-sb-${{ matrix.target }}-${{ matrix.cfg }}
# strategy:
# matrix:
# os:
# - ubuntu-latest
# - macos-latest
# - windows-latest
# target:
# - x86_64-unknown-linux-gnu
# - i686-unknown-linux-gnu
# - powerpc64-unknown-linux-gnu
# - x86_64-apple-darwin
# - aarch64-apple-darwin
# cfg:
# - 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
# # Exclude invalid combinations
# exclude:
# - os: ubuntu-latest
# target: x86_64-apple-darwin
# - os: ubuntu-latest
# target: aarch64-apple-darwin
# - os: macos-latest
# target: x86_64-unknown-linux-gnu
# - os: macos-latest
# target: i686-unknown-linux-gnu
# - os: macos-latest
# target: powerpc64-unknown-linux-gnu
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
Expand All @@ -312,12 +332,9 @@ jobs:
# ${{ runner.os }}-miri-
# - name: Install cargo-hack
# run: cargo install cargo-hack
# - name: Miri (Linux)
# run: ci/miri_sb.sh
# if: matrix.os == 'ubuntu-latest'
# - name: Miri
# run: ci/miri_sb_generic.sh
# if: matrix.os != 'ubuntu-latest'
# run: |
# bash ci/miri_sb.sh ${{ matrix.target }} ${{ matrix.cfg }}

# valgrind
valgrind:
Expand Down Expand Up @@ -388,6 +405,8 @@ jobs:
key: ${{ runner.os }}-coverage-cargo-build-target
- name: Run tarpaulin
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: "--cfg all_tests"
with:
command: tarpaulin
args: --all-features --run-types tests --run-types doctests --workspace --out xml
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)',
] }
20 changes: 16 additions & 4 deletions ci/miri_sb.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!/bin/bash
set -e

# 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: CONFIG_FLAGS are not provided"
exit 1
fi

TARGET=$1
CONFIG_FLAGS=$2

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

export MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-symbolic-alignment-check"
export RUSTFLAGS="--cfg test_$CONFIG_FLAGS"

cargo miri test --tests --target x86_64-unknown-linux-gnu --all-features
# cargo miri test --tests --target aarch64-unknown-linux-gnu #crossbeam_utils has problem on this platform
cargo miri test --tests --target i686-unknown-linux-gnu --all-features
cargo miri test --tests --target powerpc64-unknown-linux-gnu --all-features
cargo miri test --tests --target $TARGET --lib
10 changes: 0 additions & 10 deletions ci/miri_sb_generic.sh

This file was deleted.

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 test_$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
Loading

0 comments on commit 8aab7e7

Please sign in to comment.