Skip to content

Clang-Tidy and Clazy 6.7 #274

Clang-Tidy and Clazy 6.7

Clang-Tidy and Clazy 6.7 #274

Workflow file for this run

# ccache
# ---
# Uses /ccache_vcpkg folder and the compressed cache size is 360M (after whole workflow finishes)
# This /ccache_vcpkg folder is common for analyzers.yml and vcpkg-linux.yml workflows
# vcpkg-linux.yml takes 205M and analyzers.yml takes 155M
#
# On the Clazy README.md page is written:
# - It's recommended that you disable pre-compiled headers and don't use ccache.
# - Some checks are mysteriously not producing warnings or not applying fixits?
# Check if you have ccache interfering and turn it off.
#
# I'm not using PCH, but I'm using ccache as it doesn't interfere, I have tried it. πŸ€”
name: Clang-Tidy and Clazy 6.7
# Invoke manually from the command-line using the gh command, eg.:
# gh workflow run --ref silverqx-develop
# The reason for this is that I have 2 self-hosted runners on one PC (one for Linux and other for
# Windows) and I'm not able to serialize all these workflows and because of that I would have to
# decrease parallel and it would take hours to finish, so all Linux workflows must be invoked
# manually.
on: workflow_dispatch
concurrency:
group: tinyorm-linux
jobs:
analyzers:
name: Clang-Tidy and Clazy
# Self-hosted runner is Fedora 40
runs-on: [ self-hosted, linux ]
env:
# Settings (constant variables)
TINY_PARALLEL: 8
# State variables
TINY_CLANG_TIDY_COMPLETED: false
TINY_VCPKG_NEEDS_UPGRADE: false
# For simpler updates and to avoid duplicates
TINY_COMPILER_COMMAND: clang++-18
# Clang Tidy can't be executed on Release builds, it's designed to be run on Debug builds only
strategy:
matrix:
# Leaving here this matrix for future versions
qt:
- key: qt6
name: Qt6
version: 6.7.2
steps:
- uses: actions/checkout@v4
with:
path: main
- name: TinyORM prepare environment
run: |
runnerWorkPath=$(realpath "$RUNNER_WORKSPACE/..")
echo "TinyRunnerWorkPath=$runnerWorkPath" >> $GITHUB_ENV
tinyormPath=$(realpath ./main)
echo "TinyORMPath=$tinyormPath" >> $GITHUB_ENV
tinyormBuildName='analyzers-${{ matrix.qt.key }}-clang-debug'
echo "TinyORMBuildName=$tinyormBuildName" >> $GITHUB_ENV
tinyormBuildTree="$RUNNER_WORKSPACE/TinyORM-builds-cmake/build-$tinyormBuildName"
echo "TinyORMBuildTree=$tinyormBuildTree" >> $GITHUB_ENV
# lukka/get-cmake@latest needed because of Fedora
- name: CMake and Ninja install latest versions
uses: lukka/get-cmake@latest
with:
useLocalCache: true
useCloudCache: false
# Don't use the default CCACHE_DIR path on self-hosted runners
# analyzers.yml and vcpkg-linux.yml use the same /ccache_vcpkg folder
- name: Ccache prepare environment
run: |
ccacheDirPath=$(realpath "$RUNNER_WORKSPACE/ccache_vcpkg")
echo "CCACHE_DIR=$ccacheDirPath" >> $GITHUB_ENV
- name: Ccache print version and configuration
run: |
echo '::group::Print version'
ccache --version
echo '::endgroup::'
echo '::group::Print ccache config'
ccache --show-config
echo '::endgroup::'
# Don't define VCPKG_DEFAULT_BINARY_CACHE as Linux VM image is strictly for GH actions use only
- name: vcpkg prepare environment
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
echo 'VCPKG_DEFAULT_TRIPLET=x64-linux-dynamic' >> $GITHUB_ENV
echo "VCPKG_MAX_CONCURRENCY=$TINY_PARALLEL" >> $GITHUB_ENV
- name: vcpkg needs upgrade? (once per day)
run: |
vcpkgUpgradedAtFilepath="$RUNNER_WORKSPACE/.vcpkg_upgraded_at"
if [ ! -f "$vcpkgUpgradedAtFilepath" ] || [ ! -r "$vcpkgUpgradedAtFilepath" ] || \
! read datePreviousUpgradeRaw < "$vcpkgUpgradedAtFilepath"
then
echo 'TINY_VCPKG_NEEDS_UPGRADE=true' >> $GITHUB_ENV
exit 0
fi
datePreviousUpgrade=$(date --date="$datePreviousUpgradeRaw" +%s)
if [ $? -ne 0 ] || [ -z "$datePreviousUpgrade" ]; then
echo "Parsing the '.vcpkg_upgraded_at' failed." >&2
exit 1
fi
dateToday=$(date --date=$(date +%Y-%m-%d) +%s)
if [ "$datePreviousUpgrade" -lt "$dateToday" ]; then
echo 'TINY_VCPKG_NEEDS_UPGRADE=true' >> $GITHUB_ENV
fi
- name: vcpkg upgrade repository (latest version)
if: env.TINY_VCPKG_NEEDS_UPGRADE == 'true'
run: |
cd "$VCPKG_INSTALLATION_ROOT"
git switch master
git fetch --tags origin
git reset --hard origin/master
./bootstrap-vcpkg.sh
date +%Y-%m-%d > "$RUNNER_WORKSPACE/.vcpkg_upgraded_at"
- name: ${{ matrix.qt.name }} prepare environment
run: |
echo '/opt/Qt/${{ matrix.qt.version }}/gcc_64/bin' >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/opt/Qt/${{ matrix.qt.version }}/gcc_64/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Compiler print version (${{ env.TINY_COMPILER_COMMAND }})
run: |
${{ env.TINY_COMPILER_COMMAND }} --version
- name: Linker print version (ld.lld)
run: |
ld.lld --version
- name: Linker print version (ld - unused!)
run: |
ld --version
- name: CMake print version
run: |
cmake --version
- name: Ninja print version
run: |
ninja --version
- name: vcpkg print version
run: |
vcpkg --version
- name: Clang Tidy print version
run: |
clang-tidy --version
- name: Clazy print version
run: |
clazy-standalone --version
- name: Qt print version
run: |
qmake -query QT_VERSION
- name: Ccache clear statistics
run: |
ccache --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (Clazy is failing with OFF)
- name: TinyORM cmake configure (${{ env.TinyORMBuildName }})
working-directory: ${{ env.TinyORMPath }}
run: >-
cmake --log-level=DEBUG --log-context
-S .
-B "$TinyORMBuildTree"
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache
-D CMAKE_CXX_COMPILER:FILEPATH=${{ env.TINY_COMPILER_COMMAND }}
-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_EXPORT_PACKAGE_REGISTRY:BOOL=OFF
-D CMAKE_BUILD_TYPE:STRING=Debug
-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF
-D VCPKG_APPLOCAL_DEPS:BOOL=OFF
-D VERBOSE_CONFIGURE:BOOL=ON
-D BUILD_TREE_DEPLOY:BOOL=OFF
-D STRICT_MODE:BOOL=ON
-D MYSQL_PING:BOOL=ON
-D BUILD_TESTS:BOOL=ON
-D ORM:BOOL=ON
-D TOM:BOOL=ON
-D TOM_EXAMPLE:BOOL=ON
-D BUILD_DRIVERS:BOOL=ON
-D DRIVERS_TYPE:STRING=Loadable
- name: TinyORM cmake build ✨ (${{ env.TinyORMBuildName }})
working-directory: ${{ env.TinyORMBuildTree }}
run: >-
cmake --build . --target all --parallel $TINY_PARALLEL
- name: Ccache print statistics
run: |
ccache --show-stats --verbose
- name: libTinyOrm print .comment section
working-directory: ${{ env.TinyORMBuildTree }}
run: |
readelf --string-dump .comment ./libTinyOrmd.so
- name: TinyORM execute clang-tidy πŸ”₯
working-directory: ${{ env.TinyORMPath }}
run: >-
echo 'TINY_CLANG_TIDY_COMPLETED=true' >> $GITHUB_ENV
run-clang-tidy
-extra-arg-before='-Qunused-arguments'
-p="$TinyORMBuildTree"
-j $TINY_PARALLEL
'[\\\/]+(?:drivers|examples|orm|src|tests|tom)[\\\/]+.+?[\\\/]+(?!mocs_)[\w\d_\-\+]+\.cpp$'
# Disabled checks
# Level 2 - qstring-allocations
# Manual level - qt-keyword-emit (I'm not using the emit keyword; new in v1.12)
# qt4-qstring-from-array (removed from v1.12)
# qt6-qlatin1stringchar-to-u
# qvariant-template-instantiation
# unused-result-check (causes crashes)
# Others:
# In v1.12 is also a new unused-result-check warning, but when I tried it clazy-standalone.exe
# crashed (on Windows), this check isn't EVEN in the Clazy Changelog (Release Notes).
- name: TinyORM execute clazy-standalone πŸš€
# Run the clazy if the clang-tidy was executed and was success or failed
if: env.TINY_CLANG_TIDY_COMPLETED == 'true' && (success() || failure())
working-directory: ${{ env.TinyORMPath }}
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,qt-keywords,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 v1.11`\
'unexpected-flag-enumerator-value,'\
'use-arrow-operator-instead-of-data,'\
`# Checks Excluded from level2`\
'no-qstring-allocations,'\
`# New in Clazy v1.12`\
'no-module-include,'\
'sanitize-inline-keyword'
python3 ./tools/run-clazy-standalone.py \
-checks="$checks" \
-extra-arg-before='-Qunused-arguments' \
-header-filter='[\\\/]+(drivers|examples|orm|tests|tom)[\\\/]+.+\.(h|hpp)$' \
-j $TINY_PARALLEL \
-p="$TinyORMBuildTree" \
'[\\\/]+(?:drivers|examples|orm|src|tests|tom)[\\\/]+.+?[\\\/]+(?!mocs_)[\w\d_\-\+]+\.cpp$'