Repository navigation
168 lines (160 loc) · 5.63 KB
/
Copy pathtesting.yml
File metadata and controls
168 lines (160 loc) · 5.63 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Automated Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install pre-commit
shell: bash
run: |
python -V
python -m pip install pre-commit
- name: Run pre-commit linters
shell: bash
run: |
pre-commit run --all-files
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "3.14t", "3.15t", "pypy-3.11"]
exclude:
# Do not test all minor versions on all platforms, especially if they
# are not the oldest/newest supported versions
- os: windows-latest
python_version: 3.8
# as of 4/02/2020, psutil won't build under PyPy + Windows
- os: windows-latest
python_version: "pypy-3.11"
- os: macos-latest
python_version: 3.8
- os: macos-latest
# numpy triggers: RuntimeError: Polyfit sanity test emitted a
# warning
python_version: "pypy-3.11"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install project and dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install -r dev-requirements.txt
- name: Display Python version
shell: bash
run: python -c "import sys; print(sys.version)"
- name: Test with pytest
shell: bash
run: |
PYTHONPATH='.:tests' python -m pytest -r s -vs
coverage:
# Coverage of the Rust code, measured with cargo-llvm-cov (LLVM
# source-based code coverage) on an instrumented build of the extension
# module, and of the Python code, measured with coverage.py, in the pytest
# process and its Python subprocesses. It is measured with every version of
# Python and PyPy as the Rust code has version-specific code paths: Codecov
# merges the reports.
name: coverage (${{ matrix.python_version }})
runs-on: ubuntu-latest
permissions:
contents: read
# To upload the reports to Codecov with OpenID Connect (without token).
id-token: write
strategy:
fail-fast: false
matrix:
# PyPy 7.3 (pypy3.11-v7.3.x) and PyPy 8.0 (pypy-3.11) have different
# code objects.
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "3.14t", "3.15t", "pypy3.11-v7.3.x", "pypy-3.11"]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install project (instrumented build) and dependencies
shell: bash
run: |
# Build the extension module with the coverage instrumentation.
eval "$(cargo llvm-cov show-env --sh)"
cargo llvm-cov clean --workspace
python -m pip install --upgrade pip
MATURIN_PEP517_ARGS="--profile dev" python -m pip install -e .
python -m pip install -r dev-requirements.txt
python ci/install_coverage_subprocess_pth.py
- name: Display Python version
shell: bash
run: python -c "import sys; print(sys.version)"
- name: Test with pytest
shell: bash
run: |
# The instrumented extension module writes its profile data where
# cargo llvm-cov reads it.
eval "$(cargo llvm-cov show-env --sh)"
COVERAGE_PROCESS_START=$GITHUB_WORKSPACE/.coveragerc \
PYTHONPATH='.:tests' python -m pytest -r s -vs
coverage combine --append
coverage xml -i
cargo llvm-cov report --lcov --output-path rust-coverage.lcov
- name: Write the coverage summary and HTML reports
shell: bash
run: |
eval "$(cargo llvm-cov show-env --sh)"
cargo llvm-cov report --html --output-dir coverage-report
coverage html -i -d coverage-report/python
{
echo "## Coverage (Python ${{ matrix.python_version }})"
echo "### Rust code"
echo '```'
cargo llvm-cov report --summary-only
echo '```'
echo "### Python code"
coverage report -i --format=markdown
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload the HTML coverage reports
uses: actions/upload-artifact@v6
with:
name: coverage-report-${{ matrix.python_version }}
path: coverage-report
- name: Publish coverage results
uses: codecov/codecov-action@v7
with:
files: ./rust-coverage.lcov,./coverage.xml
disable_search: true
name: ${{ matrix.python_version }}
use_oidc: true