Skip to content

Commit d2f78b2

Browse files
authored
ci: Fix CI errors (#381)
Signed-off-by: Ping Yu <yuping@pingcap.com>
1 parent 027a7df commit d2f78b2

File tree

13 files changed

+57
-35
lines changed

13 files changed

+57
-35
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
profile: minimal
1818
toolchain: nightly
1919
override: true
20+
- name: Install Protoc
21+
uses: arduino/setup-protoc@v1
22+
with:
23+
version: '3.x'
24+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2025
- name: Rust Cache
2126
uses: Swatinem/rust-cache@v1.4.0
2227
- uses: actions-rs/cargo@v1
@@ -39,6 +44,7 @@ jobs:
3944
with:
4045
command: fmt
4146
args: --all -- --check
47+
4248
clippy:
4349
name: clippy
4450
runs-on: ubuntu-latest
@@ -49,13 +55,19 @@ jobs:
4955
toolchain: nightly
5056
components: clippy
5157
override: true
58+
- name: Install Protoc
59+
uses: arduino/setup-protoc@v1
60+
with:
61+
version: '3.x'
62+
repo-token: ${{ secrets.GITHUB_TOKEN }}
5263
- name: Rust Cache
5364
uses: Swatinem/rust-cache@v1.4.0
5465
- uses: actions-rs/clippy-check@v1
5566
with:
5667
token: ${{ secrets.GITHUB_TOKEN }}
5768
args: --all-targets --all-features -- -D clippy::all
5869
name: Clippy Output
70+
5971
unit-test:
6072
name: unit test
6173
env:
@@ -68,10 +80,16 @@ jobs:
6880
profile: minimal
6981
toolchain: nightly
7082
override: true
83+
- name: Install Protoc
84+
uses: arduino/setup-protoc@v1
85+
with:
86+
version: '3.x'
87+
repo-token: ${{ secrets.GITHUB_TOKEN }}
7188
- name: Rust Cache
7289
uses: Swatinem/rust-cache@v1.4.0
7390
- name: unit test
7491
run: make unit-test
92+
7593
integration-test:
7694
name: integration test
7795
env:
@@ -84,6 +102,11 @@ jobs:
84102
profile: minimal
85103
toolchain: nightly
86104
override: true
105+
- name: Install Protoc
106+
uses: arduino/setup-protoc@v1
107+
with:
108+
version: '3.x'
109+
repo-token: ${{ secrets.GITHUB_TOKEN }}
87110
- name: Rust Cache
88111
uses: Swatinem/rust-cache@v1.4.0
89112
- name: install tiup

examples/raw.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async fn main() -> Result<()> {
3535
//
3636
// Here we set the key `TiKV` to have the value `Rust` associated with it.
3737
client.put(KEY.to_owned(), VALUE.to_owned()).await.unwrap(); // Returns a `tikv_client::Error` on failure.
38-
println!("Put key {:?}, value {:?}.", KEY, VALUE);
38+
println!("Put key {KEY:?}, value {VALUE:?}.");
3939

4040
// Unlike a standard Rust HashMap all calls take owned values. This is because under the hood
4141
// protobufs must take ownership of the data. If we only took a borrow we'd need to internally
@@ -48,15 +48,15 @@ async fn main() -> Result<()> {
4848
// types are supported as well, but it all ends up as `Vec<u8>` in the end.
4949
let value: Option<Value> = client.get(KEY.to_owned()).await?;
5050
assert_eq!(value, Some(Value::from(VALUE.to_owned())));
51-
println!("Get key `{}` returned value {:?}.", KEY, value);
51+
println!("Get key `{KEY}` returned value {value:?}.");
5252

5353
// You can also set the `ColumnFamily` used by the request.
5454
// This is *advanced usage* and should have some special considerations.
5555
client
5656
.delete(KEY.to_owned())
5757
.await
5858
.expect("Could not delete value");
59-
println!("Key: `{}` deleted", KEY);
59+
println!("Key: `{KEY}` deleted");
6060

6161
// Here we check if the key has been deleted from the key-value store.
6262
let value: Option<Value> = client
@@ -80,7 +80,7 @@ async fn main() -> Result<()> {
8080
.batch_get(keys.clone())
8181
.await
8282
.expect("Could not get values");
83-
println!("Found values: {:?} for keys: {:?}", values, keys);
83+
println!("Found values: {values:?} for keys: {keys:?}");
8484

8585
// Scanning a range of keys is also possible giving it two bounds
8686
// it will returns all entries between these two.
@@ -96,7 +96,7 @@ async fn main() -> Result<()> {
9696
&keys,
9797
&[Key::from("k1".to_owned()), Key::from("k2".to_owned()),]
9898
);
99-
println!("Scaning from {:?} to {:?} gives: {:?}", start, end, keys);
99+
println!("Scanning from {start:?} to {end:?} gives: {keys:?}");
100100

101101
let k1 = "k1";
102102
let k2 = "k2";
@@ -126,10 +126,7 @@ async fn main() -> Result<()> {
126126
"v3".to_owned()
127127
]
128128
);
129-
println!(
130-
"Scaning batch scan from {:?} gives: {:?}",
131-
batch_scan_keys, vals
132-
);
129+
println!("Scanning batch scan from {batch_scan_keys:?} gives: {vals:?}");
133130

134131
// Cleanly exit.
135132
Ok(())

examples/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn scan(client: &Client, range: impl Into<BoundRange>, limit: u32) {
5252
txn.scan(range, limit)
5353
.await
5454
.expect("Could not scan key-value pairs in range")
55-
.for_each(|pair| println!("{:?}", pair));
55+
.for_each(|pair| println!("{pair:?}"));
5656
txn.commit().await.expect("Could not commit transaction");
5757
}
5858

mock-tikv/src/pd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl MockPd {
3232
fn store() -> tikv_client_proto::metapb::Store {
3333
// TODO: start_timestamp?
3434
tikv_client_proto::metapb::Store {
35-
address: format!("localhost:{}", MOCK_TIKV_PORT),
35+
address: format!("localhost:{MOCK_TIKV_PORT}"),
3636
..Default::default()
3737
}
3838
}
@@ -58,7 +58,7 @@ impl Pd for MockPd {
5858
) {
5959
let member = Member {
6060
name: "mock tikv".to_owned(),
61-
client_urls: vec![format!("localhost:{}", MOCK_PD_PORT)],
61+
client_urls: vec![format!("localhost:{MOCK_PD_PORT}")],
6262
..Default::default()
6363
};
6464
let resp = GetMembersResponse {

src/kv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct HexRepr<'a>(pub &'a [u8]);
1717
impl<'a> fmt::Display for HexRepr<'a> {
1818
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1919
for byte in self.0 {
20-
write!(f, "{:02X}", byte)?;
20+
write!(f, "{byte:02X}")?;
2121
}
2222
Ok(())
2323
}

src/pd/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fn thread_name(prefix: &str) -> String {
285285
thread::current()
286286
.name()
287287
.and_then(|name| name.split("::").skip(1).last())
288-
.map(|tag| format!("{}::{}", prefix, tag))
288+
.map(|tag| format!("{prefix}::{tag}"))
289289
.unwrap_or_else(|| prefix.to_owned())
290290
}
291291

src/region_cache.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ impl<C: RetryClientTrait> RegionCache<C> {
111111
}
112112
}
113113
Err(Error::StringError(format!(
114-
"Concurrent PD requests failed for {} times",
115-
MAX_RETRY_WAITING_CONCURRENT_REQUEST
114+
"Concurrent PD requests failed for {MAX_RETRY_WAITING_CONCURRENT_REQUEST} times"
116115
)))
117116
}
118117

src/request/plan.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ where
155155
)
156156
.await
157157
}
158-
None => Err(Error::RegionError(e)),
158+
None => Err(Error::RegionError(Box::new(e))),
159159
}
160160
} else {
161161
Ok(vec![Ok(resp)])
@@ -213,7 +213,7 @@ where
213213
|| e.has_raft_entry_too_large()
214214
|| e.has_max_timestamp_not_synced()
215215
{
216-
Err(Error::RegionError(e))
216+
Err(Error::RegionError(Box::new(e)))
217217
} else {
218218
// TODO: pass the logger around
219219
// info!("unknwon region error: {:?}", e);
@@ -475,7 +475,10 @@ where
475475
Err(Error::ExtractedErrors(errors))
476476
} else if let Some(errors) = result.region_errors() {
477477
Err(Error::ExtractedErrors(
478-
errors.into_iter().map(Error::RegionError).collect(),
478+
errors
479+
.into_iter()
480+
.map(|e| Error::RegionError(Box::new(e)))
481+
.collect(),
479482
))
480483
} else {
481484
Ok(result)

src/transaction/lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ mod tests {
159159
};
160160
Ok(Box::new(resp) as Box<dyn Any>)
161161
});
162-
Ok(Box::new(kvrpcpb::ResolveLockResponse::default()) as Box<dyn Any>)
162+
Ok(Box::<kvrpcpb::ResolveLockResponse>::default() as Box<dyn Any>)
163163
},
164164
)));
165165

