diff --git a/.bazelrc b/.bazelrc index 6683d3e..78a37de 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,3 +17,10 @@ build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_x86_64 build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_aarch64 common --extra_toolchains=@gcc_toolchain//:host_gcc_12 + + +# Clippy linting (enabled by default) +build --aspects=@score_rust_policies//clippy:linters.bzl%clippy_strict +build --output_groups=+rules_lint_human +build:lint --@aspect_rules_lint//lint:fail_on_violation=true + diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 0000000..e1390fd --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,29 @@ +# ******************************************************************************* +# 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-targets: "//src/..." + bazel-config: "lint" diff --git a/.github/workflows/lint_fmt_clippy.yml b/.github/workflows/lint_fmt.yml similarity index 90% rename from .github/workflows/lint_fmt_clippy.yml rename to .github/workflows/lint_fmt.yml index b6cea8b..08e1ef0 100644 --- a/.github/workflows/lint_fmt_clippy.yml +++ b/.github/workflows/lint_fmt.yml @@ -51,7 +51,7 @@ jobs: profile: minimal toolchain: 1.87.0 override: true - components: rustfmt, clippy + components: rustfmt - name: check code format (rustfmt) uses: actions-rs/cargo@v1 @@ -63,9 +63,3 @@ jobs: with: command: xtask args: check_lic - - - name: check clippy errors - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --features tracing --all-targets --workspace -- -D warnings diff --git a/MODULE.bazel b/MODULE.bazel index 5b2886b..22f3792 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,8 +20,11 @@ module( bazel_dep(name = "rules_python", version = "1.4.1") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_rust", version = "0.61.0") + +bazel_dep(name = "score_rust_policies", version = "0.0.4", dev_dependency = True) + bazel_dep(name = "rules_cc", version = "0.1.1") -bazel_dep(name = "aspect_rules_lint", version = "1.0.3") +bazel_dep(name = "aspect_rules_lint", version = "2.0.0") bazel_dep(name = "buildifier_prebuilt", version = "7.3.1") bazel_dep(name = "platforms", version = "1.0.0") diff --git a/README.md b/README.md index 48be16f..3d5b0cc 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,13 @@ Build all targets: bazel build //... ``` +## Clippy + +- Clippy runs by default via `.bazelrc` when building Rust targets (rules_lint aspect). +- Use `bazel build //src/...` (or any Rust target pattern) while developing. +- Use `bazel build --config=lint //src/...` to enable lint config, including `--@aspect_rules_lint//lint:fail_on_violation=true`. +- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`. + ## Build for QNX8 ### Preparations