Repository navigation
70 lines (59 loc) · 1.97 KB
/
Copy pathtest_pytest.yml
File metadata and controls
70 lines (59 loc) · 1.97 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
name: Test Pytest
on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel
env:
# A PR to main or a push to main (the release) uses PyPI versions only; devel uses the
# devel branches from [tool.uv.sources].
UV_NO_SOURCES: ${{ (github.base_ref || github.ref_name) == 'main' }}
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install project
run: uv sync --extra test
- name: Run tests with coverage
run: uv run pytest --cov --cov-report=xml --cov-report=term .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: python-${{ matrix.python-version }}
fail_ci_if_error: false
# PyPI rejects a release whose metadata has a direct reference (name @ git+...), so a pull
# request to main fails here instead of the release after the merge.
no-direct-references:
if: (github.base_ref || github.ref_name) == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
- name: Check that the wheel has no direct references (name @ git+...)
run: |
uv build --wheel -o dist
if unzip -p dist/*.whl '*.dist-info/METADATA' | grep -E '^Requires-Dist: [^;]*@'; then
echo "::error::Requires-Dist has a direct reference; use a version range and [tool.uv.sources]"
exit 1
fi