Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enable Rust Unit Tests And Code Coverage in CI #1767

Merged
merged 14 commits into from
Jun 24, 2024
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore:
- "pkg/client/.*"
- "vendor/.*"
- "test/.*"
- "serving/src/error.rs"
coverage:
status:
patch: off
Expand Down
57 changes: 55 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ jobs:
- name: Ensure nothing changed
run: git diff --exit-code

unit-tests:
name: Unit Tests
go-unit-tests:
name: Unit Tests Go
runs-on: ubuntu-latest
timeout-minutes: 10
services:
Expand All @@ -99,23 +99,76 @@ jobs:
with:
go-version: '1.21'
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Restore Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}

- name: Get dependencies
run: go mod download

- name: Test
run: make test-coverage-with-isb

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
files: ./test/profile.cov
token: ${{ secrets.CODECOV_TOKEN }}

rust-unit-tests:
name: Unit Tests Rust
runs-on: ubuntu-latest
timeout-minutes: 10
services:
redis:
image: redis:6.2
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
nats:
image: 'bitnami/nats:latest'
ports:
- 4222:4222
env:
NATS_EXTRA_ARGS: -js
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview

- name: Install grcov
run: cargo install grcov

- name: Run cargo test with coverage
working-directory: ./serving
run: |
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --all-features
mkdir -p ./target/debug/coverage/
grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o lcov.info
find . -name "*.profraw" -type f -delete

- name: Upload Rust coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
files: ./serving/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion config/apps/nats/nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
terminationGracePeriodSeconds: 60
containers:
- name: nats
image: nats:2.9.8-alpine
image: nats:2.10.11-alpine
ports:
- containerPort: 4222
name: client
Expand Down
3 changes: 2 additions & 1 deletion pkg/udf/rpc/grpc_aligned_reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rpc

import (
"context"
"errors"
"fmt"
"strconv"
"time"
Expand Down Expand Up @@ -120,7 +121,7 @@ func (u *GRPCBasedAlignedReduce) ApplyReduce(ctx context.Context, partitionID *p
case err := <-reduceErrCh:
// ctx.Done() event will be handled by the AsyncReduceFn method
// so we don't need a separate case for ctx.Done() here
if err == ctx.Err() {
if errors.Is(err, ctx.Err()) {
errCh <- err
return
}
Expand Down
4 changes: 0 additions & 4 deletions serving/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ async processing platform.

* Response with the status of completion (ability to say whether the processing is complete)
* Response with output of a complex computation over the DCG directly to the callee (say, something like [kserve](https://kserve.github.io/website/latest/)).

## Demo

Please try out [our example](./example/README.md)
Loading