Skip to content

Commit d050d98

Browse files
committed
Add CI, tox and coverage config
Add GitHub Actions CI workflow to run unit and smoke tests across Ubuntu, macOS, and Windows for Python 3.10–3.12, cache tox environments, append coverage summary, and upload coverage to Codecov. Introduce tox.ini to standardize test and lint environments (py310/311/312 plus a ruff lint env), run pytest excluding hardware-marked tests, and set CI-friendly environment variables. Add .coveragerc to configure coverage (branch, source dlclivegui, and omit hardware SDK shim backends). Update pyproject.toml test markers to add a "hardware" marker and comment out the previous "slow" marker.
1 parent db3698c commit d050d98

File tree

4 files changed

+126
-1
lines changed

4 files changed

+126
-1
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# .coveragerc
3+
[run]
4+
branch = True
5+
source = dlclivegui
6+
omit =
7+
# omit only the parts that are pure passthrough shims to SDKs
8+
dlclivegui/cameras/backends/basler_backend.py
9+
dlclivegui/cameras/backends/gentl_backend.py
10+
# dlclivegui/cameras/backends/aravis_backend.py

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
unit:
13+
name: Unit + Smoke (no hardware) • ${{ matrix.os }} • py${{ matrix.python }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
python: ['3.10', '3.11', '3.12']
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v6
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: ${{ matrix.python }}
29+
cache: 'pip'
30+
31+
- name: Cache tox environments
32+
uses: actions/cache@v4
33+
with:
34+
path: .tox
35+
key: tox-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}
36+
restore-keys: |
37+
tox-${{ runner.os }}-py${{ matrix.python }}-
38+
39+
40+
- name: Install tox
41+
run: |
42+
python -m pip install -U pip wheel
43+
python -m pip install -U tox tox-gh-actions
44+
45+
- name: Run tests (exclude hardware) with coverage via tox
46+
run: |
47+
tox -q
48+
49+
- name: Append Coverage Summary to Job
50+
if: always()
51+
shell: bash
52+
run: |
53+
python -m pip install -U coverage
54+
echo "## Coverage Summary" >> "$GITHUB_STEP_SUMMARY"
55+
echo "" >> "$GITHUB_STEP_SUMMARY"
56+
echo '```text' >> "$GITHUB_STEP_SUMMARY"
57+
python -m coverage report -m >> "$GITHUB_STEP_SUMMARY" || true
58+
echo '```' >> "$GITHUB_STEP_SUMMARY"
59+
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v5
62+
with:
63+
files: ./coverage.xml
64+
token: ${{ secrets.CODECOV_TOKEN }}
65+
fail_ci_if_error: true

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ markers = [
9494
"unit: Unit tests for individual components",
9595
"integration: Integration tests for component interaction",
9696
"functional: Functional tests for end-to-end workflows",
97-
"slow: Tests that take a long time to run",
97+
"hardware: Tests that require specific hardware, notable camera backends",
98+
# "slow: Tests that take a long time to run",
9899
"gui: Tests that require GUI interaction",
99100
]
100101

tox.ini

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[tox]
2+
min_version = 4.0
3+
env_list =
4+
py{310,311,312}
5+
lint
6+
isolated_build = true
7+
skip_missing_interpreters = true
8+
9+
[testenv]
10+
description = Unit + smoke tests (exclude hardware) with coverage
11+
package = wheel
12+
extras = test
13+
14+
# Keep behavior aligned with your GitHub Actions job:
15+
commands =
16+
pytest -m "not hardware" --maxfail=1 --disable-warnings \
17+
--cov=dlclivegui --cov-report=xml --cov-report=term-missing {posargs}
18+
19+
# Helpful defaults for headless CI runs (Qt/OpenCV):
20+
setenv =
21+
PYTHONWARNINGS = default
22+
QT_QPA_PLATFORM = offscreen
23+
# Can help avoid some Windows/OpenCV capture backend flakiness when tests touch video I/O:
24+
OPENCV_VIDEOIO_PRIORITY_MSMF = 0
25+
26+
# Let CI variables pass through (useful for debugging and some GUI/headless setups):
27+
passenv =
28+
CI
29+
GITHUB_*
30+
DISPLAY
31+
WAYLAND_DISPLAY
32+
XDG_RUNTIME_DIR
33+
34+
[testenv:lint]
35+
description = Ruff linting/format checks (matches pyproject.toml config)
36+
skip_install = true
37+
deps =
38+
ruff
39+
commands =
40+
ruff check .
41+
ruff format --check .
42+
43+
# Optional helper if you use tox-gh-actions to map GitHub's python-version to tox envs.
44+
# Requires: pip install tox-gh-actions
45+
[gh-actions]
46+
python =
47+
3.10: py310
48+
3.11: py311
49+
3.12: py312, lint

0 commit comments

Comments
 (0)