-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (71 loc) · 2.71 KB
/
Copy pathtests.yml
File metadata and controls
85 lines (71 loc) · 2.71 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
name: Tests
on:
# Run on pushes to main only; feature branches are covered by the
# pull_request trigger, so this avoids a duplicate run per commit.
push:
branches: [main]
pull_request:
workflow_call:
jobs:
# Static checks: ruff lint + formatting and mypy type checking. Runs once
# on a single Python version since the result does not depend on the
# interpreter.
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install package with dev dependencies
run: python -m pip install -e ".[dev]"
- name: Ruff lint
run: ruff check .
- name: Ruff format check
run: ruff format --check .
- name: mypy
run: mypy captcha_solver_api
# Test suite across all supported Python versions, plus a build check
# to catch packaging errors early. Skipped if lint fails to save CI minutes.
test:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package with dev dependencies
run: python -m pip install -e ".[dev]"
- name: Run tests
run: python -m pytest tests/ -v --cov --cov-report=term --cov-report=json
# Coverage badge: the percentage is written to a gist that shields.io
# renders in README. Only from main and from a single matrix entry so
# PRs and duplicate uploads never overwrite the number.
- name: Read coverage percentage
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.12'
id: coverage
run: |
percent=$(python -c 'import json; print(round(json.load(open("coverage.json"))["totals"]["percent_covered"]))')
echo "percent=$percent" >> "$GITHUB_OUTPUT"
- name: Update coverage badge
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.12'
uses: schneegans/dynamic-badges-action@v1.9.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 77b084ed0d46c740183f89ec66af8a95
filename: python-sdk-coverage.json
label: coverage
message: ${{ steps.coverage.outputs.percent }}%
valColorRange: ${{ steps.coverage.outputs.percent }}
minColorRange: 50
maxColorRange: 90
- name: Verify package builds
run: |
python -m pip install build
python -m build --sdist --wheel