-
Notifications
You must be signed in to change notification settings - Fork 14
176 lines (129 loc) · 4.77 KB
/
cpp-quality.yml
File metadata and controls
176 lines (129 loc) · 4.77 KB
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
#
# .github/workflows/cpp-quality.yml
#
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026 Jens A. Koch.
# This file is part of fifengine/fifechan.
#
name: "C++ Quality"
on:
- push
- pull_request
# You can manually run this workflow.
- workflow_dispatch
# improve CI concurrency by automatically cancelling outdated jobs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ---------------------------------------------------------------------------------------
clang-format:
# ---------------------------------------------------------------------------------------
runs-on: ubuntu-latest
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v6 # https://github.com/actions/checkout
- name: 🔽 Install dos2unix
run: |
sudo apt-get update
sudo apt-get install -y dos2unix
- name: 🔽 Install clang-format-20
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 20
sudo apt-get install -y clang-format-20
rm llvm.sh
- name: 🛠️ Apply formatting
run: |
chmod +x build-tools/format.sh
./build-tools/format.sh
#continue-on-error: true
- name: 🛠️ Check git difference
run: |
git status
git diff
#continue-on-error: true
# ---------------------------------------------------------------------------------------
cpplint:
# ---------------------------------------------------------------------------------------
runs-on: ubuntu-latest
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v6 # https://github.com/actions/checkout
- name: 🔽 Setup Python
run: |
sudo apt-get update
sudo apt-get -y install python3 python3-pip python3-venv grep
- name: 🔽 Setup Python Virtual Env
run: |
export VIRTUAL_ENV=/opt/venv
python3 -m venv $VIRTUAL_ENV
export PATH="$VIRTUAL_ENV/bin:$PATH"
- name: 🔽 Install cpplint
run: |
pip install --prefer-binary --no-cache-dir cpplint
- name: 🛠️ Run cpplint
run: |
cpplint --recursive src include tests examples
- name: 🛠️ Identify places where 'reinterpret_cast' is used
run: |
grep -rniw --include=\*.{cpp,hpp} "reinterpret_cast" src include tests examples
# ---------------------------------------------------------------------------------------
cppcheck:
# ---------------------------------------------------------------------------------------
runs-on: ubuntu-latest
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v6 # https://github.com/actions/checkout
- name: 🔽 Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: 🛠️ Run cppcheck
run: |
echo "Cppcheck version: $(cppcheck --version)"
cppcheck \
--enable=warning,style,performance,portability \
--std=c++20 \
--quiet \
--inline-suppr \
--error-exitcode=1 \
-I include \
src examples tests
#continue-on-error: true
# ---------------------------------------------------------------------------------------
comments-check:
# ---------------------------------------------------------------------------------------
runs-on: ubuntu-slim
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v6 # https://github.com/actions/checkout
- name: 🔽 Install ripgrep
run: |
sudo apt-get update
sudo apt-get install -y ripgrep
- name: 🛠️ Check for TODO, FIXME comments (src, tests)
run: |
rg -n -i '\b(?:TODO|FIXME)\b' src tests
- name: 🛠️ Check for MAYBE, PROBABLY, BROKEN, WORKAROUND comments (src, tests)
run: |
rg -n -i '\b(?:MAYBE|PROBABLY|BROKEN|WORKAROUND)\b' src tests
- name: 🛠️ Identify reinterpret_cast usage (src, tests)
continue-on-error: true
run: |
rg -n -g '*.{cpp,hpp}' '\breinterpret_cast\b' src tests
- name: 🛠️ Identify const_cast usage (src, tests)
continue-on-error: true
run: |
rg -n -g '*.{cpp,hpp}' '\bconst_cast\b' src tests
- name: 🛠️ Identify static_cast usage (src, tests)
continue-on-error: true
run: |
rg -n -g '*.{cpp,hpp}' '\bstatic_cast\b' src tests
- name: 🛠️ Identify dynamic_cast usage (src, tests)
continue-on-error: true
run: |
rg -n -g '*.{cpp,hpp}' '\bdynamic_cast\b' src tests