-
Notifications
You must be signed in to change notification settings - Fork 27
227 lines (188 loc) · 8.68 KB
/
analyzers.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Clang-Tidy and Clazy Qt5.15/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 Ubuntu 22.04
runs-on: [ self-hosted, linux ]
# Clang Tidy can't be executed on Release builds, it's designed to be run on Debug builds only
strategy:
matrix:
qt:
- key: qt5
name: Qt5
version: 5.15.2
# - key: qt6
# name: Qt6
# version: 6.7.0
env:
TINY_CLANG_TIDY_COMPLETED: false
steps:
- uses: actions/checkout@v4
with:
path: main
- name: TinyORM prepare environment
run: |
runnerWorkPath=$(realpath '${{ runner.workspace }}/..')
echo "TinyRunnerWorkPath=$runnerWorkPath" >> $GITHUB_ENV
# Starts with the merydeye-
[[ "${{ runner.name }}" == 'merydeye-'* ]] && isSelfHostedRunner='true' || isSelfHostedRunner='false'
echo "TinyIsSelfHostedRunner=$isSelfHostedRunner" >> $GITHUB_ENV
# Parallel 4 ISN't maximum but because this workflow runs hours I will use parallel 4 to be
# able continue working on my PC, also, I decided to use the different strategy, I will use
# the on: workflow_dispatch for all Linux GitHub Actions and will invoke these workflows
# manually from the command-line using the gh command, eg.:
# gh workflow run --ref silverqx-develop
[[ "$isSelfHostedRunner" == 'true' ]] && parallel=8 || parallel=2
echo "TinyParallel=$parallel" >> $GITHUB_ENV
tinyormPath=$(realpath ./main)
echo "TinyORMPath=$tinyormPath" >> $GITHUB_ENV
tinyormBuildName='analyzers-${{ matrix.qt.key }}-clang-debug'
echo "TinyORMBuildName=$tinyormBuildName" >> $GITHUB_ENV
tinyormBuildFolder="build-$tinyormBuildName"
echo "TinyORMBuildFolder=$tinyormBuildFolder" >> $GITHUB_ENV
tinyormBuildTree="${{ runner.workspace }}/TinyORM-builds-cmake/$tinyormBuildFolder"
echo "TinyORMBuildTree=$tinyormBuildTree" >> $GITHUB_ENV
- name: Test self-hosted runner
if: env.TinyIsSelfHostedRunner == 'false'
run: |
throw 'This workflow is optimized for the self-hosted runner only.'
- name: Ninja install latest version
uses: seanmiddleditch/gha-setup-ninja@master
with:
destination: ${{ env.TinyRunnerWorkPath }}/ninja-build
# Don't use the default CCACHE_DIR path on self-hosted runners
- name: Ccache prepare environment
run: |
ccacheDirPath=$(realpath '${{ runner.workspace }}/ccache')
echo "CCACHE_DIR=$ccacheDirPath" >> $GITHUB_ENV
- name: Ccache prepare configuration 🥳
run: |
# ~ 490 * 3 + 100
ccache --set-config max_size=1600M
ccache --set-config sloppiness=pch_defines,time_macros
- 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::'
- 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=${{ env.TinyParallel }}' >> $GITHUB_ENV
- name: ${{ matrix.qt.name }} prepare environment
run: |
echo '/opt/Qt/${{ matrix.qt.version }}/bin' >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/opt/Qt/${{ matrix.qt.version }}/gcc_64/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" >> $GITHUB_ENV
# The CMAKE_PREFIX_PATH must be defined on the GitHub Actions, this is some kind of a bug because the CMake
# can't find the Qt, but if I export the PATH directly in the step it works but doesn't work using
# the GITHUB_PATH like define two line above. 🫤
echo "CMAKE_PREFIX_PATH=/opt/Qt/${{ matrix.qt.version }}/gcc_64${CMAKE_PREFIX_PATH:+:}$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
- name: CMake print version
run: |
cmake --version
- name: Clazy print version
run: |
clazy-standalone --version
- name: TinyORM create folder for build trees
run: |
mkdir --parents '../TinyORM-builds-cmake'
- name: Ccache clear statistics
run: |
ccache --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (Clazy is failing with OFF)
# TinyDrivers are disabled for Qt v5.15
- name: TinyORM cmake configure (${{ env.TinyORMBuildName }})
working-directory: ${{ env.TinyORMPath }}
run: >-
tinyBuildDrivers='OFF'
# [[ '${{ matrix.qt.key }}' == 'qt6' ]] && tinyBuildDrivers='ON' || tinyBuildDrivers='OFF'
cmake
-S .
-B '${{ env.TinyORMBuildTree }}'
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=/usr/local/bin/ccache
-D CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18
-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=${{ matrix.build-type.name }}
-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 MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=OFF
-D STRICT_MODE:BOOL=ON
-D MYSQL_PING:BOOL=ON
-D BUILD_TESTS:BOOL=OFF
-D ORM:BOOL=ON
-D TOM:BOOL=ON
-D TOM_EXAMPLE:BOOL=ON
-D BUILD_DRIVERS:BOOL=$tinyBuildDrivers
-D DRIVERS_TYPE:STRING=Loadable
- name: TinyORM cmake build ✨ (${{ env.TinyORMBuildName }})
working-directory: ${{ env.TinyORMBuildTree }}
run: >-
cmake --build . --target all --parallel ${{ env.TinyParallel }}
- name: Ccache print statistics
run: |
ccache --show-stats -vv
- name: TinyORM execute clang-tidy 🔥
working-directory: ${{ env.TinyORMPath }}
run: >-
echo 'TINY_CLANG_TIDY_COMPLETED=true' >> $GITHUB_ENV
run-clang-tidy-18
-extra-arg-before='-Qunused-arguments'
-p='${{ env.TinyORMBuildTree }}'
-j ${{ env.TinyParallel }}
'[\\\/]+(?:drivers|examples|orm|src|tests|tom)[\\\/]+.+?[\\\/]+(?!mocs_)[\w\d_\-\+]+\.cpp$'
- name: Clazy-standalone prepare
# 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: |
chmod +x ./tools/run-clazy-standalone.py
# Disabled checks
# Level 2 - qstring-allocations
# Manual level - qt4-qstring-from-array, qt6-qlatin1stringchar-to-u,
# qvariant-template-instantiation
- 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 1.11`\
'unexpected-flag-enumerator-value,'\
'use-arrow-operator-instead-of-data,'\
`# Checks Excluded from level2`\
'no-qstring-allocations'
./tools/run-clazy-standalone.py \
-checks="$checks" \
-extra-arg-before='-Qunused-arguments' \
-header-filter='[\\\/]+(drivers|examples|orm|tests|tom)[\\\/]+.+\.(h|hpp)$' \
-j ${{ env.TinyParallel }} \
-p='${{ env.TinyORMBuildTree }}' \
'[\\\/]+(?:drivers|examples|orm|src|tests|tom)[\\\/]+.+?[\\\/]+(?!mocs_)[\w\d_\-\+]+\.cpp$'