Skip to content

Commit b9b4a35

Browse files
See if CI matches local
1 parent 6560b8b commit b9b4a35

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ WarningsAsErrors: >
2929
bugprone-string-literal-with-embedded-nul,
3030
bugprone-suspicious-memset-usage,
3131
32-
HeaderFilterRegex: '(include/livekit|src|examples)'
32+
HeaderFilterRegex: '.*/(include/livekit|src)/.*\.(h|hpp)$'
33+
ExcludeHeaderFilterRegex: '(.*/src/tests/.*)|(.*/_deps/.*)|(.*/build-[^/]*/.*)'
3334

3435
FormatStyle: file
3536

.github/workflows/builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ jobs:
601601
files-changed-only: false
602602
lines-changed-only: false
603603
extensions: 'c,cpp,cc,cxx'
604-
# ignore:
604+
ignore: 'build-*|cpp-example-collection|client-sdk-rust|vcpkg_installed|src/tests|bridge|examples|docker|data|docs'
605605
file-annotations: true
606606
thread-comments: update
607607
step-summary: true

tidy.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
#
3+
# tidy.sh -- Run clang-tidy locally using the same file set and config as CI.
4+
#
5+
# Matches the file filter used by the cpp-linter GitHub Action in
6+
# .github/workflows/builds.yml: only src/**/*.{c,cpp,cc,cxx} excluding
7+
# src/tests/. Picks up checks from the repo-root .clang-tidy automatically.
8+
#
9+
# Usage:
10+
# ./tidy.sh # run on full src/ tree
11+
# ./tidy.sh -j 4 # override parallelism
12+
# ./tidy.sh -fix # auto-apply fixes (forwarded to run-clang-tidy)
13+
#
14+
# Requires CMake to have generated build-release/compile_commands.json.
15+
# Run once: cmake --preset macos-release (or linux-release)
16+
17+
set -euo pipefail
18+
19+
BUILD_DIR="build-release"
20+
# Positive match for top-level src/*.{c,cpp,cc,cxx}; negative lookahead excludes
21+
# dep paths (_deps/, build-*/, -src/src/) and other top-level dirs that CI's
22+
# cpp-linter `ignore:` list filters out. Python regex (PCRE-ish) supports
23+
# lookahead; this regex is evaluated by run-clang-tidy.
24+
FILE_REGEX='^(?!.*/(_deps|build-[^/]*|bridge|examples|client-sdk-rust|cpp-example-collection|vcpkg_installed|docker|docs|data)/).*/src/(?!tests/).*\.(c|cpp|cc|cxx)$'
25+
26+
if [[ ! -f "${BUILD_DIR}/compile_commands.json" ]]; then
27+
echo "ERROR: ${BUILD_DIR}/compile_commands.json not found." >&2
28+
echo "Run: cmake --preset macos-release (or linux-release)" >&2
29+
exit 1
30+
fi
31+
32+
if ! command -v run-clang-tidy >/dev/null 2>&1; then
33+
echo "ERROR: run-clang-tidy not found in PATH." >&2
34+
echo "Install LLVM: brew install llvm (macOS)" >&2
35+
echo " apt install clang-tidy (Linux)" >&2
36+
exit 1
37+
fi
38+
39+
extra_args=()
40+
if [[ "$(uname)" == "Darwin" ]]; then
41+
sdk_path="$(xcrun --show-sdk-path 2>/dev/null || true)"
42+
if [[ -n "${sdk_path}" ]]; then
43+
extra_args+=(-extra-arg="-isysroot${sdk_path}")
44+
fi
45+
fi
46+
47+
if command -v nproc >/dev/null 2>&1; then
48+
jobs=$(nproc)
49+
else
50+
jobs=$(sysctl -n hw.ncpu 2>/dev/null || echo 4)
51+
fi
52+
53+
run-clang-tidy \
54+
-p "${BUILD_DIR}" \
55+
-quiet \
56+
-j "${jobs}" \
57+
"${extra_args[@]}" \
58+
"$@" \
59+
"${FILE_REGEX}"

0 commit comments

Comments
 (0)