Skip to content

Commit 48bdaa1

Browse files
committed
Add unit test workflow for rust code
1 parent 7b8aa78 commit 48bdaa1

3 files changed

Lines changed: 90 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
paths:
88
- rust/**
99
- .github/workflows/build.yml
10-
- Cargo.toml
11-
- Cargo.lock
10+
- rust/lance-graph/Cargo.toml
11+
- rust/lance-graph/Cargo.lock
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -37,6 +37,10 @@ jobs:
3737
- uses: Swatinem/rust-cache@v2
3838
with:
3939
workspaces: rust/lance-graph
40+
- name: Install dependencies
41+
run: |
42+
sudo apt update
43+
sudo apt install -y protobuf-compiler
4044
- name: Build
4145
run: cargo build --manifest-path rust/lance-graph/Cargo.toml
4246
- name: Build tests

.github/workflows/rust-test.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Rust Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- rust/**
9+
- .github/workflows/rust-test.yml
10+
- Cargo.toml
11+
- Cargo.lock
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
CARGO_TERM_COLOR: always
19+
RUSTFLAGS: "-C debuginfo=1"
20+
RUST_BACKTRACE: "1"
21+
CARGO_INCREMENTAL: "0"
22+
23+
jobs:
24+
test:
25+
runs-on: ubuntu-24.04
26+
timeout-minutes: 30
27+
strategy:
28+
matrix:
29+
toolchain:
30+
- stable
31+
- nightly
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Setup rust toolchain
35+
run: |
36+
rustup toolchain install ${{ matrix.toolchain }}
37+
rustup default ${{ matrix.toolchain }}
38+
- uses: Swatinem/rust-cache@v2
39+
with:
40+
workspaces: rust/lance-graph
41+
- name: Install dependencies
42+
run: |
43+
sudo apt update
44+
sudo apt install -y protobuf-compiler
45+
- name: Build tests
46+
run: cargo test --manifest-path rust/lance-graph/Cargo.toml --no-run
47+
- name: Run unit tests
48+
run: cargo test --manifest-path rust/lance-graph/Cargo.toml --lib
49+
- name: Run doc tests
50+
run: cargo test --manifest-path rust/lance-graph/Cargo.toml --doc
51+
52+
test-with-coverage:
53+
runs-on: ubuntu-24.04
54+
timeout-minutes: 30
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Setup rust toolchain
58+
run: |
59+
rustup toolchain install stable
60+
rustup default stable
61+
- uses: Swatinem/rust-cache@v2
62+
with:
63+
workspaces: rust/lance-graph
64+
- name: Install dependencies
65+
run: |
66+
sudo apt update
67+
sudo apt install -y protobuf-compiler
68+
- name: Install cargo-llvm-cov
69+
uses: taiki-e/install-action@cargo-llvm-cov
70+
- name: Run tests with coverage
71+
run: |
72+
cargo llvm-cov --manifest-path rust/lance-graph/Cargo.toml --lcov --output-path lcov.info
73+
- name: Upload coverage to Codecov
74+
uses: codecov/codecov-action@v4
75+
with:
76+
files: lcov.info
77+
flags: rust-unittests
78+
fail_ci_if_error: false

.github/workflows/style.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
paths:
88
- rust/**
99
- .github/workflows/style.yml
10-
- Cargo.toml
11-
- Cargo.lock
10+
- rust/lance-graph/Cargo.toml
11+
- rust/lance-graph/Cargo.lock
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -38,6 +38,10 @@ jobs:
3838
- uses: Swatinem/rust-cache@v2
3939
with:
4040
workspaces: rust/lance-graph
41+
- name: Install dependencies
42+
run: |
43+
sudo apt update
44+
sudo apt install -y protobuf-compiler
4145
- name: Clippy
4246
run: cargo clippy --manifest-path rust/lance-graph/Cargo.toml --all-targets -- -D warnings
4347

0 commit comments

Comments
 (0)