-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (145 loc) · 4.33 KB
/
python-tests.yml
File metadata and controls
177 lines (145 loc) · 4.33 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
name: Python Tests & Validation
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
schedule:
- cron: '0 0 * * *' # Daily run
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Display Python version
run: python -c "import sys; print(f'Python {sys.version}')"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-asyncio
pip install -r requirements.txt
python -m spacy download en_core_web_sm
python -c "import nltk; nltk.download('punkt'); nltk.download('wordnet')"
- name: Run basic syntax check
run: |
echo "Checking Python syntax..."
python -m py_compile src/truthprobe_v3.py
if [ -f "src/enhanced_detector.py" ]; then
python -m py_compile src/enhanced_detector.py
fi
- name: Run tests with pytest
run: |
python -m pytest tests/ -v --cov=src --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml
env:
PYTHONPATH: ${{ github.workspace }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.python-version }}
path: |
junit/test-results.xml
coverage.xml
htmlcov/
lint:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install linting tools
run: |
pip install flake8 black isort mypy bandit
- name: Check code formatting with Black
run: |
black --check src/ tests/ --diff
- name: Lint with flake8
run: |
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check import order with isort
run: |
isort --check-only --diff src/ tests/
- name: Type check with mypy
run: |
mypy src/ --ignore-missing-imports --strict
- name: Security scan with bandit
run: |
bandit -r src/ -f json -o bandit-report.json || true
build:
runs-on: ubuntu-latest
needs: [test, lint]
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Verify package
run: |
pip install twine
twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist-package
path: dist/
deploy-docs:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
keep_files: true
status:
runs-on: ubuntu-latest
needs: [test, lint, build]
if: always()
steps:
- name: Create Status Badge
run: |
echo "All checks passed successfully!" > status.txt
echo "✅ All tests passed" >> status.txt
date >> status.txt
- name: Upload Status
uses: actions/upload-artifact@v3
with:
name: status
path: status.txt