-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.13 KB
/
python-unit-test.yml
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
# .github/workflows/python-unit-test.yml
name: Run python unit tests
on:
workflow_call:
inputs:
runs-on:
type: string
description: 'The type of runner that the job will run on'
required: false
default: 'windows-latest'
python-version-path:
type: string
description: 'The path to the python version file'
required: false
default: ".python-version"
run-coverage:
type: boolean
description: 'Whether to run test coverage'
required: false
default: false
jobs:
setup-matrix:
runs-on: ${{ inputs.runs-on }}
outputs:
python-versions: ${{ steps.set_python_versions_matrix.outputs.python-versions }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: AllenNeuralDynamics/Aind.Behavior.GitHubActions
path: action-repo
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Run Python Script
id: set_python_versions_matrix
shell: bash
run: |
python_version=$(uv run python action-repo/.github/workflows/get_python_version.py ${{ inputs.python-version-path }})
echo "python-versions=$python_version" >> $GITHUB_OUTPUT
tests:
needs: setup-matrix
runs-on: ${{ inputs.runs-on }}
strategy:
matrix:
python-version: ${{ fromJSON(needs['setup-matrix'].outputs['python-versions']).python-version }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Check if uv.lock is up-to-date
run: uv lock --check
- name: Install dependencies
run: uv sync --extra dev
- name: Run tests
shell: bash
run: |
if [ "${{ inputs.run-coverage }}" = "true" ]; then
uv run -m coverage run -m unittest
uv run -m coverage report
else
uv run -m unittest
fi