-
Notifications
You must be signed in to change notification settings - Fork 1
191 lines (158 loc) · 6.01 KB
/
tests.yml
File metadata and controls
191 lines (158 loc) · 6.01 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
name: Tests
permissions:
contents: write
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -V
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coverage pytest pytest-cov
- name: Run tests with coverage
env:
DBC_TEST_USERNAME: ${{ secrets.DBC_USERNAME }}
DBC_TEST_PASSWORD: ${{ secrets.DBC_PASSWORD }}
run: python -m pytest tests/ -v --cov=src/deathbycaptcha --cov-report=term --cov-report=xml --junit-xml=report.xml
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports-py${{ matrix.python-version }}
path: |
report.xml
coverage.xml
retention-days: 30
test-python3-15:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.15.0-alpha.5
uses: actions/setup-python@v5
with:
python-version: "3.15.0-alpha.5"
- name: Display Python version
run: python -V
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coverage pytest pytest-cov
- name: Run tests with coverage
env:
DBC_TEST_USERNAME: ${{ secrets.DBC_USERNAME }}
DBC_TEST_PASSWORD: ${{ secrets.DBC_PASSWORD }}
run: python -m pytest tests/ -v --cov=src/deathbycaptcha --cov-report=term --cov-report=xml --junit-xml=report.xml
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports-py3.15.0-alpha.5
path: |
report.xml
coverage.xml
retention-days: 30
test-image-captcha-python3-14:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.14
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Display Python version
run: python -V
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-cov
- name: Run all tests with coverage (Python 3.14)
env:
DBC_TEST_USERNAME: ${{ secrets.DBC_USERNAME }}
DBC_TEST_PASSWORD: ${{ secrets.DBC_PASSWORD }}
run: python -m pytest tests/ -v --cov=src/deathbycaptcha --cov-report=term --cov-report=xml --cov-report=html --junit-xml=report.xml
- name: Upload coverage reports and test results
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-badge-test-results-py3.14
path: |
report.xml
coverage.xml
htmlcov/
retention-days: 30
- name: Generate coverage badge SVG
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'develop')
run: |
python - << 'PY'
import os
import xml.etree.ElementTree as ET
tree = ET.parse('coverage.xml')
root = tree.getroot()
line_rate = float(root.attrib.get('line-rate', '0'))
pct = round(line_rate * 100)
if pct >= 90:
color = '#4c1'
elif pct >= 75:
color = '#97CA00'
elif pct >= 60:
color = '#dfb317'
else:
color = '#e05d44'
left_text = 'coverage'
right_text = f'{pct}%'
left_w = 78
right_w = 52
total_w = left_w + right_w
svg = "\n".join([
f'<svg xmlns="http://www.w3.org/2000/svg" width="{total_w}" height="20" role="img" aria-label="{left_text}: {right_text}">',
' <linearGradient id="s" x2="0" y2="100%">',
' <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>',
' <stop offset="1" stop-opacity=".1"/>',
' </linearGradient>',
f' <clipPath id="r"><rect width="{total_w}" height="20" rx="3" fill="#fff"/></clipPath>',
' <g clip-path="url(#r)">',
f' <rect width="{left_w}" height="20" fill="#555"/>',
f' <rect x="{left_w}" width="{right_w}" height="20" fill="{color}"/>',
f' <rect width="{total_w}" height="20" fill="url(#s)"/>',
' </g>',
' <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" text-rendering="geometricPrecision" font-size="11">',
f' <text x="{left_w/2}" y="15" fill="#010101" fill-opacity=".3">{left_text}</text>',
f' <text x="{left_w/2}" y="14">{left_text}</text>',
f' <text x="{left_w + right_w/2}" y="15" fill="#010101" fill-opacity=".3">{right_text}</text>',
f' <text x="{left_w + right_w/2}" y="14">{right_text}</text>',
' </g>',
'</svg>'
]) + "\n"
os.makedirs('.github/badges', exist_ok=True)
with open('.github/badges/coverage.svg', 'w', encoding='utf-8') as f:
f.write(svg)
PY
- name: Commit coverage badge
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'develop')
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/badges/coverage.svg
git diff --cached --quiet && exit 0
git commit -m "chore(ci): update coverage badge [skip ci]"
git push