From 48bdaa1234ab409fb3a774c21ad3345ec0e72f88 Mon Sep 17 00:00:00 2001 From: beinan Date: Mon, 6 Oct 2025 21:35:13 +0000 Subject: [PATCH] Add unit test workflow for rust code --- .github/workflows/build.yml | 8 +++- .github/workflows/rust-test.yml | 78 +++++++++++++++++++++++++++++++++ .github/workflows/style.yml | 8 +++- 3 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/rust-test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4efb93f4..3119334f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,8 @@ on: paths: - rust/** - .github/workflows/build.yml - - Cargo.toml - - Cargo.lock + - rust/lance-graph/Cargo.toml + - rust/lance-graph/Cargo.lock concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -37,6 +37,10 @@ jobs: - uses: Swatinem/rust-cache@v2 with: workspaces: rust/lance-graph + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y protobuf-compiler - name: Build run: cargo build --manifest-path rust/lance-graph/Cargo.toml - name: Build tests diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml new file mode 100644 index 00000000..b1b4cfc4 --- /dev/null +++ b/.github/workflows/rust-test.yml @@ -0,0 +1,78 @@ +name: Rust Tests +on: + push: + branches: + - main + pull_request: + paths: + - rust/** + - .github/workflows/rust-test.yml + - Cargo.toml + - Cargo.lock + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: "-C debuginfo=1" + RUST_BACKTRACE: "1" + CARGO_INCREMENTAL: "0" + +jobs: + test: + runs-on: ubuntu-24.04 + timeout-minutes: 30 + strategy: + matrix: + toolchain: + - stable + - nightly + steps: + - uses: actions/checkout@v4 + - name: Setup rust toolchain + run: | + rustup toolchain install ${{ matrix.toolchain }} + rustup default ${{ matrix.toolchain }} + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust/lance-graph + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y protobuf-compiler + - name: Build tests + run: cargo test --manifest-path rust/lance-graph/Cargo.toml --no-run + - name: Run unit tests + run: cargo test --manifest-path rust/lance-graph/Cargo.toml --lib + - name: Run doc tests + run: cargo test --manifest-path rust/lance-graph/Cargo.toml --doc + + test-with-coverage: + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Setup rust toolchain + run: | + rustup toolchain install stable + rustup default stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust/lance-graph + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y protobuf-compiler + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Run tests with coverage + run: | + cargo llvm-cov --manifest-path rust/lance-graph/Cargo.toml --lcov --output-path lcov.info + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: lcov.info + flags: rust-unittests + fail_ci_if_error: false \ No newline at end of file diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index b6073353..1954f059 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -7,8 +7,8 @@ on: paths: - rust/** - .github/workflows/style.yml - - Cargo.toml - - Cargo.lock + - rust/lance-graph/Cargo.toml + - rust/lance-graph/Cargo.lock concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -38,6 +38,10 @@ jobs: - uses: Swatinem/rust-cache@v2 with: workspaces: rust/lance-graph + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y protobuf-compiler - name: Clippy run: cargo clippy --manifest-path rust/lance-graph/Cargo.toml --all-targets -- -D warnings