Skip to content

Commit

Permalink
GH Actions: Enable local and remote clang-tidy scan on Linux (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrhanKupusoglu authored May 9, 2022
1 parent b5a1e83 commit a642000
Show file tree
Hide file tree
Showing 8 changed files with 837 additions and 7 deletions.
48 changes: 42 additions & 6 deletions .github/workflows/build-ubuntu-20.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build Ubuntu 20.04

on:
on:
push:
pull_request:
branches:
Expand All @@ -16,7 +16,7 @@ jobs:
sudo apt update
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qt5-default libqwt-qt5-dev
- name: Install Capn Proto
- name: Install Cap'n Proto
run: |
mkdir "${{ runner.workspace }}/capnp"
cd "${{ runner.workspace }}/capnp"
Expand All @@ -28,11 +28,11 @@ jobs:
sudo make install
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 0

- name: Install Python requirements
shell: bash
run: |
Expand All @@ -45,6 +45,7 @@ jobs:
mkdir "${{ runner.workspace }}/_build"
cd "${{ runner.workspace }}/_build"
cmake $GITHUB_WORKSPACE -G "Ninja" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DHAS_HDF5=ON \
-DHAS_QT5=ON \
-DHAS_CURL=ON \
Expand Down Expand Up @@ -99,13 +100,48 @@ jobs:
working-directory: ${{ runner.workspace }}/_build

- name: Upload Debian
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ubuntu-debian
path: ${{ runner.workspace }}/_build/_deploy/*.deb

- name: Upload Python Wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ubuntu-python-wheel
path: ${{ runner.workspace }}/_build/_deploy/*.whl

#---------------------------------------------------------------------------

# GNU tar - Excluding Some Files
# https://www.gnu.org/software/tar/manual/html_node/exclude.html
# the emtpy '.git/' drectory is required, it marks the root directory
- name: 'Create a tarball'
run: |
cd ${{ runner.workspace }}
tar --exclude-vcs-ignore \
--exclude='bin' \
--exclude='doc' \
--exclude='_build/_CPack_Packages' \
--exclude='_build/_deploy' \
--exclude='_build/lib' \
--exclude='_build/python' \
--exclude='*.deb' \
--exclude='*.a' \
--exclude='*.o' \
--exclude='*.so' \
--exclude=ecal/.git/* \
-czf ecal.tar.gz ecal/ _build/
du -sh ecal.tar.gz
# https://github.com/actions/upload-artifact
- name: Upload the whole directory
uses: actions/upload-artifact@v3
with:
name: ecal-dir
path: ${{ runner.workspace }}/ecal.tar.gz

call-clang-tidy:
needs: build-ubuntu
uses: ./.github/workflows/run-clang-tidy.yml
72 changes: 72 additions & 0 deletions .github/workflows/run-clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Run clang-tidy

on:
workflow_call:

jobs:
clang-tidy-scan:
runs-on: ubuntu-20.04
continue-on-error: true

steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qt5-default
sudo apt-get install clang-tidy
- name: Display version info
run: |
echo $(g++ --version)
echo $(clang --version)
echo $(cmake --version)
echo $(clang-tidy --version)
# https://github.com/actions/download-artifact
- name: Download the built directory
uses: actions/download-artifact@v3
with:
name: ecal-dir

# replace the working directory
- name: Extract the tarball archive
run: mv ecal.tar.gz ../. && cd .. && rm -rf ecal && tar -xzf ecal.tar.gz && cd ecal

# https://github.com/Ana06/get-changed-files
- name: Detect the changeset
id: changed_files
uses: Ana06/get-changed-files@v2.1.0

# see: ./build.sh --help
- name: Run clang-tidy on the changeset
id: suffix
run: |
build_linux/clang-tidy/build.sh -a -b ../../../_build -f ${{ steps.changed_files.outputs.added_modified }}
# https://github.com/actions/upload-artifact
# If make or clang-tidy is never called, artifact upload will fail (no log files) with just a warning.
- name: Archive logs as artifact
uses: actions/upload-artifact@v3
with:
name: clang_tidy_log_${{ steps.suffix.outputs.timestamp }}
path: ~/work/ecal/_build/clang_tidy_log_*.txt
if-no-files-found: warn

- name: Detect number of clang-tidy warnings
id: num_warnings
run: |
NUM_WARNINGS=0
NUM_LOG_FILES=$(ls ~/work/ecal/_build/clang_tidy_log_*.txt 2> /dev/null | wc -l)
if [[ ${NUM_LOG_FILES} -gt 0 ]]
then
NUM_WARNINGS=$(grep -oE "\w+\.\w+:\w+:\w+:\s?warning:\s?.*" -- ~/work/ecal/_build/clang_tidy_log_*.txt | wc -l)
fi
echo "::set-output name=value::${NUM_WARNINGS}"
# https://github.com/actions/github-script
- name: Check clang-tidy warnings
if: ${{ steps.num_warnings.outputs.value > 0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('number of clang-tidy warnings: ${{ steps.num_warnings.outputs.value}}')
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ doc/extensions/_autogen
.idea
cmake-build-*

# clang-tidy
/.clang-tidy
log_*.txt
45 changes: 44 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ include(build_location)
# find_project(eCAL calls shall be ignored, eCAL is build as part of the project)
set(as_subproject eCAL)

if(CMAKE_EXPORT_COMPILE_COMMANDS)
message(STATUS "Compilation database will be created")
else()
# to make it visible it is explicitly set to OFF
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
endif()

# Normalize backslashes from Windows paths
file(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH)
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
Expand Down Expand Up @@ -188,7 +195,7 @@ set(possible_subprojects
qwt
)

# We should rename the option, but don't know how to do in in a
# We should rename the option, but don't know how to do in in a
# backwards compatible way
set(ECAL_THIRDPARTY_BUILD_CMAKEFUNCTIONS ${ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS})

Expand Down Expand Up @@ -510,3 +517,39 @@ endif()
# create package
# --------------------------------------------------------
include(cpack/cpack_variables.cmake)

message(STATUS "Build Options:")
message(STATUS "--------------------------------------------------------------------------------")
message(STATUS "CMAKE_EXPORT_COMPILE_COMMANDS : ${CMAKE_EXPORT_COMPILE_COMMANDS}")
message(STATUS "HAS_HDF5 : ${HAS_HDF5}")
message(STATUS "HAS_QT5 : ${HAS_QT5}")
message(STATUS "HAS_CURL : ${HAS_CURL}")
message(STATUS "HAS_CAPNPROTO : ${HAS_CAPNPROTO}")
message(STATUS "BUILD_DOCS : ${BUILD_DOCS}")
message(STATUS "BUILD_APPS : ${BUILD_APPS}")
message(STATUS "BUILD_SAMPLES : ${BUILD_SAMPLES}")
message(STATUS "BUILD_TIME : ${BUILD_TIME}")
message(STATUS "BUILD_PY_BINDING : ${BUILD_PY_BINDING}")
message(STATUS "BUILD_STANDALONE_PY_WHEEL : ${BUILD_STANDALONE_PY_WHEEL}")
message(STATUS "BUILD_CSHARP_BINDING : ${BUILD_CSHARP_BINDING}")
message(STATUS "BUILD_ECAL_TESTS : ${BUILD_ECAL_TESTS}")
message(STATUS "ECAL_LAYER_ICEORYX : ${ECAL_LAYER_ICEORYX}")
message(STATUS "ECAL_INCLUDE_PY_SAMPLES : ${ECAL_INCLUDE_PY_SAMPLES}")
message(STATUS "ECAL_INSTALL_SAMPLE_SOURCES : ${ECAL_INSTALL_SAMPLE_SOURCES}")
message(STATUS "ECAL_JOIN_MULTICAST_TWICE : ${ECAL_JOIN_MULTICAST_TWICE}")
message(STATUS "ECAL_NPCAP_SUPPORT : ${ECAL_NPCAP_SUPPORT}")
message(STATUS "ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS : ${ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS}")
message(STATUS "ECAL_THIRDPARTY_BUILD_SPDLOG : ${ECAL_THIRDPARTY_BUILD_SPDLOG}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TINYXML2 : ${ECAL_THIRDPARTY_BUILD_TINYXML2}")
message(STATUS "ECAL_THIRDPARTY_BUILD_FINEFTP : ${ECAL_THIRDPARTY_BUILD_FINEFTP}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TERMCOLOR : ${ECAL_THIRDPARTY_BUILD_TERMCOLOR}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TCP_PUBSUB : ${ECAL_THIRDPARTY_BUILD_TCP_PUBSUB}")
message(STATUS "ECAL_THIRDPARTY_BUILD_RECYCLE : ${ECAL_THIRDPARTY_BUILD_RECYCLE}")
message(STATUS "ECAL_THIRDPARTY_BUILD_GTEST : ${ECAL_THIRDPARTY_BUILD_GTEST}")
message(STATUS "ECAL_THIRDPARTY_BUILD_PROTOBUF : ${ECAL_THIRDPARTY_BUILD_PROTOBUF}")
message(STATUS "ECAL_THIRDPARTY_BUILD_CURL : ${ECAL_THIRDPARTY_BUILD_CURL}")
message(STATUS "ECAL_THIRDPARTY_BUILD_HDF5 : ${ECAL_THIRDPARTY_BUILD_HDF5}")
message(STATUS "ECAL_LINK_HDF5_SHARED : ${ECAL_LINK_HDF5_SHARED}")
message(STATUS "CPACK_PACK_WITH_INNOSETUP : ${CPACK_PACK_WITH_INNOSETUP}")

message(STATUS "--------------------------------------------------------------------------------")
19 changes: 19 additions & 0 deletions build_linux/clang-tidy/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
Checks: "*,
-abseil-*,
-altera-*,
-android-*,
-fuchsia-*,
-google-*,
-llvm*,
-modernize-use-trailing-return-type,
-zircon-*,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-cppcoreguidelines-non-private-member-variables-in-classes,
-misc-non-private-member-variables-in-classes,
"
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
Loading

0 comments on commit a642000

Please sign in to comment.