-
Notifications
You must be signed in to change notification settings - Fork 22
417 lines (344 loc) · 11 KB
/
ci.yml
File metadata and controls
417 lines (344 loc) · 11 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
name: CI
on:
push:
branches: [master, dev, feat/*, fix/*, docs/*, release/*]
pull_request:
branches: [master, dev, feat/*, fix/*, docs/*, release/*]
workflow_dispatch:
jobs:
lint:
name: Code Quality (Linting & Formatting)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff black isort pydocstyle mypy bandit[toml]
pip install types-PyYAML types-setuptools
pip install -e .
- name: Run Ruff (linting)
run: |
ruff check visdrone_toolkit/ scripts/ tests/ --exit-non-zero-on-fix
- name: Run Ruff (formatting check)
run: |
ruff format --check visdrone_toolkit/ scripts/ tests/
- name: Run Black (formatting check)
run: |
black --check --diff visdrone_toolkit/ scripts/ tests/ --line-length=100
- name: Run isort (import sorting check)
run: |
isort --check-only --diff visdrone_toolkit/ scripts/ tests/ --profile=black --line-length=100
- name: Run pydocstyle (docstring check)
run: |
pydocstyle visdrone_toolkit/ --convention=google --add-ignore=D100,D101,D102,D103,D104,D105,D107,D212
continue-on-error: true
- name: Run mypy (type checking)
run: |
mypy visdrone_toolkit/ --ignore-missing-imports --check-untyped-defs
continue-on-error: true
- name: Run Bandit (security linting)
run: |
bandit -r visdrone_toolkit/ -c pyproject.toml
continue-on-error: true
markdown-yaml-lint:
name: Markdown & YAML Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install markdownlint-cli
run: npm install -g markdownlint-cli
- name: Run markdownlint
run: |
markdownlint '**/*.md' --disable MD013 MD033 MD041 --ignore node_modules || true
continue-on-error: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install yamllint
run: pip install yamllint
- name: Run yamllint
run: |
yamllint . -d "{extends: default, rules: {line-length: {max: 120}, document-start: disable}}" || true
continue-on-error: true
test:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1 libglib2.0-0
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install -e ".[dev]"
- name: Run pytest with coverage
run: |
pytest tests/ -v --cov=visdrone_toolkit --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.10'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1 libglib2.0-0
python -m pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install -e ".[dev]"
- name: Test format converters
run: |
pytest tests/test_converters.py -v --tb=short
- name: Test dataset loading
run: |
pytest tests/test_dataset.py -v --tb=short
- name: Test model initialization
run: |
pytest tests/test_models.py -v --tb=short || true
continue-on-error: true
pre-commit:
name: Pre-commit Hooks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Set up Node.js (for prettier, markdownlint)
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit on all files
run: |
pre-commit run --all-files --show-diff-on-failure
continue-on-error: false
build:
name: Build Distribution
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check distribution
run: |
twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-packages
path: dist/
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit[toml]
pip install -e .
- name: Run safety (dependency vulnerability check)
run: |
safety check --json || true
continue-on-error: true
- name: Run bandit (security linting)
run: |
bandit -r visdrone_toolkit/ -c pyproject.toml -f json -o bandit-report.json || true
continue-on-error: true
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: bandit-report.json
shell-check:
name: Shell Script Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: "./scripts"
severity: warning
continue-on-error: true
docs:
name: Documentation Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx-rtd-theme
pip install -e .
- name: Check README
run: |
if [ ! -f README.md ]; then
README_PATH="README.md"
elif [ -f .github/README.md ]; then
README_PATH=".github/README.md"
else
echo "README.md not found"
exit 1
fi
if [ $(wc -l < "$README_PATH") -lt 50 ]; then
echo "README.md seems too short"
exit 1
fi
echo "✓ README.md found and validated"
- name: Validate CHANGELOG
run: |
if [ -f CHANGELOG.md ]; then
CHANGELOG_PATH="CHANGELOG.md"
elif [ -f .github/CHANGELOG.md ]; then
CHANGELOG_PATH=".github/CHANGELOG.md"
else
echo "CHANGELOG.md not found"
exit 0
fi
if [ $(wc -l < "$CHANGELOG_PATH") -gt 10 ]; then
echo "✓ CHANGELOG.md found"
else
echo "⚠ CHANGELOG.md not found (warning only)"
fi
continue-on-error: true
- name: Check LICENSE
run: |
if [ -f LICENSE ]; then
echo "✓ LICENSE found"
else
echo "✗ LICENSE not found"
exit 1
fi
python-compatibility:
name: Python Syntax Check (Pyupgrade)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pyupgrade
run: pip install pyupgrade
- name: Check Python 3.8+ syntax
run: |
find visdrone_toolkit/ scripts/ tests/ -name "*.py" -exec pyupgrade --py38-plus {} +
continue-on-error: true
summary:
name: CI Summary
runs-on: ubuntu-latest
needs:
[
lint,
markdown-yaml-lint,
test,
integration-tests,
pre-commit,
build,
security,
shell-check,
docs,
python-compatibility,
]
if: always()
steps:
- name: Check CI status
run: |
echo "Lint: ${{ needs.lint.result }}"
echo "Markdown/YAML Lint: ${{ needs.markdown-yaml-lint.result }}"
echo "Tests: ${{ needs.test.result }}"
echo "Integration Tests: ${{ needs.integration-tests.result }}"
echo "Pre-commit: ${{ needs.pre-commit.result }}"
echo "Build: ${{ needs.build.result }}"
echo "Security: ${{ needs.security.result }}"
echo "Shell Check: ${{ needs.shell-check.result }}"
echo "Docs: ${{ needs.docs.result }}"
echo "Python Compatibility: ${{ needs.python-compatibility.result }}"
- name: Fail if critical jobs failed
if: |
needs.lint.result == 'failure' ||
needs.test.result == 'failure' ||
needs.pre-commit.result == 'failure' ||
needs.build.result == 'failure'
run: |
echo "Critical CI checks failed"
exit 1