-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 2.3 KB
/
python-tests.yml
File metadata and controls
87 lines (77 loc) · 2.3 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
name: Reusable Python Tests
permissions:
contents: read
on:
workflow_call:
inputs:
python-versions:
description: JSON array of Python versions.
required: false
type: string
default: '["3.11","3.12","3.13"]'
install-spec:
description: Pip install spec, e.g. .[test]
required: false
type: string
default: ".[test]"
coverage-target:
description: Coverage target path.
required: false
type: string
default: "deux"
coverage-threshold:
description: Coverage fail-under percentage.
required: false
type: number
default: 95
pytest-args:
description: Additional pytest args.
required: false
type: string
default: "tests/"
system-packages:
description: Apt packages required before tests.
required: false
type: string
default: "libhidapi-dev"
jobs:
pytest:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install system dependencies
if: ${{ inputs.system-packages != '' }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ inputs.system-packages }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e "${{ inputs.install-spec }}"
python -m pip install pytest-cov
- name: Run tests with coverage
run: |
python -m pytest \
--cov=${{ inputs.coverage-target }} \
--cov-report=term-missing \
--cov-report=xml \
--cov-fail-under=${{ inputs.coverage-threshold }} \
${{ inputs.pytest-args }}
- name: Upload coverage report
if: always() && matrix.python-version == '3.12'
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage.xml
retention-days: 14