Skip to content

Commit 89b44c9

Browse files
Merge branch 'main' into redis_reconnect
2 parents 61c4f59 + 27fa965 commit 89b44c9

File tree

30 files changed

+172
-45
lines changed

30 files changed

+172
-45
lines changed

.bazelrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ build --@rules_rust//:extra_rustc_flag=-Wtrivial_casts
8888
build --@rules_rust//:extra_rustc_flag=-Wtrivial_numeric_casts
8989
build --@rules_rust//:extra_rustc_flag=-Dunconditional_recursion
9090
build --@rules_rust//:extra_rustc_flag=-Dunexpected_cfgs
91+
build --@rules_rust//:extra_rustc_flag=-Dunknown_lints
9192
build --@rules_rust//:extra_rustc_flag=-Dunnameable_test_items
9293
build --@rules_rust//:extra_rustc_flag=-Wunreachable_pub
9394
build --@rules_rust//:extra_rustc_flag=-Dunsafe_op_in_unsafe_fn
9495
build --@rules_rust//:extra_rustc_flag=-Dunstable_syntax_pre_expansion
9596
build --@rules_rust//:extra_rustc_flag=-Wunused_import_braces
97+
build --@rules_rust//:extra_rustc_flag=-Dunused_imports
9698
build --@rules_rust//:extra_rustc_flag=-Wunused_lifetimes
9799
build --@rules_rust//:extra_rustc_flag=-Wunused_qualifications
98100
build --@rules_rust//:extra_rustc_flag=-Wvariant_size_differences
@@ -103,25 +105,40 @@ build --@rules_rust//:clippy_flag=-Wclippy::pedantic
103105
build --@rules_rust//:clippy_flag=-Dclippy::alloc_instead_of_core
104106
build --@rules_rust//:clippy_flag=-Dclippy::as_underscore
105107
build --@rules_rust//:clippy_flag=-Dclippy::await_holding_lock
108+
build --@rules_rust//:clippy_flag=-Dclippy::bind_instead_of_map
109+
build --@rules_rust//:clippy_flag=-Dclippy::collapsible_if
106110
build --@rules_rust//:clippy_flag=-Wclippy::dbg_macro
107111
build --@rules_rust//:clippy_flag=-Wclippy::decimal_literal_representation
112+
build --@rules_rust//:clippy_flag=-Dclippy::disallowed_methods
113+
build --@rules_rust//:clippy_flag=-Dclippy::doc_markdown
108114
build --@rules_rust//:clippy_flag=-Dclippy::elidable_lifetime_names
109115
build --@rules_rust//:clippy_flag=-Dclippy::explicit_into_iter_loop
110116
build --@rules_rust//:clippy_flag=-Dclippy::future_not_send
111117
build --@rules_rust//:clippy_flag=-Aclippy::get_unwrap
118+
build --@rules_rust//:clippy_flag=-Dclippy::implicit_clone
119+
build --@rules_rust//:clippy_flag=-Dclippy::implicit_hasher
120+
build --@rules_rust//:clippy_flag=-Dclippy::manual_is_variant_and
121+
build --@rules_rust//:clippy_flag=-Dclippy::map_unwrap_or
112122
build --@rules_rust//:clippy_flag=-Dclippy::missing_const_for_fn
113123
build --@rules_rust//:clippy_flag=-Aclippy::missing_docs_in_private_items
124+
build --@rules_rust//:clippy_flag=-Dclippy::or_fun_call
114125
build --@rules_rust//:clippy_flag=-Wclippy::print_stdout
126+
build --@rules_rust//:clippy_flag=-Dclippy::ptr_arg
115127
build --@rules_rust//:clippy_flag=-Dclippy::redundant_closure_for_method_calls
116128
build --@rules_rust//:clippy_flag=-Dclippy::semicolon_if_nothing_returned
129+
build --@rules_rust//:clippy_flag=-Dclippy::single_char_pattern
117130
build --@rules_rust//:clippy_flag=-Dclippy::std_instead_of_core
118131
build --@rules_rust//:clippy_flag=-Dclippy::string_lit_as_bytes
119132
build --@rules_rust//:clippy_flag=-Dclippy::todo
120133
build --@rules_rust//:clippy_flag=-Aclippy::too_long_first_doc_paragraph
134+
build --@rules_rust//:clippy_flag=-Dclippy::unchecked_duration_subtraction
121135
build --@rules_rust//:clippy_flag=-Wclippy::unimplemented
136+
build --@rules_rust//:clippy_flag=-Dclippy::unnecessary_semicolon
122137
build --@rules_rust//:clippy_flag=-Aclippy::unwrap_in_result
123138
build --@rules_rust//:clippy_flag=-Aclippy::unwrap_used
124139
build --@rules_rust//:clippy_flag=-Wclippy::use_debug
140+
build --@rules_rust//:clippy_flag=-Dclippy::used_underscore_binding
141+
build --@rules_rust//:clippy_flag=-Dclippy::useless_format
125142
build --@rules_rust//:clippy_flag=-Dclippy::cast_possible_truncation
126143
build --@rules_rust//:clippy_flag=-Aclippy::cast_possible_wrap
127144
build --@rules_rust//:clippy_flag=-Aclippy::cast_precision_loss

Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ overlapping-range-endpoints = "deny"
114114
suspicious-double-ref-op = "deny"
115115
unconditional-recursion = "deny"
116116
unexpected-cfgs = "deny"
117+
unknown-lints = "deny"
117118
unnameable-test-items = "deny"
118119
unsafe-op-in-unsafe-fn = "deny"
119120
unstable-syntax-pre-expansion = "deny"
121+
unused-imports = "deny"
120122

