Skip to content

Commit 53936fe

Browse files
committed
Add clang-format and clang-tidy to our Github workflow
1 parent 1a2bba1 commit 53936fe

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/clang-format.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: clang-format Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
formatting-check:
7+
name: Formatting Check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install clang-format
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install -y clang-format-18
16+
17+
- name: Run clang-format
18+
run: |
19+
find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format-18 --dry-run --Werror
20+
21+
- name: Formatting check passed
22+
if: success()
23+
run: echo "✓ All files are properly formatted"
24+
25+
- name: Formatting check failed
26+
if: failure()
27+
run: |
28+
echo "✗ Some files need formatting. Run 'clang-format -i <files>' to fix."
29+
echo "Or run: find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format -i"
30+
exit 1

.github/workflows/clang-tidy.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: clang-tidy Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
clang-tidy:
7+
name: clang-tidy Check
8+
runs-on: ubuntu-24.04
9+
env:
10+
CC: clang-18
11+
CXX: clang++-18
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install clang-tidy and dependencies
17+
run: |
18+
sudo apt-get update
19+
sudo apt-get install -y clang-tidy-18 libc++-18-dev libc++abi-18-dev ninja-build
20+
21+
- name: Install vcpkg
22+
run: |
23+
git clone https://github.com/microsoft/vcpkg.git ${GITHUB_WORKSPACE}/vcpkg
24+
cd ${GITHUB_WORKSPACE}/vcpkg
25+
./bootstrap-vcpkg.sh
26+
export CXXFLAGS="-stdlib=libc++"
27+
export LDFLAGS="-stdlib=libc++ -lc++abi"
28+
./vcpkg install uni-algo nlohmann-json
29+
30+
- name: Configure CMake
31+
run: |
32+
cmake \
33+
-B build \
34+
-G Ninja \
35+
-DCMAKE_CXX_STANDARD=23 \
36+
-DCMAKE_BUILD_TYPE=Debug \
37+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
38+
-Dskyr_BUILD_TESTS=OFF \
39+
-Dskyr_BUILD_DOCS=OFF \
40+
-Dskyr_BUILD_EXAMPLES=OFF \
41+
-Dskyr_BUILD_WITH_LLVM_LIBCXX=ON \
42+
-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake
43+
44+
- name: Run clang-tidy on headers
45+
run: |
46+
find include -name '*.hpp' -print0 | \
47+
xargs -0 -n1 -P$(nproc) clang-tidy-18 -p build --warnings-as-errors='*'
48+
49+
- name: Run clang-tidy on tests
50+
run: |
51+
find tests -name '*.cpp' -print0 | \
52+
xargs -0 -n1 -P$(nproc) clang-tidy-18 -p build --warnings-as-errors='*'
53+
54+
- name: clang-tidy check passed
55+
if: success()
56+
run: echo "✓ clang-tidy found no issues"
57+
58+
- name: clang-tidy check failed
59+
if: failure()
60+
run: |
61+
echo "✗ clang-tidy found issues. Review the output above for details."
62+
exit 1

0 commit comments

Comments
 (0)