-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (71 loc) · 2.37 KB
/
python-tests.yml
File metadata and controls
80 lines (71 loc) · 2.37 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
name: Reusable Python Tests
on:
workflow_call:
inputs:
python-version:
description: 'Python version to use'
required: true
type: string
os:
description: 'Operating system to run on'
required: true
type: string
pyproject-directory:
description: 'Directory to find pyproject.toml'
required: false
type: string
default: '.'
coverage-directory:
description: 'Directory to calculate coverage for'
required: true
type: string
fix-lwt-symlink:
description: 'Fix the lwt symlinks on windows'
required: false
type: string
default: "false"
jobs:
test:
name: Unit tests
runs-on: ${{ inputs.os }}
defaults:
run:
shell: bash
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4.2.2
with:
submodules: true
- name: Fix windows symlinks
if: ${{ inputs.fix-lwt-symlink == 'true' && runner.os == 'Windows' }}
run: |
rm lwt_interface
cp -r --dereference git-submodules/tskit/python/lwt_interface ./lwt_interface
- name: Install additional APT packages
if: ${{ inputs.additional-apt-packages != '' }}
run: sudo apt-get update && sudo apt-get install -y ${{ inputs.additional-apt-packages }}
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
version: "0.10.0"
- name: Install test deps
run: uv sync --project=${{ inputs.pyproject-directory }} --locked --group test --no-default-groups
- name: Run tests
run: |
uv run --project=${{ inputs.pyproject-directory }} --locked --group test --no-default-groups \
pytest --cov-report=xml --cov-branch -n2 --cov=${{ inputs.coverage-directory }} \
${{ inputs.pyproject-directory }}/tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: python-tests
files: coverage.xml
disable_search: true
verbose: true