121123
keyword-idents = "warn"
122124
let-underscore = "warn"
@@ -147,14 +149,29 @@ pedantic = { level = "warn", priority = -1 }
147149
alloc-instead-of-core = "deny"
148150
as-underscore = "deny"
149151
await-holding-lock = "deny"
152+
bind-instead-of-map = "deny"
153+
collapsible-if = "deny"
154+
disallowed-methods = "deny"
155+
doc-markdown = "deny"
150156
elidable-lifetime-names = "deny"
151157
explicit-into-iter-loop = "deny"
152158
future-not-send = "deny"
159+
implicit-clone = "deny"
160+
implicit-hasher = "deny"
161+
manual-is-variant-and = "deny"
162+
map-unwrap-or = "deny"
163+
or-fun-call = "deny"
164+
ptr-arg = "deny"
153165
redundant-closure-for-method-calls = "deny"
154166
semicolon-if-nothing-returned = "deny"
167+
single-char-pattern = "deny"
155168
std-instead-of-core = "deny"
156169
string-lit-as-bytes = "deny"
157170
todo = "deny"
171+
unchecked-duration-subtraction = "deny"
172+
unnecessary-semicolon = "deny"
173+
used-underscore-binding = "deny"
174+
useless-format = "deny"
158175

159176
# Restriction Warnings with default priority
160177
dbg-macro = "warn"

deployment-examples/metrics/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ services:
4747

4848
# Grafana for visualization
4949
grafana:
50-
image: grafana/grafana:10.3.0
50+
image: grafana/grafana:12.4.0
5151
container_name: grafana
5252
restart: unless-stopped
5353
ports:

