From 48bb0133c2c3374aa72349082b03086475e5825b Mon Sep 17 00:00:00 2001 From: subramaniak Date: Thu, 10 Sep 2026 03:10:18 +0000 Subject: [PATCH 1/5] ci: add clang-tidy and cargo clippy checks --- .bazelrc | 7 ++++++ .github/workflows/build_scenarios.yml | 31 +++++++++++++++++++++++++++ MODULE.bazel | 16 +++++++++++++- score/test_scenarios_cpp/BUILD | 11 ++++++++++ tools/lint/BUILD.bazel | 17 +++++++++++++++ tools/lint/linters.bzl | 22 +++++++++++++++++++ 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 tools/lint/BUILD.bazel create mode 100644 tools/lint/linters.bzl diff --git a/.bazelrc b/.bazelrc index 46ba4c9..5abd333 100644 --- a/.bazelrc +++ b/.bazelrc @@ -57,3 +57,10 @@ build:arm64-qnx --config=_common build:arm64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix build:arm64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0 build:arm64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_aarch64_unknown_nto_qnx800 + +# ------------------------------------------------------------------------------- +# Clang-tidy (score_cpp_policies) +# ------------------------------------------------------------------------------- +test:clang-tidy --aspects=//tools/lint:linters.bzl%clang_tidy_aspect +test:clang-tidy --output_groups=+rules_lint_report +test:clang-tidy --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux diff --git a/.github/workflows/build_scenarios.yml b/.github/workflows/build_scenarios.yml index c9364cd..c391942 100644 --- a/.github/workflows/build_scenarios.yml +++ b/.github/workflows/build_scenarios.yml @@ -35,3 +35,34 @@ jobs: - name: Run tests run: | bazel test //... --config=x86_64-linux + + clang-tidy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.15.0 + with: + bazelisk-version: 1.26.0 # newest LTS before 1 Jun 2025 + + - name: Run clang-tidy + run: | + bazel test --config=clang-tidy //score/test_scenarios_cpp:clang_tidy + + clippy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@1.87.0 + with: + components: clippy + + - name: Run clippy + working-directory: score/test_scenarios_rust + run: | + cargo clippy --locked --all-targets -- -D warnings diff --git a/MODULE.bazel b/MODULE.bazel index 778be38..0743077 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,7 +20,7 @@ module( bazel_dep(name = "rules_python", version = "1.4.1") bazel_dep(name = "bazel_skylib", version = "1.7.1") 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.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "7.3.1") bazel_dep(name = "platforms", version = "1.0.0") @@ -35,6 +35,10 @@ bazel_dep(name = "rules_rust", version = "0.68.1-score") bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.5.1", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.8.0", dev_dependency = True) +# Clang-tidy (score_cpp_policies wires up aspect_rules_lint with the S-CORE baseline config). +bazel_dep(name = "score_cpp_policies", version = "0.1.1", dev_dependency = True) +bazel_dep(name = "toolchains_llvm", version = "1.8.0", dev_dependency = True) + # Others gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", dev_dependency = True) gcc.toolchain( @@ -75,6 +79,16 @@ use_repo( "score_qcc_x86_64_toolchain", ) +llvm = use_extension( + "@toolchains_llvm//toolchain/extensions:llvm.bzl", + "llvm", + dev_dependency = True, +) +llvm.toolchain( + llvm_version = "19.1.7", +) +use_repo(llvm, "llvm_toolchain") + PYTHON_VERSION = "3.12" python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) diff --git a/score/test_scenarios_cpp/BUILD b/score/test_scenarios_cpp/BUILD index 3461231..e9346cd 100644 --- a/score/test_scenarios_cpp/BUILD +++ b/score/test_scenarios_cpp/BUILD @@ -12,6 +12,7 @@ # ******************************************************************************* load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_cc//cc:cc_test.bzl", "cc_test") +load("//tools/lint:linters.bzl", "clang_tidy_test") cc_library( name = "test_scenarios_cpp", @@ -52,3 +53,13 @@ cc_test( "@googletest//:gtest_main", ], ) + +clang_tidy_test( + name = "clang_tidy", + # :tests (cc_test) isn't covered by the aspect's default rule_kinds. + srcs = [ + ":test_scenarios_cpp", + ], + # manual: needs the llvm toolchain, which --config=clang-tidy registers. + tags = ["manual"], +) diff --git a/tools/lint/BUILD.bazel b/tools/lint/BUILD.bazel new file mode 100644 index 0000000..206c4e4 --- /dev/null +++ b/tools/lint/BUILD.bazel @@ -0,0 +1,17 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +exports_files( + ["linters.bzl"], + visibility = ["//visibility:public"], +) diff --git a/tools/lint/linters.bzl b/tools/lint/linters.bzl new file mode 100644 index 0000000..595912b --- /dev/null +++ b/tools/lint/linters.bzl @@ -0,0 +1,22 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +"""Clang-tidy aspect and test rule, using the score_cpp_policies baseline.""" + +load("@score_cpp_policies//clang_tidy:defs.bzl", "make_clang_tidy_aspect", "make_clang_tidy_test") + +clang_tidy_aspect = make_clang_tidy_aspect( + binary = Label("@llvm_toolchain//:clang-tidy"), +) + +clang_tidy_test = make_clang_tidy_test(aspect = clang_tidy_aspect) From 1c58364b2f92e22e57609115226fd178d9e441ed Mon Sep 17 00:00:00 2001 From: subramaniak Date: Fri, 11 Sep 2026 08:04:42 +0000 Subject: [PATCH 2/5] ci: bump clippy toolchain pin to 1.92.0 --- .github/workflows/build_scenarios.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_scenarios.yml b/.github/workflows/build_scenarios.yml index c391942..e7d35c7 100644 --- a/.github/workflows/build_scenarios.yml +++ b/.github/workflows/build_scenarios.yml @@ -58,7 +58,7 @@ jobs: uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@1.87.0 + uses: dtolnay/rust-toolchain@1.92.0 with: components: clippy From 245621773fd3c183111d0b544ac911a008045205 Mon Sep 17 00:00:00 2001 From: subramaniak Date: Tue, 15 Sep 2026 10:34:08 +0000 Subject: [PATCH 3/5] ci: add root .clang-tidy, bump llvm_version to 22.1.7 --- .clang-tidy | 33 +++++++++++++++++++++++++++++++++ BUILD | 2 ++ MODULE.bazel | 14 ++++++++++---- tools/lint/linters.bzl | 1 + 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..b0ba677 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,33 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* +# Local copy of the @score_cpp_policies//clang_tidy baseline. clang-tidy only +# discovers a .clang-tidy by walking up from the file it's linting, so a config +# living inside an external repo (score_cpp_policies) is never found -- this +# file has to live at our own root for the baseline checks to actually run. +Checks: >- + -*, + clang-analyzer-*, + cert-*, + cppcoreguidelines-*, + bugprone-*, + misc-*, + performance-*, + readability-*, + modernize-* + +WarningsAsErrors: >- + clang-analyzer-* + +HeaderFilterRegex: 'score/' + +FormatStyle: none diff --git a/BUILD b/BUILD index a6bda84..c1d49eb 100644 --- a/BUILD +++ b/BUILD @@ -13,6 +13,8 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements") load("@score_tooling//:defs.bzl", "setup_starpls") +exports_files([".clang-tidy"]) + setup_starpls( name = "starpls_server", visibility = ["//visibility:public"], diff --git a/MODULE.bazel b/MODULE.bazel index 0743077..9d9928b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -32,7 +32,7 @@ bazel_dep(name = "score_rust_policies", version = "0.0.5") # Toolchains and extensions bazel_dep(name = "rules_rust", version = "0.68.1-score") -bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.5.1", dev_dependency = True) +bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.5.4", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.8.0", dev_dependency = True) # Clang-tidy (score_cpp_policies wires up aspect_rules_lint with the S-CORE baseline config). @@ -57,7 +57,7 @@ gcc.toolchain( ) gcc.toolchain( name = "score_qcc_x86_64_toolchain", - sdp_version = "8.0.0", + sdp_version = "8.0.4", target_cpu = "x86_64", target_os = "qnx", use_default_package = True, @@ -65,7 +65,7 @@ gcc.toolchain( ) gcc.toolchain( name = "score_qcc_aarch64_toolchain", - sdp_version = "8.0.0", + sdp_version = "8.0.4", target_cpu = "aarch64", target_os = "qnx", use_default_package = True, @@ -85,7 +85,13 @@ llvm = use_extension( dev_dependency = True, ) llvm.toolchain( - llvm_version = "19.1.7", + cxx_standard = {"": "c++17"}, + link_libs = {"": [ + "-lrt", + "-latomic", + ]}, + llvm_version = "22.1.7", + stdlib = {"": "stdc++"}, ) use_repo(llvm, "llvm_toolchain") diff --git a/tools/lint/linters.bzl b/tools/lint/linters.bzl index 595912b..f5a9ddc 100644 --- a/tools/lint/linters.bzl +++ b/tools/lint/linters.bzl @@ -17,6 +17,7 @@ load("@score_cpp_policies//clang_tidy:defs.bzl", "make_clang_tidy_aspect", "make clang_tidy_aspect = make_clang_tidy_aspect( binary = Label("@llvm_toolchain//:clang-tidy"), + local_configs = [Label("//:.clang-tidy")], ) clang_tidy_test = make_clang_tidy_test(aspect = clang_tidy_aspect) From ab16953d3d219ac8f9338ccf185ae38516d4a533 Mon Sep 17 00:00:00 2001 From: subramaniak Date: Tue, 15 Sep 2026 10:46:23 +0000 Subject: [PATCH 4/5] chore: update comments --- .clang-tidy | 4 ---- .github/workflows/build_scenarios.yml | 2 +- MODULE.bazel | 1 - score/test_scenarios_cpp/BUILD | 2 -- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index b0ba677..01fef13 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,10 +10,6 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -# Local copy of the @score_cpp_policies//clang_tidy baseline. clang-tidy only -# discovers a .clang-tidy by walking up from the file it's linting, so a config -# living inside an external repo (score_cpp_policies) is never found -- this -# file has to live at our own root for the baseline checks to actually run. Checks: >- -*, clang-analyzer-*, diff --git a/.github/workflows/build_scenarios.yml b/.github/workflows/build_scenarios.yml index e7d35c7..e2717d1 100644 --- a/.github/workflows/build_scenarios.yml +++ b/.github/workflows/build_scenarios.yml @@ -45,7 +45,7 @@ jobs: - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.15.0 with: - bazelisk-version: 1.26.0 # newest LTS before 1 Jun 2025 + bazelisk-version: 1.26.0 - name: Run clang-tidy run: | diff --git a/MODULE.bazel b/MODULE.bazel index 9d9928b..2406d14 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -35,7 +35,6 @@ bazel_dep(name = "rules_rust", version = "0.68.1-score") bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.5.4", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.8.0", dev_dependency = True) -# Clang-tidy (score_cpp_policies wires up aspect_rules_lint with the S-CORE baseline config). bazel_dep(name = "score_cpp_policies", version = "0.1.1", dev_dependency = True) bazel_dep(name = "toolchains_llvm", version = "1.8.0", dev_dependency = True) diff --git a/score/test_scenarios_cpp/BUILD b/score/test_scenarios_cpp/BUILD index e9346cd..983eaf9 100644 --- a/score/test_scenarios_cpp/BUILD +++ b/score/test_scenarios_cpp/BUILD @@ -56,10 +56,8 @@ cc_test( clang_tidy_test( name = "clang_tidy", - # :tests (cc_test) isn't covered by the aspect's default rule_kinds. srcs = [ ":test_scenarios_cpp", ], - # manual: needs the llvm toolchain, which --config=clang-tidy registers. tags = ["manual"], ) From 6c703cbfbb98836b495abb4389a88dda5a426cde Mon Sep 17 00:00:00 2001 From: subramaniak Date: Wed, 16 Sep 2026 07:41:38 +0000 Subject: [PATCH 5/5] fix: narrow HeaderFilterRegex to score/test_scenarios_cpp/ --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 01fef13..810810d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -24,6 +24,6 @@ Checks: >- WarningsAsErrors: >- clang-analyzer-* -HeaderFilterRegex: 'score/' +HeaderFilterRegex: 'score/test_scenarios_cpp/' FormatStyle: none