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

ci(rust): add test coverage ci #489

Merged
merged 4 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ flags:
carryforward: true
paths:
- "golang/**"
rust:
carryforward: true
paths:
- "rust/**"
1 change: 0 additions & 1 deletion .github/workflows/rust_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- name: Build
working-directory: ./rust
run: cargo build

- name: Unit Test
working-directory: ./rust
run: cargo test -- --nocapture
47 changes: 47 additions & 0 deletions .github/workflows/rust_coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Rust Coverage
on:
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'rust/**'
push:
branches:
- master
jobs:
calculate-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install cargo-llvm-cov
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-llvm-cov

- name: Generate code coverage
working-directory: ./rust
run: cargo llvm-cov --all-features --workspace --ignore-filename-regex pb/ --codecov --output-path codecov.json

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
files: ./rust/codecov.json
flags: rust
verbose: true
fail_ci_if_error: true
20 changes: 0 additions & 20 deletions rust/src/main.rs

This file was deleted.

8 changes: 4 additions & 4 deletions rust/src/model/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ pub enum FilterType {

/// Filter expression for message filtering.
pub struct FilterExpression {
pub(crate) filter_type: FilterType,
pub(crate) expression: String,
filter_type: FilterType,
expression: String,
}

impl FilterExpression {
Expand Down Expand Up @@ -231,8 +231,8 @@ impl FilterExpression {
/// Send result returned by producer.
#[derive(Clone, Debug)]
pub struct SendReceipt {
pub(crate) message_id: String,
pub(crate) transaction_id: String,
message_id: String,
transaction_id: String,
}

impl SendReceipt {
Expand Down
15 changes: 10 additions & 5 deletions rust/src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,15 @@ mod tests {
}))
});
producer.client.expect_send_message().returning(|_, _| {
Ok(vec![SendReceipt {
message_id: "".to_string(),
transaction_id: "".to_string(),
}])
Ok(vec![SendReceipt::from_pb_send_result(
&pb::SendResultEntry {
message_id: "message_id".to_string(),
transaction_id: "transaction_id".to_string(),
..pb::SendResultEntry::default()
},
)])
});
producer
let result = producer
.send_one(
MessageBuilder::builder()
.set_topic("test_topic")
Expand All @@ -404,6 +407,8 @@ mod tests {
.unwrap(),
)
.await?;
assert_eq!(result.message_id(), "message_id");
assert_eq!(result.transaction_id(), "transaction_id");
Ok(())
}
}
4 changes: 2 additions & 2 deletions rust/src/simple_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ impl SimpleConsumer {
&endpoints,
message_queue,
pb::FilterExpression {
r#type: expression.filter_type as i32,
expression: expression.expression.clone(),
r#type: expression.filter_type() as i32,
expression: expression.expression().to_string(),
},
batch_size,
prost_types::Duration::try_from(invisible_duration).unwrap(),
Expand Down