From 5c03458ba2d1ba70b56be70ae685103b8adb91f3 Mon Sep 17 00:00:00 2001 From: silverqx Date: Sun, 10 Jul 2022 18:54:15 +0200 Subject: [PATCH] workflows added clang-tidy and clazy qt6 analyzers --- .../{analyzers.yml => analyzers-qt5.yml} | 2 +- .github/workflows/analyzers-qt6.yml | 134 ++++++++++++++++++ README.md | 9 +- 3 files changed, 141 insertions(+), 4 deletions(-) rename .github/workflows/{analyzers.yml => analyzers-qt5.yml} (99%) create mode 100644 .github/workflows/analyzers-qt6.yml diff --git a/.github/workflows/analyzers.yml b/.github/workflows/analyzers-qt5.yml similarity index 99% rename from .github/workflows/analyzers.yml rename to .github/workflows/analyzers-qt5.yml index 99012addb..c934af77d 100644 --- a/.github/workflows/analyzers.yml +++ b/.github/workflows/analyzers-qt5.yml @@ -1,4 +1,4 @@ -name: Clang Tidy/Clazy +name: Clang Tidy/Clazy Qt5.15 on: pull_request: diff --git a/.github/workflows/analyzers-qt6.yml b/.github/workflows/analyzers-qt6.yml new file mode 100644 index 000000000..e06f32972 --- /dev/null +++ b/.github/workflows/analyzers-qt6.yml @@ -0,0 +1,134 @@ +name: Clang Tidy/Clazy Qt6.2 + +on: + pull_request: + push: + branches: + - main + - gh-actions + +jobs: + + clang-analyzers: + name: clang-tidy and clazy + + runs-on: ubuntu-22.04 + + env: + TINY_CLANG_TIDY_EXECUTED: false + + steps: + - uses: actions/checkout@v3 + + - name: add-apt-repository Clang 14 + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main" + + - name: apt update + run: | + sudo apt update + + - name: apt install clang-14, lld, g++-12, clang-tidy-14, Qt 6.2.4 base, and ccache + run: >- + sudo apt install -y clang-14 lld g++-12 clang-tidy-14 ccache + qt6-base-dev libqt6sql6-mysql libqt6sql6-sqlite libqt6sql6-psql + + - name: ninja install latest version + uses: seanmiddleditch/gha-setup-ninja@master + with: + destination: ${{ runner.workspace }}/../ninja-build + + - name: TinyORM create build folder (clang14-cmake-debug) + run: | + mkdir -p ../TinyORM-builds-cmake/build-clang14-cmake-debug + + - name: ccache setup 🕺 + uses: Chocobo1/setup-ccache-action@v1 + with: + install_ccache: false + update_packager_index: false + ccache_options: | + compression = false + max_size = 3G + + - name: vcpkg set-up environment + run: | + echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV + echo 'VCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}/.github/resources/vcpkg-custom-triplets' \ + >> $GITHUB_ENV + echo 'VCPKG_DEFAULT_TRIPLET=x64-linux-dynamic' >> $GITHUB_ENV + echo 'VCPKG_MAX_CONCURRENCY=2' >> $GITHUB_ENV + + - name: TinyORM cmake configure (clang14-cmake-debug) + run: >- + cmake + -S . + -B ../TinyORM-builds-cmake/build-clang14-cmake-debug + -G Ninja + -D CMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/ccache + -D CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 + -D CMAKE_TOOLCHAIN_FILE:FILEPATH="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + -D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON + -D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON + -D CMAKE_BUILD_TYPE:BOOL=Debug + -D VERBOSE_CONFIGURE:BOOL=ON + -D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=OFF + -D MYSQL_PING:BOOL=ON + -D BUILD_TESTS:BOOL=ON + -D ORM:BOOL=ON + -D TOM:BOOL=ON + -D TOM_EXAMPLE:BOOL=ON + + - name: TinyORM cmake build ✨ (clang14-cmake-debug) + run: | + source .github/resources/qt5env.sh + cmake --build ../TinyORM-builds-cmake/build-clang14-cmake-debug --target all --parallel 2 + + - name: clazy-standalone install + run: >- + wget $URL_CLAZY_STANDALONE_LINUX_X64 + -O ${{ runner.temp }}/clazy-standalone.tar.bz2 --no-verbose + + sudo tar xjvf ${{ runner.temp }}/clazy-standalone.tar.bz2 --directory /usr/local + + clazy-standalone --version + env: + URL_CLAZY_STANDALONE_LINUX_X64: ${{ secrets.URL_CLAZY_STANDALONE_LINUX_X64 }} + + - name: TinyORM execute clang-tidy 🔥 + run: | + echo 'TINY_CLANG_TIDY_EXECUTED=true' >> $GITHUB_ENV + + ln -s ../TinyORM-builds-cmake/build-clang14-cmake-debug/compile_commands.json \ + compile_commands.json + + run-clang-tidy-14 '(?:src\/|tests\/).+\/(?!mocs_)[\w_\-\+]+\.cpp$' + + # Disabled checks + # Level 2 - qstring-allocations + # Manual level - qt4-qstring-from-array, qt6-qlatin1stringchar-to-u,qt-keywords, + # qvariant-template-instantiation + - name: TinyORM execute clazy-standalone 🚀 + if: env.TINY_CLANG_TIDY_EXECUTED == 'true' && (success() || failure()) + run: | + checks=\ + 'level0,level1,level2,'\ + `# Manual checks`\ + 'assert-with-side-effects,container-inside-loop,detaching-member,'\ + 'heap-allocated-small-trivial-type,ifndef-define-typo,isempty-vs-count,jni-signatures,'\ + 'qhash-with-char-pointer-key,qproperty-type-mismatch,qrequiredresult-candidates,'\ + 'qstring-varargs,qt6-deprecated-api-fixes,qt6-fwd-fixes,qt6-header-fixes,'\ + 'qt6-qhash-signature,raw-environment-function,reserve-candidates,'\ + 'signal-with-return-value,thread-with-slots,tr-non-literal,unneeded-cast,'\ + 'use-chrono-in-qtimer,'\ + `# New in Clazy 1.11`\ + 'unexpected-flag-enumerator-value,'\ + 'use-arrow-operator-instead-of-data,'\ + `# Checks Excluded from level2`\ + 'no-qstring-allocations' + + tools/run-clazy-standalone -checks="$checks" \ + -header-filter='(orm|tom|migrations)/.+\.(h|hpp)$' \ + '(?:src\/|tests\/).+\/(?!mocs_)[\w_\-\+]+\.cpp$' + diff --git a/README.md b/README.md index ba00d3d3c..7b5c96fbd 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ [![Linux GCC/Clang Qt6.2][action-linux-badge-qt6]][action-linux-qt6] [![MSYS2 UCRT64 GCC/Clang][action-mingw-badge]][action-mingw] [![clang-cl MSVC2022][clang-cl-badge]][clang-cl] -[![Clang Tidy/Clazy][action-analyzers-badge]][action-analyzers] +[![Clang Tidy/Clazy Qt5.15][action-analyzers-qt5-badge]][action-analyzers-qt5] +[![Clang Tidy/Clazy Qt6.2][action-analyzers-qt6-badge]][action-analyzers-qt6] [![www.tinyorm.org][docs-badge]][docs] [![License MIT][license-badge]][license] @@ -51,8 +52,10 @@ Whole library is documented as markdown documents: [action-mingw-badge]: https://github.com/silverqx/TinyORM/actions/workflows/mingw.yml/badge.svg [clang-cl]: https://github.com/silverqx/TinyORM/actions/workflows/clang-cl.yml [clang-cl-badge]: https://github.com/silverqx/TinyORM/actions/workflows/clang-cl.yml/badge.svg -[action-analyzers]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers.yml -[action-analyzers-badge]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers.yml/badge.svg +[action-analyzers-qt5]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers-qt5.yml +[action-analyzers-qt5-badge]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers-qt5.yml/badge.svg +[action-analyzers-qt6]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers-qt6.yml +[action-analyzers-qt6-badge]: https://github.com/silverqx/TinyORM/actions/workflows/analyzers-qt6.yml/badge.svg [docs-badge]: https://img.shields.io/badge/Docs-www.tinyorm.org-blue [docs]: https://www.tinyorm.org [license-badge]: https://img.shields.io/github/license/silverqx/TinyORM