rust-rocksdb 0.47.0

Rust wrapper for Facebook's RocksDB embeddable database
Documentation
name: RocksDB CI

on:
  push:
    branches: [master]
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always

jobs:
  style:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt
          cache: false
          rustflags: ""

      - name: Run rustfmt
        run: cargo fmt --all -- --check

  doc-check:
    name: Rustdoc-check
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rust-docs

      - name: Run cargo rustdoc
        run: cargo rustdoc -- -D warnings

  doctest: # doctest are no supported in cargo nextest yet. https://github.com/nextest-rs/nextest/issues/16
    name: Doctests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1

      - name: Run doctests
        run: cargo test --doc

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: clippy

      - name: Install dependencies
        run: sudo apt-get update && sudo apt-get install -y liburing-dev pkg-config

      - name: Set PKG_CONFIG_PATH
        run: echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV

      - name: Run clippy
        run: |
          cargo clippy --all-targets --features \
            "jemalloc \
            io-uring \
            valgrind \
            mt_static \
            rtti \
            multi-threaded-cf \
            malloc-usable-size \
            zstd-static-linking-only \
            serde1" \
            -- -D warnings

  audit:
    name: Security audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions-rust-lang/audit@v1

  test:
    name: ${{ matrix.build }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        build: [Linux, Linux-ARM, macOS, Windows]
        include:
          - build: Linux
            os: ubuntu-latest
          - build: Linux-ARM
            os: ubuntu-24.04-arm
          - build: macOS
            os: macos-latest
          - build: Windows
            os: windows-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5
        with:
          submodules: recursive

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          save-if: ${{ github.ref == 'refs/heads/master' }}

      - uses: taiki-e/install-action@nextest

      - name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
        if: runner.os == 'Windows'
        run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse

      - name: Install dependencies
        if: runner.os == 'Windows'
        run: choco install llvm -y

      - name: Mark working directory as read-only
        if: runner.os == 'Linux'
        run: |
          mkdir -p target
          touch Cargo.lock
          chmod -R a-w .
          chmod -R a+w target Cargo.lock

      - name: Run rocksdb tests
        run: cargo nextest run --all

      - name: Mark working directory as writable
        if: runner.os == 'Linux'
        run: chmod -R a+w .

  test-multi-threaded-cf:
    name: ${{ matrix.build }} (multi-threaded-cf)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        build: [Linux, Linux-ARM, macOS, Windows]
        include:
          - build: Linux
            os: ubuntu-latest
          - build: Linux-ARM
            os: ubuntu-24.04-arm
          - build: macOS
            os: macos-latest
          - build: Windows
            os: windows-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5
        with:
          submodules: recursive

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          cache-key: "v1-rust-multi-threaded-cf"
          save-if: ${{ github.ref == 'refs/heads/master' }}

      - uses: taiki-e/install-action@nextest

      - name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
        if: runner.os == 'Windows'
        run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse

      - name: Install dependencies
        if: runner.os == 'Windows'
        run: choco install llvm -y

      - name: Mark working directory as read-only
        if: runner.os == 'Linux'
        run: |
          mkdir -p target
          touch Cargo.lock
          chmod -R a-w .
          chmod -R a+w target Cargo.lock

      - name: Run rocksdb tests (multi-threaded-cf)
        run: cargo nextest run --all --features multi-threaded-cf

      - name: Mark working directory as writable
        if: runner.os == 'Linux'
        run: chmod -R a+w .

  test-jemalloc:
    name: Test with jemalloc - ${{ matrix.build }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        build: [Linux, Linux-ARM, macOS]
        include:
          - build: Linux
            os: ubuntu-latest
          - build: Linux-ARM
            os: ubuntu-24.04-arm
          - build: macOS
            os: macos-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5
        with:
          submodules: recursive

      - name: Install rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          cache-key: "v1-rust-jemalloc"
          save-if: ${{ github.ref == 'refs/heads/master' }}

      - uses: taiki-e/install-action@nextest

      - name: Mark working directory as read-only
        if: runner.os == 'Linux'
        run: |
          mkdir -p target
          touch Cargo.lock
          chmod -R a-w .
          chmod -R a+w target Cargo.lock

      - name: Run rocksdb tests with jemalloc
        run: cargo nextest run --all --features jemalloc

      - name: Mark working directory as writable
        if: runner.os == 'Linux'
        run: chmod -R a+w .

  test-sanitizers:
    name: Test with AddressSanitizer
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5
        with:
          submodules: recursive

      - name: Install rust nightly
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: nightly
          components: rust-src
          cache-key: "v1-rust-asan"
          save-if: ${{ github.ref == 'refs/heads/master' }}
          rustflags: ""

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y llvm clang

      - name: Run tests with AddressSanitizer
        env:
          RUSTFLAGS: -Zsanitizer=address
          RUSTDOCFLAGS: -Zsanitizer=address
          ASAN_OPTIONS: detect_leaks=0:abort_on_error=1:print_stats=1
        run: |
          cargo +nightly test -Zbuild-std --target x86_64-unknown-linux-gnu --all --lib --bins