nativelink-config/generate-stores-config/src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,31 @@ fn main() {
2222
for block in json_start.captures_iter(&stores_rs) {
2323
let start_marker = block.get(0).unwrap().end();
2424
let end_match = block_end.find(&stores_rs[start_marker..]).unwrap();
25-
let end_marker =end_match.start();
26-
let contents = &stores_rs[start_marker..(start_marker+end_marker)].split("\n").map(|line| line.replacen("///", "", 1)).collect::<Vec<String>>().join("\n");
25+
let end_marker = end_match.start();
26+
let contents = &stores_rs[start_marker..(start_marker + end_marker)]
27+
.split("\n")
28+
.map(|line| line.replacen("///", "", 1))
29+
.collect::<Vec<String>>()
30+
.join("\n");
2731
blocks.push(contents.trim().to_string());
2832
}
2933

30-
let mut output = String::from("// Generated by generate-stores-config from stores.rs comments for testing
34+
let mut output = String::from(
35+
"// Generated by generate-stores-config from stores.rs comments for testing
3136
{
3237
servers: [],
3338
stores: [
34-
");
39+
",
40+
);
3541

3642
for (index, contents) in blocks.iter().enumerate() {
37-
let more_output = format!(r#" {{
43+
let more_output = format!(
44+
r#" {{
3845
name: "{index}",
3946
{contents}
4047
}},
41-
"#);
48+
"#
49+
);
4250
output.push_str(&more_output);
4351
}
4452
output.push_str("]}\n");

nativelink-config/src/cas_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ pub struct LocalWorkerConfig {
732732

733733
/// Maximum time allowed for uploading action results to CAS after execution
734734
/// completes. If upload takes longer than this, the action fails with
735-
/// DeadlineExceeded and may be retried by the scheduler. Value in seconds.
735+
/// `DeadlineExceeded` and may be retried by the scheduler. Value in seconds.
736736
///
737737
/// Default: 600 (seconds / 10 mins)
738738
#[serde(default, deserialize_with = "convert_duration_with_shellexpand")]

nativelink-config/src/schedulers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub struct SimpleSpec {
128128
/// any worker update before being timed out and re-queued.
129129
/// This applies regardless of worker keepalive status, catching cases
130130
/// where a worker is alive (sending keepalives) but stuck on a specific
131-
/// action. Set to 0 to disable (relies only on worker_timeout_s).
131+
/// action. Set to 0 to disable (relies only on `worker_timeout_s`).
132132
///
133133
/// Default: 0 (disabled)
134134
#[serde(default, deserialize_with = "convert_duration_with_shellexpand")]

nativelink-config/src/stores.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ pub struct FilesystemSpec {
616616
pub block_size: u64,
617617

618618
/// Maximum number of concurrent write operations allowed.
619-
/// Each write involves streaming data to a temp file and calling sync_all(),
619+
/// Each write involves streaming data to a temp file and calling `sync_all()`,
620620
/// which can saturate disk I/O when many writes happen simultaneously.
621621
/// Limiting concurrency prevents disk saturation from blocking the async
622622
/// runtime.
@@ -1164,14 +1164,14 @@ pub struct RedisSpec {
11641164
#[serde(deserialize_with = "convert_vec_string_with_shellexpand")]
11651165
pub addresses: Vec<String>,
11661166

1167-
/// DEPRECATED: use command_timeout_ms
1167+
/// DEPRECATED: use `command_timeout_ms`
11681168
/// The response timeout for the Redis connection in seconds.
11691169
///
11701170
/// Default: 10
11711171
#[serde(default)]
11721172
pub response_timeout_s: u64,
11731173

1174-
/// DEPRECATED: use connection_timeout_ms
1174+
/// DEPRECATED: use `connection_timeout_ms`
11751175
///
11761176
/// The connection timeout for the Redis connection in seconds.
11771177
///

nativelink-macro/src/lib.rs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,71 @@
1313
// limitations under the License.
1414

1515
use proc_macro::TokenStream;
16-
use quote::quote;
16+
use proc_macro2::TokenTree;
17+
use quote::{format_ident, quote};
1718
use syn::{ItemFn, parse_macro_input};
1819

20+
// Helper function for debugging. Add prettyplease as dependency
21+
//
22+
// fn unparse(input: proc_macro2::TokenStream) -> String {
23+
// let item = syn::parse2(input).unwrap();
24+
// let file = syn::File {
25+
// attrs: vec![],
26+
// items: vec![item],
27+
// shebang: None,
28+
// };
29+
30+
// prettyplease::unparse(&file)
31+
// }
32+
33+
// Either use this as-is or as `#[nativelink_test("foo")]` where foo is the path for nativelink-util
34+
// Mostly used inside nativelink-util as `#[nativelink_test("crate")]`
35+
// If you start it with an ident instead, e.g. `#[nativelink_test(flavor = "multi_thread")]` we feed it into tokio::test
1936
#[proc_macro_attribute]
2037
pub fn nativelink_test(attr: TokenStream, item: TokenStream) -> TokenStream {
2138
let attr = proc_macro2::TokenStream::from(attr);
2239
let input_fn = parse_macro_input!(item as ItemFn);
40+
let mut maybe_crate_ident: Option<proc_macro2::TokenStream> = None;
41+
let mut maybe_tokio_attrs: Option<proc_macro2::TokenStream> = None;
42+
43+
for a in attr.clone() {
44+
assert!(maybe_crate_ident.is_none());
45+
46+
match a {
47+
TokenTree::Literal(l) => {
48+
let s = format_ident!("{}", l.to_string().replace('"', ""));
49+
maybe_crate_ident = Some(quote! {#s});
50+
}
51+
TokenTree::Ident(_) => {
52+
maybe_tokio_attrs = Some(attr);
53+
break;
54+
}
55+
_ => {
56+
panic!("unsupported tokentree: {a:?}");
57+
}
58+
}
59+
}
2360

2461
let fn_name = &input_fn.sig.ident;
2562
let fn_block = &input_fn.block;
2663
let fn_inputs = &input_fn.sig.inputs;
2764
let fn_output = &input_fn.sig.output;
2865
let fn_attr = &input_fn.attrs;
66+
let crate_ident = maybe_crate_ident.unwrap_or_else(|| quote!(::nativelink_util));
67+
let tokio_attrs = maybe_tokio_attrs.unwrap_or_else(|| quote!());
2968

3069
let expanded = quote! {
3170
#(#fn_attr)*
3271
#[expect(
3372
clippy::disallowed_methods,
3473
reason = "`tokio::test` uses `tokio::runtime::Runtime::block_on`"
3574
)]
36-
#[tokio::test(#attr)]
75+
#[tokio::test(#tokio_attrs)]
3776
#[::tracing_test::traced_test]
3877
async fn #fn_name(#fn_inputs) #fn_output {
39-
::nativelink_util::__tracing::error_span!(stringify!(#fn_name))
78+
#crate_ident::__tracing::error_span!(stringify!(#fn_name))
4079
.in_scope(|| async move {
41-
::nativelink_util::common::reseed_rng_for_test().unwrap();
80+
#crate_ident::common::reseed_rng_for_test().unwrap();
4281
let res = #fn_block;
4382
logs_assert(|lines: &[&str]| {
4483
for line in lines {

nativelink-proto/gen_lib_rs_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
clippy::missing_const_for_fn,
5151
clippy::similar_names,
5252
clippy::std_instead_of_core,
53+
clippy::use_self,
54+
rustdoc::broken_intra_doc_links,
5355
rustdoc::invalid_html_tags
5456
)]
5557
"""

nativelink-proto/genproto/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
clippy::missing_const_for_fn,
3131
clippy::similar_names,
3232
clippy::std_instead_of_core,
33+
clippy::use_self,
34+
rustdoc::broken_intra_doc_links,
3335
rustdoc::invalid_html_tags
3436
)]
3537

0 commit comments

Comments
 (0)