-
Notifications
You must be signed in to change notification settings - Fork 1
215 lines (176 loc) · 5.37 KB
/
ci.yml
File metadata and controls
215 lines (176 loc) · 5.37 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
name: CI/CD Pipeline
on:
push:
branches: [ main, develop, 'feat/**' ]
pull_request:
branches: [ main, develop ]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
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 dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest-cov pytest-html
- name: Create required directories
run: |
mkdir -p data/backups
mkdir -p out
mkdir -p .logs
- name: Run unit tests with coverage
run: |
python -m pytest tests/ -v \
--cov=src \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--html=test-report.html \
--self-contained-html
continue-on-error: false
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.12'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.python-version }}
path: |
test-report.html
htmlcov/
coverage.xml
- name: Check test coverage threshold
if: matrix.python-version == '3.12'
run: |
python -m pytest tests/ --cov=src --cov-fail-under=25
lint:
name: Code Quality Checks
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.12'
cache: 'pip'
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install flake8 black isort
- name: Run flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true
- name: Check code formatting with black
run: |
black --check src/ tests/
continue-on-error: true
- name: Check import sorting with isort
run: |
isort --check-only src/ tests/
continue-on-error: true
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Create required directories
run: |
mkdir -p data/backups
mkdir -p out
mkdir -p .logs
- name: Run integration tests
run: |
python -m pytest tests/test_integration.py -v
- name: Run comprehensive quality suite
run: |
python -m pytest tests/test_comprehensive_quality_suite.py -v
- name: Run API tests
run: |
python -m pytest tests/test_api.py -v
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.12'
cache: 'pip'
- name: Install security tools
run: |
python -m pip install --upgrade pip
pip install safety bandit
- name: Run safety check
run: |
pip install -r requirements.txt
safety check --json
continue-on-error: true
- name: Run bandit security scan
run: |
bandit -r src/ -f json -o bandit-report.json
continue-on-error: true
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json
build-status:
name: Build Status
runs-on: ubuntu-latest
needs: [test, lint, integration-test, security]
if: always()
steps:
- name: Check build status
run: |
echo "Test job status: ${{ needs.test.result }}"
echo "Lint job status: ${{ needs.lint.result }}"
echo "Integration test job status: ${{ needs.integration-test.result }}"
echo "Security job status: ${{ needs.security.result }}"
if [ "${{ needs.test.result }}" != "success" ]; then
echo "❌ Tests failed!"
exit 1
fi
if [ "${{ needs.integration-test.result }}" != "success" ]; then
echo "❌ Integration tests failed!"
exit 1
fi
echo "✅ All critical checks passed!"