Repository navigation
304 lines (253 loc) Β· 9.05 KB
/
Copy pathci.yml
File metadata and controls
304 lines (253 loc) Β· 9.05 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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# Cancel in-progress workflows when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
jobs:
build:
name: Build (${{ matrix.os }}, ${{ matrix.build_type }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [debug, release]
env:
PRESET_NAME: ${{ matrix.os == 'ubuntu-latest' && format('linux-{0}', matrix.build_type) || matrix.os == 'windows-latest' && format('windows-{0}', matrix.build_type) || format('macos-{0}', matrix.build_type) }}
VCPKG_TRIPLET: ${{ matrix.os == 'ubuntu-latest' && 'x64-linux' || matrix.os == 'windows-latest' && 'x64-windows' || 'arm64-osx' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup vcpkg cache
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/vcpkg
~/.cache/vcpkg
key: vcpkg-${{ matrix.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
vcpkg-${{ matrix.os }}-
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build pkg-config build-essential curl zip unzip tar
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install ninja pkg-config
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install ninja
- name: Setup MSVC Developer Command Prompt (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Setup CMake and vcpkg
uses: lukka/get-cmake@latest
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "dd3097e305afa53f7b4312371f62058d2e665320"
- name: Configure project
run: cmake --preset=${{ env.PRESET_NAME }}
- name: Build project
run: cmake --build --preset=${{ env.PRESET_NAME }}
- name: Test library linkage (Unix)
if: runner.os != 'Windows'
run: |
cd bin/build/${{ env.PRESET_NAME }}/example
ls -la
file example* || true
- name: Test library linkage (Windows)
if: runner.os == 'Windows'
run: |
cd bin/build/${{ env.PRESET_NAME }}/example
dir
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: binancecpp-${{ matrix.os }}-${{ matrix.build_type }}
path: |
build/${{ env.PRESET_NAME }}/src/
build/${{ env.PRESET_NAME }}/example/
retention-days: 5
code-quality:
name: Code Quality
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup code quality tools
run: |
sudo apt-get update
sudo apt-get install -y clang-format cppcheck
python3 -m pip install --upgrade pip cpplint
- name: Find C++ source files
id: find-files
run: |
find src example -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" > cpp_files.txt
echo "file-count=$(wc -l < cpp_files.txt)" >> $GITHUB_OUTPUT
- name: Check code formatting
run: |
echo "π Checking code formatting with clang-format..."
echo "Found ${{ steps.find-files.outputs.file-count }} C++ files"
FORMAT_ISSUES=0
while IFS= read -r file; do
if [ -f "$file" ]; then
echo "Checking: $file"
if ! clang-format --dry-run --Werror "$file" > /dev/null 2>&1; then
echo "β οΈ Format issues: $file"
FORMAT_ISSUES=1
fi
fi
done < cpp_files.txt
if [ $FORMAT_ISSUES -eq 1 ]; then
echo "β οΈ Code formatting issues found (acceptable for legacy code)"
echo "π‘ To format: find src example -name '*.cpp' -o -name '*.h' | xargs clang-format -i"
else
echo "β
All files properly formatted"
fi
- name: Run style checks
run: |
echo "π Running cpplint style checker..."
LINT_ISSUES=0
while IFS= read -r file; do
if [ -f "$file" ]; then
echo "Checking style: $file"
if ! cpplint \
--filter=-legal/copyright,-build/include_subdir,-readability/streams,-build/header_guard,-build/include_order,-build/namespaces,-whitespace/tab \
--linelength=80 \
"$file" 2>&1; then
LINT_ISSUES=1
fi
fi
done < cpp_files.txt
if [ $LINT_ISSUES -eq 1 ]; then
echo "β οΈ Style issues found (acceptable for legacy code)"
else
echo "β
No significant style issues"
fi
- name: Run static analysis
run: |
echo "π¬ Running cppcheck static analysis..."
cppcheck \
--enable=warning,style,performance,portability \
--std=c++20 \
--language=c++ \
--verbose \
--error-exitcode=1 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--inline-suppr \
src/ example/ 2>&1 | tee cppcheck_output.txt
if grep -q "error:" cppcheck_output.txt; then
echo "β Cppcheck found errors"
exit 1
else
echo "β
Static analysis passed"
fi
validate-project:
name: Project Validation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate project files
run: |
echo "π Validating essential project files..."
# Check required files exist
required_files=(
"CMakeLists.txt"
"vcpkg.json"
"CMakePresets.json"
"README.md"
)
for file in "${required_files[@]}"; do
if [ -f "$file" ]; then
echo "β
Found: $file"
else
echo "β Missing: $file"
exit 1
fi
done
- name: Validate README content
run: |
echo "π Validating README.md content..."
# Check for essential sections
if grep -q -i "cmake\|build" README.md; then
echo "β
Build instructions found"
else
echo "β οΈ No build instructions found in README"
fi
if grep -q -i "vcpkg" README.md; then
echo "β
vcpkg mention found"
else
echo "β οΈ No vcpkg mention found in README"
fi
- name: Validate CMake configuration
run: |
echo "βοΈ Validating CMake presets..."
# Check if presets are valid JSON
if ! python3 -m json.tool CMakePresets.json > /dev/null; then
echo "β Invalid JSON in CMakePresets.json"
exit 1
else
echo "β
CMakePresets.json is valid JSON"
fi
# Check if vcpkg.json is valid
if ! python3 -m json.tool vcpkg.json > /dev/null; then
echo "β Invalid JSON in vcpkg.json"
exit 1
else
echo "β
vcpkg.json is valid JSON"
fi
- name: Check license and legal files
run: |
echo "βοΈ Checking license information..."
if [ -f "LICENSE" ] || [ -f "LICENSE.txt" ] || [ -f "LICENSE.md" ]; then
echo "β
License file found"
else
echo "β οΈ No license file found"
fi
# Summary job that depends on all others
ci-success:
name: CI Success
runs-on: ubuntu-latest
if: always()
needs: [build, code-quality, validate-project]
steps:
- name: Check all jobs status
run: |
echo "π CI Pipeline Summary:"
echo "======================"
# Check if any job failed
if [[ "${{ needs.build.result }}" != "success" ]]; then
echo "β Build job failed"
exit 1
else
echo "β
Build job passed"
fi
if [[ "${{ needs.code-quality.result }}" != "success" ]]; then
echo "β Code quality job failed"
exit 1
else
echo "β
Code quality job passed"
fi
if [[ "${{ needs.validate-project.result }}" != "success" ]]; then
echo "β Project validation job failed"
exit 1
else
echo "β
Project validation job passed"
fi
echo "π All CI checks passed successfully!"