Skip to content

Commit a1a9073

Browse files
authored
fix: add linting (Cargo Clippy & Rust fmt) and unit tests to CI (#1060)
Also fix clippy and fmt issues
1 parent 603b095 commit a1a9073

File tree

5 files changed

+85
-11
lines changed

5 files changed

+85
-11
lines changed

.github/workflows/integration-test.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
name: Integration
2-
1+
name: Integration Tests with Quest
32
on:
43
pull_request:
54
paths-ignore:
6-
- 'docs/**'
7-
- 'helm/**'
8-
- 'assets/**'
9-
- '**.md'
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
109

1110
jobs:
1211

.github/workflows/lint.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lint
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
15+
fmt:
16+
name: Rust fmt check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
override: true
25+
- run: rustup component add rustfmt
26+
- uses: actions-rs/cargo@v1
27+
with:
28+
command: fmt
29+
args: --all -- --check
30+
31+
clippy:
32+
name: Cargo Clippy check
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions-rs/toolchain@v1
37+
with:
38+
profile: minimal
39+
toolchain: stable
40+
override: true
41+
- run: rustup component add clippy
42+
- uses: actions-rs/cargo@v1
43+
with:
44+
command: clippy
45+
args: -- -D warnings

.github/workflows/unit-test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
unit-tests:
15+
name: Unit tests
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions-rs/toolchain@v1
20+
with:
21+
profile: minimal
22+
toolchain: stable
23+
override: true
24+
- uses: actions-rs/cargo@v1
25+
with:
26+
command: test

src/cli.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,14 @@ impl FromArgMatches for Cli {
526526
self.trino_username = m.get_one::<String>(Self::TRINO_USER_NAME).cloned();
527527

528528
self.kafka_topics = m.get_one::<String>(Self::KAFKA_TOPICS).cloned();
529-
self.kafka_host = m.get_one::<String>(Self::KAFKA_HOST).cloned();
529+
self.kafka_security_protocol = m
530+
.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL)
531+
.cloned();
530532
self.kafka_group = m.get_one::<String>(Self::KAFKA_GROUP).cloned();
531533
self.kafka_client_id = m.get_one::<String>(Self::KAFKA_CLIENT_ID).cloned();
532-
self.kafka_security_protocol = m.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL).cloned();
534+
self.kafka_security_protocol = m
535+
.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL)
536+
.cloned();
533537
self.kafka_partitions = m.get_one::<String>(Self::KAFKA_PARTITIONS).cloned();
534538

535539
self.tls_cert_path = m.get_one::<PathBuf>(Self::TLS_CERT).cloned();

src/kafka.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub enum KafkaError {
125125
fn setup_consumer() -> Result<(StreamConsumer, Vec<String>), KafkaError> {
126126
if let Some(topics) = &CONFIG.parseable.kafka_topics {
127127
// topics can be a comma separated list of topics to subscribe to
128-
let topics = topics.split(",").map(|v| v.to_owned()).collect_vec();
128+
let topics = topics.split(',').map(|v| v.to_owned()).collect_vec();
129129

130130
let host = if CONFIG.parseable.kafka_host.is_some() {
131131
CONFIG.parseable.kafka_host.as_ref()
@@ -162,8 +162,8 @@ fn setup_consumer() -> Result<(StreamConsumer, Vec<String>), KafkaError> {
162162
// partitions is a comma separated pairs of topic:partitions
163163
let mut topic_partition_pairs = Vec::new();
164164
let mut set = true;
165-
for vals in vals_raw.split(",") {
166-
let intermediate = vals.split(":").collect_vec();
165+
for vals in vals_raw.split(',') {
166+
let intermediate = vals.split(':').collect_vec();
167167
if intermediate.len() != 2 {
168168
warn!(
169169
"Value for P_KAFKA_PARTITIONS is incorrect! Skipping setting partitions!"

0 commit comments

Comments
 (0)