Skip to content

Commit 5197b96

Browse files
Add back bespoke Python tests
1 parent 66c103c commit 5197b96

2 files changed

Lines changed: 50 additions & 91 deletions

File tree

.github/workflows/tests.yml

Lines changed: 49 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -49,96 +49,6 @@ jobs:
4949
os: [ macos-latest, ubuntu-24.04, windows-latest ]
5050

5151

52-
53-
# test:
54-
# name: Python
55-
# runs-on: ${{ matrix.os }}
56-
# strategy:
57-
# fail-fast: false
58-
# matrix:
59-
# python: [ 3.11, 3.13 ]
60-
# os: [ macos-latest, ubuntu-24.04, windows-latest ]
61-
# defaults:
62-
# run:
63-
# shell: bash
64-
# steps:
65-
# - name: Cancel Previous Runs
66-
# uses: styfle/cancel-workflow-action@0.13.0
67-
# with:
68-
# access_token: ${{ github.token }}
69-
70-
# - name: Checkout
71-
# uses: actions/checkout@v6.0.2
72-
73-
# - name: Install OSX libs
74-
# if: matrix.os == 'macos-latest'
75-
# run: |
76-
# brew install libxml2 libxslt
77-
78-
# - name: Fix windows symlinks
79-
# working-directory: python
80-
# if: matrix.os == 'windows-latest'
81-
# run: |
82-
# rm -r lib
83-
# mkdir lib
84-
# cp -r --dereference ../c/subprojects lib/.
85-
# cp -r --dereference ../c/tskit lib/.
86-
# cp ../c/tskit.h lib/.
87-
88-
# - name: Install uv and set the python version
89-
# uses: astral-sh/setup-uv@v7
90-
# with:
91-
# python-version: ${{ matrix.python }}
92-
# version: "0.8.15"
93-
94-
# - name: Install dependencies
95-
# working-directory: python
96-
# run: uv sync --locked --group test
97-
98-
# - name: Minidom test
99-
# working-directory: python
100-
# # Importing either IPython or pytest causes import of xml.dom.minidom
101-
# # So to actually test that tskit imports it, we need a minimal test
102-
# run: |
103-
# uv run python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
104-
105-
# - name: Run JIT code coverage
106-
# run: |
107-
# NUMBA_DISABLE_JIT=1 uv run --project=python \
108-
# pytest --cov=tskit --cov-report=xml --cov-branch -n2 \
109-
# python/tests/test_jit.py
110-
111-
# - name: Upload coverage to Codecov
112-
# uses: codecov/codecov-action@v5.5.2
113-
# with:
114-
# token: ${{ secrets.CODECOV_TOKEN }}
115-
# working-directory: python
116-
# fail_ci_if_error: false
117-
# files: coverage.xml
118-
# disable_search: true
119-
# verbose: true
120-
# flags: python-tests-no-jit
121-
122-
# - name: Run tests
123-
# run: |
124-
# if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
125-
# uv run --project=python \
126-
# pytest --cov=tskit --skip-slow --cov-report=xml --cov-branch -n2 python/tests
127-
# else
128-
# uv run --project=python \
129-
# pytest --cov=tskit --cov-report=xml --cov-branch -n2 python/tests
130-
# fi
131-
132-
# - name: Upload coverage to Codecov
133-
# uses: codecov/codecov-action@v5.5.2
134-
# with:
135-
# token: ${{ secrets.CODECOV_TOKEN }}
136-
# fail_ci_if_error: false
137-
# flags: python-tests
138-
# files: coverage.xml
139-
# disable_search: true
140-
# verbose: true
141-
14252
msys2:
14353
runs-on: windows-latest
14454
strategy:
@@ -181,3 +91,52 @@ jobs:
18191
working-directory: c
18292
run: |
18393
ninja -C build test
94+
95+
bespoke-python-test:
96+
name: Bespoke Python tests
97+
runs-on: ubuntu-24.04
98+
99+
steps:
100+
- name: Cancel Previous Runs
101+
uses: styfle/cancel-workflow-action@0.13.0
102+
with:
103+
access_token: ${{ github.token }}
104+
105+
- name: Checkout
106+
uses: actions/checkout@v6.0.2
107+
with:
108+
submodules: true
109+
110+
- name: Install uv and set the python version
111+
uses: astral-sh/setup-uv@v6
112+
with:
113+
python-version: 3.11
114+
version: "0.8.15"
115+
116+
- name: Install Python dependencies
117+
run: uv sync --project=${{ inputs.pyproject-directory }} --locked --group test --no-default-groups
118+
119+
- name: Minidom test
120+
working-directory: python
121+
# Importing either IPython or pytest causes import of xml.dom.minidom
122+
# So to actually test that tskit imports it, we need a minimal test
123+
run: |
124+
uv run --locked --group test --no-default-groups \
125+
python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
126+
127+
- name: Run JIT code coverage
128+
run: |
129+
NUMBA_DISABLE_JIT=1 uv run --locked --project=python --no-default-groups\
130+
pytest --cov=python/tskit --cov-report=xml --cov-branch \
131+
python/tests/test_jit.py
132+
133+
- name: Upload coverage to Codecov
134+
uses: codecov/codecov-action@v5.5.2
135+
with:
136+
token: ${{ secrets.CODECOV_TOKEN }}
137+
fail_ci_if_error: true
138+
files: coverage.xml
139+
disable_search: true
140+
verbose: true
141+
flags: python-tests-no-jit
142+

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ ignore = [
138138
"PT009", # pytest.raises(ValueError) too broad
139139
"PT011", # pytest.raises(ValueError) too broad
140140
"PT012", # pytest.raises() block should contain a single simple statement
141-
"B018", # Found useless expression. Either assign it
142141
# "B028", # No stacklevel for warnings
142+
"B018", # Found useless expression. Either assign it
143143
"PT031", # `pytest.warns()` block should contain a single simple statement
144144
]
145145

0 commit comments

Comments
 (0)