Skip to content

Commit 11357b9

Browse files
committed
Adopt clang-tidy support from @score_cpp_policies
1 parent 2833f5d commit 11357b9

7 files changed

Lines changed: 131 additions & 0 deletions

File tree

.bazelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ coverage --combined_report=lcov
8282
coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu
8383
coverage --features=coverage
8484
coverage --cache_test_results=no
85+
86+
# Clang-tidy: bazel test --config=clang-tidy //...
87+
test:clang-tidy --aspects=//tools/lint:linters.bzl%clang_tidy_aspect
88+
test:clang-tidy --output_groups=+rules_lint_report
89+
test:clang-tidy --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux
90+
test:clang-tidy --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu

.clang-tidy

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
---
15+
# Clang-tidy configuration for score_logging.
16+
# NOTE: check set subject to be tailored as compliance increases.
17+
Checks: >
18+
-*,
19+
clang-analyzer-*,
20+
cert-*,
21+
cppcoreguidelines-*,
22+
bugprone-*,
23+
misc-*,
24+
performance-*,
25+
readability-*,
26+
modernize-*
27+
28+
WarningsAsErrors: >
29+
clang-analyzer-*,
30+
31+
# Exclude third-party and external dependencies' headers from analysis.
32+
HeaderFilterRegex: '^(?!.*/third_party/).*'
33+
34+
FormatStyle: file

.github/workflows/clang_tidy.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
name: Clang-Tidy
15+
16+
on:
17+
pull_request:
18+
types: [opened, reopened, synchronize]
19+
merge_group:
20+
21+
jobs:
22+
clang-tidy:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Setup Bazel
27+
uses: bazel-contrib/setup-bazel@0.15.0
28+
with:
29+
bazelisk-version: 1.26.0
30+
- name: Run clang-tidy
31+
run: |
32+
cd logging
33+
bazel test --config=clang-tidy --lockfile_mode=error //score/...

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use_format_targets()
4242

4343
exports_files([
4444
"MODULE.bazel",
45+
".clang-tidy",
4546
])
4647

4748
# Creates all documentation targets:

MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1")
2222
bazel_dep(name = "rules_rust", version = "0.61.0")
2323
bazel_dep(name = "rules_cc", version = "0.1.1")
2424
bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
25+
bazel_dep(name = "score_cpp_policies", version = "0.0.0", dev_dependency = True)
26+
git_override(
27+
module_name = "score_cpp_policies",
28+
commit = "87b5b33dea15ff2e2dde1b0aae9cb982f49bc277",
29+
remote = "https://github.com/RSingh1511/score_cpp_policies.git",
30+
)
31+
bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)
2532
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
2633
bazel_dep(name = "platforms", version = "1.0.0")
2734

@@ -80,6 +87,16 @@ use_repo(
8087
"score_qcc_x86_64_toolchain",
8188
)
8289

90+
llvm = use_extension(
91+
"@toolchains_llvm//toolchain/extensions:llvm.bzl",
92+
"llvm",
93+
dev_dependency = True,
94+
)
95+
llvm.toolchain(
96+
llvm_version = "19.1.7",
97+
)
98+
use_repo(llvm, "llvm_toolchain")
99+
83100
PYTHON_VERSION = "3.12"
84101

85102
python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)

tools/lint/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
exports_files(
15+
["linters.bzl"],
16+
visibility = ["//visibility:public"],
17+
)

tools/lint/linters.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
"""Clang-tidy linter configuration for score_logging."""
15+
16+
load("@score_cpp_policies//clang_tidy:defs.bzl", "make_clang_tidy_aspect", "make_clang_tidy_test")
17+
18+
clang_tidy_aspect = make_clang_tidy_aspect(
19+
binary = Label("@llvm_toolchain//:clang-tidy"),
20+
configs = [Label("//:.clang-tidy")],
21+
)
22+
23+
clang_tidy_test = make_clang_tidy_test(aspect = clang_tidy_aspect)

0 commit comments

Comments
 (0)