Skip to content

Commit

Permalink
GitHub Actions: Run clang-tidy via CMake instead of run-clang-tidy, fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Oct 25, 2024
1 parent f8ce3b3 commit 4f84719
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux
run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux clang-tools-extra
- name: Linting
run: misc/ci.py
- name: Configure with CMake
run: cmake -Bbuild -G"Ninja Multi-Config"
run: cmake -Bbuild -G"Ninja Multi-Config" -DNINJA_CLANG_TIDY=1
- name: Build debug ninja
run: ninja
run: CLICOLOR_FORCE=1 ninja
working-directory: build
- name: Test debug ninja
working-directory: build/Debug
run: |
./ninja_test
./ninja_test --gtest_color=yes
../../misc/output_test.py
- name: Build release ninja
run: ninja -f build-Release.ninja
run: CLICOLOR_FORCE=1 ninja -f build-Release.ninja
working-directory: build
- name: Test release ninja
working-directory: build/Release
run: |
./ninja_test
./ninja_test --gtest_color=yes
../../misc/output_test.py
build:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: Install dependencies
run: |
apt update
apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev
apt install -y python3-pytest ninja-build python3-pip clang libgtest-dev
pip3 install cmake==3.17.*
- name: Configure (GCC)
run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config'
Expand All @@ -129,7 +129,7 @@ jobs:
working-directory: build-gcc/Release

- name: Configure (Clang)
run: CC=clang CXX=clang++ cmake -Bbuild-clang -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' -DCMAKE_EXPORT_COMPILE_COMMANDS=1
run: CC=clang CXX=clang++ cmake -Bbuild-clang -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config'

- name: Build (Clang, Debug)
run: cmake --build build-clang --config Debug
Expand All @@ -147,10 +147,6 @@ jobs:
run: pytest-3 --color=yes ../..
working-directory: build-clang/Release

- name: clang-tidy
run: /usr/lib/llvm-10/share/clang/run-clang-tidy.py -header-filter=src
working-directory: build-clang

build-with-python:
runs-on: [ubuntu-latest]
container:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ if(NINJA_BUILD_BINARY)
if(WIN32)
target_sources(ninja PRIVATE windows/ninja.manifest)
endif()

option(NINJA_CLANG_TIDY "Run clang-tidy on source files" OFF)
if(NINJA_CLANG_TIDY)
set_target_properties(libninja PROPERTIES CXX_CLANG_TIDY "clang-tidy;--use-color")
set_target_properties(ninja PROPERTIES CXX_CLANG_TIDY "clang-tidy;--use-color")
endif()
endif()

# Adds browse mode into the ninja binary if it's supported by the host platform.
Expand Down

0 comments on commit 4f84719

Please sign in to comment.