src/transaction/transaction.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ impl<PdC: PdClient> Committer<PdC> {
13261326
if self.write_size > TXN_COMMIT_BATCH_SIZE {
13271327
let size_mb = self.write_size as f64 / 1024.0 / 1024.0;
13281328
lock_ttl = (TTL_FACTOR * size_mb.sqrt()) as u64;
1329-
lock_ttl = lock_ttl.min(MAX_TTL).max(DEFAULT_LOCK_TTL);
1329+
lock_ttl = lock_ttl.clamp(DEFAULT_LOCK_TTL, MAX_TTL);
13301330
}
13311331
lock_ttl
13321332
}
@@ -1388,11 +1388,11 @@ mod tests {
13881388
move |req: &dyn Any| {
13891389
if req.downcast_ref::<kvrpcpb::TxnHeartBeatRequest>().is_some() {
13901390
heartbeats_cloned.fetch_add(1, Ordering::SeqCst);
1391-
Ok(Box::new(kvrpcpb::TxnHeartBeatResponse::default()) as Box<dyn Any>)
1391+
Ok(Box::<kvrpcpb::TxnHeartBeatResponse>::default() as Box<dyn Any>)
13921392
} else if req.downcast_ref::<kvrpcpb::PrewriteRequest>().is_some() {
1393-
Ok(Box::new(kvrpcpb::PrewriteResponse::default()) as Box<dyn Any>)
1393+
Ok(Box::<kvrpcpb::PrewriteResponse>::default() as Box<dyn Any>)
13941394
} else {
1395-
Ok(Box::new(kvrpcpb::CommitResponse::default()) as Box<dyn Any>)
1395+
Ok(Box::<kvrpcpb::CommitResponse>::default() as Box<dyn Any>)
13961396
}
13971397
},
13981398
)));
@@ -1432,16 +1432,16 @@ mod tests {
14321432
move |req: &dyn Any| {
14331433
if req.downcast_ref::<kvrpcpb::TxnHeartBeatRequest>().is_some() {
14341434
heartbeats_cloned.fetch_add(1, Ordering::SeqCst);
1435-
Ok(Box::new(kvrpcpb::TxnHeartBeatResponse::default()) as Box<dyn Any>)
1435+
Ok(Box::<kvrpcpb::TxnHeartBeatResponse>::default() as Box<dyn Any>)
14361436
} else if req.downcast_ref::<kvrpcpb::PrewriteRequest>().is_some() {
1437-
Ok(Box::new(kvrpcpb::PrewriteResponse::default()) as Box<dyn Any>)
1437+
Ok(Box::<kvrpcpb::PrewriteResponse>::default() as Box<dyn Any>)
14381438
} else if req
14391439
.downcast_ref::<kvrpcpb::PessimisticLockRequest>()
14401440
.is_some()
14411441
{
1442-
Ok(Box::new(kvrpcpb::PessimisticLockResponse::default()) as Box<dyn Any>)
1442+
Ok(Box::<kvrpcpb::PessimisticLockResponse>::default() as Box<dyn Any>)
14431443
} else {
1444-
Ok(Box::new(kvrpcpb::CommitResponse::default()) as Box<dyn Any>)
1444+
Ok(Box::<kvrpcpb::CommitResponse>::default() as Box<dyn Any>)
14451445
}
14461446
},
14471447
)));

0 commit comments

Comments
 (0)