-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (231 loc) · 8.2 KB
/
tests.yml
File metadata and controls
276 lines (231 loc) · 8.2 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
name: Tests
on:
push:
branches:
- main
- develop
paths:
- '**.py'
- 'requirements*.txt'
- '.github/workflows/tests.yml'
pull_request:
branches:
- main
- develop
paths:
- '**.py'
- 'requirements*.txt'
workflow_dispatch:
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-and-format:
runs-on: ubuntu-latest
name: Lint & Format Check
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install pylint flake8 2>/dev/null || echo "Linting tools optional"
- name: Lint runner.py
continue-on-error: true
run: |
if command -v pylint &> /dev/null; then
pylint runner.py --disable=all --enable=E 2>/dev/null || true
fi
if command -v flake8 &> /dev/null; then
flake8 runner.py --count --select=E9,F63,F7,F82 --show-source 2>/dev/null || true
fi
- name: Lint runners/ subpackages
continue-on-error: true
run: |
if command -v flake8 &> /dev/null; then
flake8 runners/ --count --select=E9,F63,F7,F82 --show-source 2>/dev/null || true
fi
unit-tests:
runs-on: ${{ matrix.os }}
name: Unit Tests - ${{ matrix.os }} / Python ${{ matrix.python-version }}
env:
PYTHONUTF8: "1"
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
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 pytest-cov || pip install pytest
- name: Verify package structure
run: |
python -c "import runner; print(f'✅ Core: {runner.__version__}')"
python -c "from runners.workflows import workflow_engine; print('✅ Workflows')"
python -c "from runners.profilers import performance_profiler; print('✅ Profilers')"
python -c "from runners.scanners import code_analyzer; print('✅ Scanners')"
python -c "from runners.security import secret_scanner; print('✅ Security')"
python -c "from runners.integrations import cloud_cost_tracker; print('✅ Integrations')"
- name: Run unit tests
continue-on-error: true
run: |
if [ -f "pytest.ini" ]; then
python -m pytest tests/unit/ -v --tb=short --cov=runner --cov=runners 2>&1 | head -200
else
echo "⚠️ No pytest.ini found"
fi
- name: Run integration tests
continue-on-error: true
if: matrix.os == 'ubuntu-latest'
run: |
if [ -d "tests/integration" ]; then
python -m pytest tests/integration/ -v --tb=short 2>&1 | head -100 || true
fi
api-tests:
runs-on: ubuntu-latest
name: WEBAPI Tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
cd WEBAPI && pip install -r requirements.txt
- name: Verify WEBAPI structure
run: |
python -c "import sys; sys.path.insert(0, 'WEBAPI'); from api import app; print('✅ FastAPI app loads')"
- name: Check API endpoints
run: |
python -c "
import sys
sys.path.insert(0, 'WEBAPI')
from api import app
routes = [route.path for route in app.routes]
print('API Endpoints:')
for route in sorted(routes):
print(f' - {route}')
"
docker-build:
runs-on: ubuntu-latest
name: Docker Build Test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
security-checks:
runs-on: ubuntu-latest
name: Security Checks
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install security tools
run: |
pip install bandit safety 2>/dev/null || echo "Security tools optional"
- name: Run Bandit on runner.py
continue-on-error: true
run: |
if command -v bandit &> /dev/null; then
bandit runner.py -f json -o /tmp/bandit.json 2>/dev/null || true
echo "Bandit scan completed"
fi
- name: Check dependencies
continue-on-error: true
run: |
if command -v safety &> /dev/null; then
safety check --json 2>/dev/null || echo "Safety check completed with warnings"
fi
performance-check:
runs-on: ubuntu-latest
name: Performance Check
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run performance tests
continue-on-error: true
run: |
if [ -d "tests/performance" ]; then
python -m pytest tests/performance/ -v --tb=short 2>&1 | head -100 || true
fi
compatibility-check:
runs-on: ubuntu-latest
name: Compatibility Check
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test PyPy3 compatibility
uses: actions/setup-python@v4
with:
python-version: 'pypy-3.10'
- name: Verify PyPy3 compatibility
run: |
python -m pip install --upgrade pip
pip install -r requirements-pypy3.txt 2>/dev/null || pip install -r requirements.txt
python -m py_compile runner.py
python -c "import runner; print(f'✅ PyPy3 compatibility OK: {runner.__version__}')"
summary:
runs-on: ubuntu-latest
name: Test Summary
if: always()
needs: [lint-and-format, unit-tests, api-tests, docker-build, security-checks, performance-check, compatibility-check]
steps:
- name: Test Results
run: |
echo "📊 Test Execution Summary"
echo "═══════════════════════════════════════════"
echo "✅ Lint & Format: ${{ needs.lint-and-format.result }}"
echo "✅ Unit Tests: ${{ needs.unit-tests.result }}"
echo "✅ API Tests: ${{ needs.api-tests.result }}"
echo "✅ Docker Build: ${{ needs.docker-build.result }}"
echo "✅ Security: ${{ needs.security-checks.result }}"
echo "✅ Performance: ${{ needs.performance-check.result }}"
echo "✅ Compatibility: ${{ needs.compatibility-check.result }}"
echo "═══════════════════════════════════════════"
# Fail if any critical test failed
if [ "${{ needs.unit-tests.result }}" = "failure" ]; then
echo "❌ Unit tests failed"
exit 1
fi
echo "✨ All test suites completed"