Skip to content

Commit

Permalink
Clang-tidy off by default if present
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed May 6, 2022
1 parent 623036c commit b2136c4
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: alpine_docker
name: alpine-docker

on:
push:
Expand All @@ -7,7 +7,8 @@ on:
pull_request:

jobs:
alpine_docker_build:
alpine-docker:
name: Docker build based on alpine
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: clang-format check
name: clang-format-check

on:
push:
Expand All @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v4.5.0
uses: jidicula/clang-format-action@v4.6.2
with:
check-path: "src"
fallback-style: "Google"
1 change: 1 addition & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
docker-publish:
name: Publish Docker image to public Docker hub
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macOS
name: MacOS

on:
push:
Expand All @@ -8,6 +8,7 @@ on:

jobs:
xcode:
name: Build on MacOS
runs-on: macos-latest

steps:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/ubuntu-clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Clang-tidy

on:
push:
branches:
- main
pull_request:

jobs:
ubuntu-clang-tidy-build:
name: Build on Ubuntu with clang-tidy checks
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [clang++-13]
buildmode: [Debug]

steps:
- name: Checkout repository code
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt update && sudo apt install libcurl4-gnutls-dev ninja-build
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 13
- name: Install clang-tidy
run: |
sudo apt install clang-tidy-13
sudo ln -s /usr/bin/clang-tidy-13 /usr/bin/clang-tidy
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.buildmode}} -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCCT_ENABLE_CLANG_TIDY=ON -GNinja

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: ninja

- name: Local Tests
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -j 2 -C ${{matrix.buildmode}} --output-on-failure --exclude-regex api_test

- name: Public API Tests # Tries several times to avoid random timeout errors not coming from coincenter
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -j 2 -C ${{matrix.buildmode}} --output-on-failure --tests-regex api_test --repeat until-pass:10
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
pull_request:

jobs:
ci_ubuntu_build:
ubuntu-monitoring-build:
name: Build on Ubuntu with monitoring support
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
pull_request:

jobs:
ci_ubuntu_build:
ubuntu-build:
name: Build on Ubuntu
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,12 +35,6 @@ jobs:
sudo ./llvm.sh 13
if: matrix.compiler == 'clang++-13'

- name: Install clang-tidy
run: |
sudo apt install clang-tidy-13
sudo ln -s /usr/bin/clang-tidy-13 /usr/bin/clang-tidy
if: matrix.compiler == 'clang++-13' && matrix.buildmode == 'Debug'

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
pull_request:

jobs:
ci_windows_build:
windows-build:
name: Build on Windows
runs-on: windows-latest
strategy:
matrix:
Expand Down
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,16 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
endif()

set(CCT_ASAN_BUILD OFF)
set(CCT_TIDY_BUILD OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# In Debug, activate asan by default
set(CCT_ASAN_BUILD ON)
find_program(CLANG_TIDY "clang-tidy")
if (CLANG_TIDY)
# Activate clang tidy
set(CCT_TIDY_BUILD ON)
endif()
endif()

option(CCT_ENABLE_TESTS "Build the unit tests" ${MAIN_PROJECT})
option(CCT_BUILD_EXEC "Build an executable instead of a static library" ${MAIN_PROJECT})
option(CCT_ENABLE_ASAN "Compile with AddressSanitizer" ${CCT_ASAN_BUILD})
option(CCT_ENABLE_CLANG_TIDY "Compile with clang-tidy checks" ${CCT_TIDY_BUILD})
option(CCT_ENABLE_CLANG_TIDY "Compile with clang-tidy checks" OFF)
option(CCT_BUILD_PROMETHEUS_FROM_SRC "Fetch and build from prometheus-cpp sources" OFF)

set(CCT_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data" CACHE PATH "Needed data directory for coincenter")
Expand Down Expand Up @@ -228,7 +223,7 @@ else()
message(STATUS "Activate clang-tidy")
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
else()
message(WARN "clang-tidy executable cannot be found")
message(FATAL_ERROR "clang-tidy executable cannot be found")
endif()
endif()
endif()
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![alpine](https://github.com/sjanel/coincenter/actions/workflows/alpine_docker.yml/badge.svg?branch=master)](https://github.com/sjanel/coincenter/actions/workflows/alpine_docker.yml)
[![macos](https://github.com/sjanel/coincenter/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/sjanel/coincenter/actions/workflows/macos.yml)
[![ubuntu](https://github.com/sjanel/coincenter/actions/workflows/ubuntu.yml/badge.svg?branch=master)](https://github.com/sjanel/coincenter/actions/workflows/ubuntu.yml)
[![windows](https://github.com/sjanel/coincenter/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/sjanel/coincenter/actions/workflows/windows.yml)
[![alpine](https://github.com/sjanel/coincenter/actions/workflows/alpine-docker.yml/badge.svg?branch=main)](https://github.com/sjanel/coincenter/actions/workflows/alpine-docker.yml)
[![macos](https://github.com/sjanel/coincenter/actions/workflows/macos.yml/badge.svg?branch=main)](https://github.com/sjanel/coincenter/actions/workflows/macos.yml)
[![ubuntu](https://github.com/sjanel/coincenter/actions/workflows/ubuntu.yml/badge.svg?branch=main)](https://github.com/sjanel/coincenter/actions/workflows/ubuntu.yml)
[![windows](https://github.com/sjanel/coincenter/actions/workflows/windows.yml/badge.svg?branch=main)](https://github.com/sjanel/coincenter/actions/workflows/windows.yml)

[![formatted](https://github.com/sjanel/coincenter/actions/workflows/clang-format-check.yml/badge.svg?branch=master)](https://github.com/sjanel/coincenter/actions/workflows/clang-format-check.yml)
[![formatted](https://github.com/sjanel/coincenter/actions/workflows/clang-format-check.yml/badge.svg?branch=main)](https://github.com/sjanel/coincenter/actions/workflows/clang-format-check.yml)

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/sjanel/coincenter/master/LICENSE)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/sjanel/coincenter/main/LICENSE)
[![GitHub Releases](https://img.shields.io/github/release/sjanel/coincenter.svg)](https://github.com/sjanel/coincenter/releases)

coincenter
Expand Down

0 comments on commit b2136c4

Please sign in to comment.