diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..438503f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,85 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + +name: Test + +jobs: + run-test: + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.ignore-err }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + toolchain: [stable] + ignore-err: [false] + coverage: [false] + include: + - os: ubuntu-latest + toolchain: nightly + ignore-err: true + coverage: true + - os: macos-latest + toolchain: nightly + ignore-err: true + coverage: false + steps: + - uses: actions/checkout@v2 + name: Checkout 🛎️ + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-test + - uses: actions-rs/toolchain@v1 + name: Setup Cargo Toolchain 🛎️ + with: + components: rustfmt, clippy + toolchain: ${{ matrix.toolchain }} + override: true + default: true + - uses: actions-rs/cargo@v1 + name: Check Code Format 🔧 + with: + command: fmt + args: -- --check + - uses: actions-rs/cargo@v1 + name: Run Cargo Clippy 🔧 + with: + command: clippy + args: -- -D warnings + - uses: actions-rs/cargo@v1 + name: Running Tests 🚀 + with: + command: test + args: --all + - uses: actions-rs/cargo@v1 + name: Cargo Clean + if: ${{ matrix.coverage }} + with: + command: clean + - uses: actions-rs/cargo@v1 + name: Tests with coverage reports 🚀 + if: ${{ matrix.coverage }} + with: + command: test + args: --all-features --no-fail-fast + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" + RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" + - id: coverage + if: ${{ matrix.coverage }} + uses: actions-rs/grcov@v0.1 + - name: Coveralls upload 📕 + if: ${{ matrix.coverage }} + uses: codecov/codecov-action@v1 + with: + file: ${{ steps.coverage.outputs.report }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3884840..0000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -language: rust -cache: cargo -sudo: required - -branches: - only: - - master - -os: - - linux - # - windows - - osx - -rust: - - stable - - nightly - -matrix: - allow_failures: - - rust: nightly - fast_finish: true - -before_install: - - curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf - - -install: - - if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then rustup component add rustfmt; fi - - if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then rustup component add clippy; fi - -before_script: - - export PATH=/usr/bin/:$HOME/.cargo/bin:$PATH - -script: - - echo $TRAVIS_RUST_VERSION - - if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then cargo fmt -- --check; fi - - if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then cargo clippy --all; fi - - cargo build --verbose --all - - cargo clean - - | - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [ $TRAVIS_OS_NAME == "linux" ]; then - export CARGO_INCREMENTAL=0; - export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"; - export RUSTDOCFLAGS="-Cpanic=abort"; - sed -i s/stable/nightly/g rust-toolchain - fi - - cargo test --verbose --all - - | - if [ $TRAVIS_OS_NAME == "linux" ] && [ $TRAVIS_RUST_VERSION == "nightly" ]; then - zip -0 ccov.zip `find . \( -name "wickdb*.gc*" \) -print`; - ./grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info; - bash <(curl -s https://codecov.io/bash) -f lcov.info; - fi -env: - global: - - RUST_BACKTRACE=1 diff --git a/src/db/mod.rs b/src/db/mod.rs index 6a7c20c..32b85a9 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -618,7 +618,7 @@ impl DBImpl { } // Recover in the order in which the logs were generated - logs_to_recover.sort(); + logs_to_recover.sort_unstable(); let mut max_sequence = 0; let mut edit = VersionEdit::new(self.options.max_levels); for (i, log_number) in logs_to_recover.iter().enumerate() { diff --git a/src/mem/skiplist.rs b/src/mem/skiplist.rs index c7feb16..7ec7c8b 100644 --- a/src/mem/skiplist.rs +++ b/src/mem/skiplist.rs @@ -251,10 +251,7 @@ impl Skiplist { true } else { let node_key = unsafe { (*n).key() }; - match self.comparator.compare(key, node_key) { - CmpOrdering::Greater => false, - _ => true, - } + !matches!(self.comparator.compare(key, node_key), CmpOrdering::Greater) } } } diff --git a/src/version/mod.rs b/src/version/mod.rs index 5d9cf37..92197cb 100644 --- a/src/version/mod.rs +++ b/src/version/mod.rs @@ -91,7 +91,7 @@ pub struct Version { impl fmt::Debug for Version { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "vnum: {} \n", &self.vnum)?; + writeln!(f, "vnum: {} ", &self.vnum)?; for (level, files) in self.files.iter().enumerate() { write!(f, "level {}: [ ", level)?; for file in files { @@ -101,7 +101,7 @@ impl fmt::Debug for Version { file.number, file.file_size, file.smallest, file.largest )?; } - write!(f, " ]\n")?; + writeln!(f, " ]")?; } Ok(()) } @@ -251,7 +251,7 @@ impl Version { acc }); s.push_str(summary.as_str()); - s.push_str("]"); + s.push(']'); s }