-
Notifications
You must be signed in to change notification settings - Fork 26
83 lines (70 loc) · 2.53 KB
/
test.yml
File metadata and controls
83 lines (70 loc) · 2.53 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
# .github/workflows/ci.yml
name: Run Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
tests:
name: ${{ matrix.os }} / py${{ matrix.python-version }} (all incl. GUI)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]
include:
- python-version: "3.10"
toxenv: "py310-all"
- python-version: "3.11"
toxenv: "py311-all"
- python-version: "3.12"
toxenv: "py312-all"
env:
# Optional escape hatch (Linux only). Default off.
USE_XVFB: "0"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install tox
run: python -m pip install -U pip tox
- name: Install Xvfb (Linux, optional)
if: runner.os == 'Linux' && env.USE_XVFB == '1'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- name: Run tests with tox (Linux + optional Xvfb)
if: runner.os == 'Linux'
run: |
if [ "${USE_XVFB}" = "1" ]; then
xvfb-run -a tox -e ${{ matrix.toxenv }}
else
tox -e ${{ matrix.toxenv }}
fi
- name: Run tests with tox (macOS/Windows)
if: runner.os != 'Linux'
run: tox -e ${{ matrix.toxenv }}
# ----------------------------
# Coverage reporting
# ----------------------------
- name: Upload HTML coverage report (artifact)
uses: actions/upload-artifact@v4
with:
name: htmlcov-${{ runner.os }}-py${{ matrix.python-version }}
path: htmlcov
if-no-files-found: warn
- name: Add coverage summary to GitHub Actions job summary
shell: bash
run: |
echo "## Coverage (py${{ matrix.python-version }} on ${{ runner.os }})" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
# `pytest-cov` writes `.coverage` by default; coverage.py can render a summary from it.
python -m coverage report -m >> "$GITHUB_STEP_SUMMARY" || echo "coverage report not available" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "📎 HTML report uploaded as artifact: **htmlcov-${{ runner.os }}-py${{ matrix.python-version }}**" >> "$GITHUB_STEP_SUMMARY"