Skip to content

Commit

Permalink
iox-eclipse-iceoryx#889 Add clang-tidy workflows
Browse files Browse the repository at this point in the history
Build iceoryx and then run clang-tidy on all cpp files exclude tests.
  • Loading branch information
Roman Sokolkov committed Jul 31, 2021
1 parent d5f8841 commit 79dd65b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tools/check_clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 79dd65b

Please sign in to comment.