From 89f31655511005b667d680ad6140c56ea209e70f Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:38:35 +0000 Subject: [PATCH] CI: Added clang-format and clang-tidy --- .forgejo/workflows/pr_check.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 2df7053..7d02cb0 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -88,6 +88,21 @@ jobs: ls -la /home/LLVM-19.1.0/bin/ export PATH="/home/LLVM-19.1.0/bin:${PATH}" + - name: Check clang-format + run: | + export PATH="/home/LLVM-19.1.0/bin:${PATH}" + cd ${{ github.workspace }} + find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt + export REPO_FILES=$(cat repo_sources_to_check.txt) + + printf "\nList of files to be checked:\n" + echo "::group::files to be checked" + for FILE in $REPO_FILES; do printf "\t ${{ github.workspace }}/$FILE \n"; done + echo "::endgroup::" + + for FILE in $REPO_FILES; do clang-format -i ${{ github.workspace }}/$FILE --dry-run --Werror; done + echo "No clang-format violations detected!" + - name: Clang build with -fsanitize=address environment: CC: /home/LLVM-19.1.0/bin/clang @@ -111,6 +126,13 @@ jobs: cd ${{ github.workspace }}/build_clang ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests + - name: Check clang-tidy + run: | + export PATH="/home/LLVM-19.1.0/bin:${PATH}" + wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + python run-clang-tidy.py -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/ + echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors" + - name: GCC build environment: CC: /usr/sbin/gcc