-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (147 loc) · 4.38 KB
/
code-quality.yml
File metadata and controls
182 lines (147 loc) · 4.38 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
name: Code Quality Analysis
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
# Run daily analysis
- cron: '0 2 * * *'
jobs:
complexity:
name: Code Complexity Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install tools
run: |
pip install --no-cache-dir radon pylint
- name: Check cyclomatic complexity
run: |
radon cc -a -s . | tee complexity-report.txt
continue-on-error: true
- name: Check maintainability index
run: |
radon mi -s . | tee maintainability-report.txt
continue-on-error: true
- name: Lint with pylint
run: |
pylint --exit-zero --reports=y . > pylint-report.txt 2>&1 || true
continue-on-error: true
- name: Upload reports
uses: actions/upload-artifact@v3
with:
name: code-quality-reports
path: |
complexity-report.txt
maintainability-report.txt
pylint-report.txt
if: always()
dependency-check:
name: Dependency Security Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install uv
run: pip install --no-cache-dir uv
- name: Install dependencies
run: uv sync
- name: Check for known vulnerabilities
run: uv run pip-audit --format json --output audit-report.json || true
continue-on-error: true
- name: Upload audit report
uses: actions/upload-artifact@v3
with:
name: dependency-audit
path: audit-report.json
if: always()
code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install uv
run: pip install --no-cache-dir uv
- name: Install dependencies
run: uv sync
- name: Install test dependencies
run: uv pip install pytest pytest-cov
continue-on-error: true
- name: Generate coverage report
run: |
uv run pytest --cov=. --cov-report=xml --cov-report=html . 2>/dev/null || true
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests
fail_ci_if_error: false
continue-on-error: true
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov
if: always()
sast:
name: SAST Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install security tools
run: |
pip install --no-cache-dir semgrep bandit
- name: Run semgrep
run: |
semgrep --config=p/security-audit --json --output=semgrep-report.json . || true
continue-on-error: true
- name: Run bandit
run: |
bandit -r . -f json -o bandit-report.json || true
continue-on-error: true
- name: Upload SAST reports
uses: actions/upload-artifact@v3
with:
name: sast-reports
path: |
semgrep-report.json
bandit-report.json
if: always()
summary:
name: Quality Summary
runs-on: ubuntu-latest
needs: [ complexity, dependency-check, code-coverage, sast ]
if: always()
steps:
- name: Download all reports
uses: actions/download-artifact@v3
- name: Print summary
run: |
echo "## Code Quality Summary"
echo ""
echo "✅ All quality checks completed"
echo ""
echo "### Reports Generated:"
echo "- Complexity Analysis"
echo "- Dependency Audit"
echo "- Code Coverage"
echo "- SAST Analysis"
echo ""
echo "Check the artifacts tab for detailed reports."