diff --git a/.clang-tidy b/.clang-tidy index f194f955b2d..beb41ece247 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,5 @@ Checks: '-*,readability-*,-readability-named-parameter,-readability-avoid-const-params-in-decls,-readability-else-after-return,performance-*,-readability-redundant-access-specifiers,hicpp-*,-hicpp-named-parameter,-hicpp-avoid-c-arrays,cppcoreguidelines-*,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-vararg,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-vararg,concurrency-*,clang-analyzer-*,cert-*,bugprone-*' +WarningsAsErrors: '-*,readability-*,-readability-named-parameter,-readability-avoid-const-params-in-decls,-readability-else-after-return,performance-*,-readability-redundant-access-specifiers,hicpp-*,-hicpp-named-parameter,-hicpp-avoid-c-arrays,cppcoreguidelines-*,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-vararg,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-vararg,concurrency-*,clang-analyzer-*,cert-*,bugprone-*' CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } - { key: readability-identifier-naming.EnumCase, value: CamelCase } diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml new file mode 100644 index 00000000000..ee8d8991343 --- /dev/null +++ b/.github/workflows/tidy.yml @@ -0,0 +1,35 @@ +name: Check with clang-tidy + +on: + push: + branches: [ master ] + pull_request: + branches: [ master, release* ] + +jobs: + clang-tidy: + runs-on: ubuntu-20.04 + + steps: + - name: compiler versions + run: | + echo $(gcc --version) + echo $(clang --version) + + - name: Install iceoryx dependencies and clang-tidy + # Softwares installed in ubuntu-20.04 instance + # https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu2004-README.md + run: sudo apt-get update && sudo apt-get install -y libacl1-dev libncurses5-dev clang-tidy-10 + + - name: Checkout + uses: actions/checkout@v2 + + - name: Build + env: + CC: clang-10 + CXX: clang++-10 + run: | + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh + + - name: Run clang-tidy + run: ./tools/check_clang_tidy.sh diff --git a/tools/check_clang_tidy.sh b/tools/check_clang_tidy.sh new file mode 100755 index 00000000000..09be69166ba --- /dev/null +++ b/tools/check_clang_tidy.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +fail() { + printf "\033[1;31merror: %s: %s\033[0m\n" ${FUNCNAME[1]} "${1:-"Unknown error"}" + exit 1 +} + +hash run-clang-tidy-10.py || fail "run-clang-tidy-10.py not found" +cd $(git rev-parse --show-toplevel) +[ -f build/compile_commands.json ] || fail "build/compile_commands.json not found" +# TODO: only process files change in PR +# https://dev.to/scienta/get-changed-files-in-github-actions-1p36 +FILES=$(git ls-files | grep -E "\.(c|cpp)$" | grep -E -v '/(test|testing)/') +run-clang-tidy-12.py -p build $FILES