Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,20 @@ jobs:

- name: Run Makefile build
run: make -j radostrace osdtrace

clang-tidy:
runs-on: ubuntu-24.04
steps:
- name: Checkout code and submodules
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y g++ clang clang-tidy libelf-dev libc6-dev-i386 libdw-dev

- name: Run clang-tidy
run: make -j clang-tidy
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ else
endif

# Main targets
.PHONY: all clean
.PHONY: all clean clang-tidy
all: $(OSDTRACE_SRC)/ceph_btf_local.h $(EMBEDDED_DWARF_HDR) $(PROG_OBJS)

install:
Expand Down Expand Up @@ -116,6 +116,21 @@ clean:
$(call msg,CLEAN)
$(Q)rm -rf $(OUTPUT) $(PROG_OBJS) $(DOCDIR)/*.8.gz $(DOCDIR)/*.in $(OSDTRACE_SRC)/ceph_btf_local.h $(EMBEDDED_DWARF_HDR)

# clang-tidy static analysis (requires skeleton headers in .output/)
CLANG_TIDY ?= clang-tidy
TIDY_SRCS := $(OSDTRACE_SRC)/osdtrace.cc \
$(OSDTRACE_SRC)/radostrace.cc \
$(OSDTRACE_SRC)/kfstrace.cc \
$(OSDTRACE_SRC)/dwarf_parser.cc \
$(OSDTRACE_SRC)/version_utils.cc

clang-tidy: $(OUTPUT)/osdtrace.skel.h $(OUTPUT)/radostrace.skel.h $(OUTPUT)/kfstrace.skel.h $(EMBEDDED_DWARF_HDR)
$(call msg,TIDY)
$(Q)for src in $(TIDY_SRCS); do \
printf ' %-8s %s\n' "TIDY" "$$src"; \
$(CLANG_TIDY) $$src -- $(CXXFLAGS) $(VERSION_DEFINES) || exit 1; \
done

$(OUTPUT) $(OUTPUT)/libbpf $(BPFTOOL_OUTPUT):
$(call msg,MKDIR,$@)
$(Q)mkdir -p $@
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = lint, pylint, pep8, test
envlist = lint, pylint, pep8, test, clang-tidy


[vars]
Expand Down Expand Up @@ -31,3 +31,10 @@ deps =
commands =
pytest --fixtures tests/
pytest tests/ -v

[testenv:clang-tidy]
description = run clang-tidy static analysis on C++ sources
skip_install = true
allowlist_externals = make
commands =
make clang-tidy
Loading