Skip to content

Commit a898d58

Browse files
hoe-jocastler
authored andcommitted
[rules score]: add developer mode
1 parent aa322a9 commit a898d58

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

bazel/rules/rules_score/private/dependable_element.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ def _run_validation(ctx, arch_json, static_fbs_files):
642642
validation_args.add("--architecture-json", arch_json)
643643
validation_args.add_all("--component-fbs", static_fbs_files)
644644
validation_args.add("--output", validation_log)
645+
if ctx.attr.maturity == "development":
646+
validation_args.add("--warn-on-errors")
645647

646648
# ctx.actions.run will fail the build if validation_cli returns non-zero exit code
647649
ctx.actions.run(

validation/core/src/main.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ struct Args {
4444

4545
#[arg(long)]
4646
output: Option<String>,
47+
48+
/// When set, validation errors are printed as warnings and the tool exits
49+
/// with code 0. Intended for use during development (maturity=development).
50+
#[arg(long, default_value_t = false)]
51+
warn_on_errors: bool,
4752
}
4853

4954
struct ValidationCliInputs {
@@ -95,7 +100,12 @@ fn run(args: Args) -> Result<(), String> {
95100
let mut context = build_validation_context(inputs)?;
96101
let validators = resolve_validators(&context)?;
97102

98-
run_selected_validators(args.output.as_deref(), &validators, &mut context)
103+
run_selected_validators(
104+
args.output.as_deref(),
105+
args.warn_on_errors,
106+
&validators,
107+
&mut context,
108+
)
99109
}
100110

101111
fn resolve_validators(context: &ValidationContext) -> Result<Vec<SelectedValidator>, String> {
@@ -117,6 +127,7 @@ fn resolve_validators(context: &ValidationContext) -> Result<Vec<SelectedValidat
117127

118128
fn run_selected_validators(
119129
output_path: Option<&str>,
130+
warn_on_errors: bool,
120131
validators: &[SelectedValidator],
121132
context: &mut ValidationContext,
122133
) -> Result<(), String> {
@@ -126,7 +137,7 @@ fn run_selected_validators(
126137
merge_errors(&mut errors, run_validator(*validator, context));
127138
}
128139

129-
finish_validation(output_path, &errors)
140+
finish_validation(output_path, warn_on_errors, &errors)
130141
}
131142

132143
fn run_validator(validator: SelectedValidator, context: &ValidationContext) -> Errors {
@@ -195,7 +206,11 @@ fn merge_errors(target: &mut Errors, incoming: Errors) {
195206
}
196207
}
197208

198-
fn finish_validation(output_path: Option<&str>, errors: &Errors) -> Result<(), String> {
209+
fn finish_validation(
210+
output_path: Option<&str>,
211+
warn_on_errors: bool,
212+
errors: &Errors,
213+
) -> Result<(), String> {
199214
if let Some(path) = output_path {
200215
write_log(path, errors)?;
201216
}
@@ -215,7 +230,12 @@ fn finish_validation(output_path: Option<&str>, errors: &Errors) -> Result<(), S
215230
errors.messages.len(),
216231
details
217232
);
218-
Err(output)
233+
if warn_on_errors {
234+
eprintln!("WARNING: {output}");
235+
Ok(())
236+
} else {
237+
Err(output)
238+
}
219239
}
220240
}
221241

0 commit comments

Comments
 (0)