From c7cc502535b636b65d30df5b63539f6a85bb5b52 Mon Sep 17 00:00:00 2001 From: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:43:02 +0200 Subject: [PATCH 1/2] clippy: added clippy checks Addresses: eclipse-score/score#2008 Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> --- .bazelrc | 5 ++++ .github/workflows/bazel_clippy.yml | 28 +++++++++++++++++++ BUILD | 13 +++++++++ MODULE.bazel | 1 + README.md | 6 ++++ .../rust_test_scenarios/BUILD | 7 +++-- .../basic/orchestration_with_persistency.rs | 2 +- 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/bazel_clippy.yml diff --git a/.bazelrc b/.bazelrc index 1b19025099..6524da0305 100644 --- a/.bazelrc +++ b/.bazelrc @@ -15,6 +15,11 @@ common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry common --registry=https://bcr.bazel.build +# Clippy linting (enabled by default) +build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect +build --output_groups=+clippy_checks +build --@rules_rust//rust/settings:clippy.toml=@score_rust_policies//clippy/strict:clippy.toml + # Flags needed by score_baselibs and communication modules. # Do not add more! build --@score_baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False diff --git a/.github/workflows/bazel_clippy.yml b/.github/workflows/bazel_clippy.yml new file mode 100644 index 0000000000..fcd1595ee5 --- /dev/null +++ b/.github/workflows/bazel_clippy.yml @@ -0,0 +1,28 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +name: Bazel Clippy + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + +jobs: + bazel-clippy: + uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@main + with: + bazel-target: "build //:clippy" diff --git a/BUILD b/BUILD index 8ef451a21e..384f7aadd0 100644 --- a/BUILD +++ b/BUILD @@ -12,6 +12,7 @@ # ******************************************************************************* load("@score_docs_as_code//:docs.bzl", "docs") +load("@rules_rust//rust:defs.bzl", "rust_clippy") docs( data = [ @@ -30,3 +31,15 @@ filegroup( srcs = ["README.md"], visibility = ["//visibility:public"], ) + +rust_clippy( + name = "clippy", + testonly = True, + tags = ["manual"], + visibility = ["//visibility:public"], + deps = [ + "//feature_integration_tests/rust_test_scenarios:rust_test_scenarios", + "//feature_showcase/rust:kyron_example", + "//feature_showcase/rust:orch_per_example", + ], +) diff --git a/MODULE.bazel b/MODULE.bazel index 7cce020da0..288dc3acdc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -64,5 +64,6 @@ git_override( # imports for the feature showcase module bazel_dep(name = "rules_rust", version = "0.61.0") +bazel_dep(name = "score_rust_policies", version = "0.0.2", dev_dependency = True) bazel_dep(name = "score_itf", version = "0.1.0") bazel_dep(name = "score_crates", version = "0.0.4") diff --git a/README.md b/README.md index f56b3abeb5..4cbdff9c54 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ bazel build --config bl-x86_64-linux \ bazel build --config bl-x86_64-linux @score_orchestrator//src/... ``` +## Clippy + +- Clippy runs by default via `.bazelrc` on all Rust targets (Rust tests may be tagged `no-clippy`). +- Use `bazel build //:clippy` if you want an explicit lint-only target, or build the Rust targets normally to see Clippy diagnostics. +- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`. + ## Feature showcase examples The examples that are aiming to showcase features provided by S-CORE are located in `feature_showcase` folder. You can run them currently for host platform using `--config bl-x86_64-linux`. diff --git a/feature_integration_tests/rust_test_scenarios/BUILD b/feature_integration_tests/rust_test_scenarios/BUILD index d6c2e0db3c..f4d92d31ad 100644 --- a/feature_integration_tests/rust_test_scenarios/BUILD +++ b/feature_integration_tests/rust_test_scenarios/BUILD @@ -16,7 +16,10 @@ load("@rules_rust//rust:defs.bzl", "rust_binary") rust_binary( name = "rust_test_scenarios", srcs = glob(["src/**/*.rs"]), - visibility = ["//feature_integration_tests/python_test_cases:__pkg__"], + visibility = [ + "//feature_integration_tests/python_test_cases:__pkg__", + "//visibility:public", + ], tags = [ "manual", ], @@ -31,4 +34,4 @@ rust_binary( "@score_crates//:serde", "@score_crates//:serde_json", ], -) \ No newline at end of file +) diff --git a/feature_integration_tests/rust_test_scenarios/src/scenarios/basic/orchestration_with_persistency.rs b/feature_integration_tests/rust_test_scenarios/src/scenarios/basic/orchestration_with_persistency.rs index a9a7641a77..17a0e86576 100644 --- a/feature_integration_tests/rust_test_scenarios/src/scenarios/basic/orchestration_with_persistency.rs +++ b/feature_integration_tests/rust_test_scenarios/src/scenarios/basic/orchestration_with_persistency.rs @@ -87,7 +87,7 @@ async fn kvs_save_cycle_number(path: String) -> Result<(), UserErrValue> { // Simple set/get. let key = "run_cycle_number"; - let last_cycle_number: u32 = kvs.get_value_as::(key).unwrap_or_else(|_| 0_u32); + let last_cycle_number: u32 = kvs.get_value_as::(key).unwrap_or(0_u32); kvs.set_value(key, last_cycle_number + 1) .expect("Failed to set value"); From 689cd172df83c1e509be2c0e494839bba7669c81 Mon Sep 17 00:00:00 2001 From: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> Date: Wed, 10 Dec 2025 17:14:52 +0200 Subject: [PATCH 2/2] clippy: code review Commented out kyron based on Frank's comment Addresses: eclipse-score/score#2008 Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 384f7aadd0..c6e60dfcdc 100644 --- a/BUILD +++ b/BUILD @@ -39,7 +39,7 @@ rust_clippy( visibility = ["//visibility:public"], deps = [ "//feature_integration_tests/rust_test_scenarios:rust_test_scenarios", - "//feature_showcase/rust:kyron_example", +# "//feature_showcase/rust:kyron_example", "//feature_showcase/rust:orch_per_example", ], )