1
+ name : Reusable Python Tests
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ additional_commands :
7
+ description : ' Additional commands to run after installing dependencies'
8
+ required : false
9
+ type : string
10
+ default : ' '
11
+ make_command :
12
+ description : ' Make/build command to run'
13
+ required : false
14
+ type : string
15
+ default : ' '
16
+
17
+ jobs :
18
+ test :
19
+ name : Python
20
+ runs-on : ${{ matrix.os }}
21
+ defaults :
22
+ run :
23
+ shell : bash
24
+ steps :
25
+ - name : Cancel Previous Runs
26
+
27
+ with :
28
+ access_token : ${{ github.token }}
29
+
30
+ - name : Checkout
31
+
32
+ with :
33
+ submodules : true
34
+
35
+ - name : Determine working directory
36
+ id : workdir
37
+ run : |
38
+ if [ -d "python" ]; then
39
+ echo "dir=python" >> $GITHUB_OUTPUT
40
+ else
41
+ echo "dir=." >> $GITHUB_OUTPUT
42
+ fi
43
+
44
+ - name : Install uv and set the python version
45
+ uses : astral-sh/setup-uv@v6
46
+ with :
47
+ python-version : ${{ matrix.python }}
48
+ version : " 0.8.15"
49
+
50
+ - name : Install dependencies
51
+ working-directory : ${{ steps.workdir.outputs.dir }}
52
+ run : |
53
+ uv venv
54
+ uv pip install -r pyproject.toml --extra test
55
+
56
+ - name : Additional commands
57
+ if : ${{ inputs.additional_commands != '' }}
58
+ working-directory : ${{ steps.workdir.outputs.dir }}
59
+ run : ${{ inputs.additional_commands }}
60
+
61
+ - name : Make/build
62
+ if : ${{ inputs.make_command != '' }}
63
+ working-directory : ${{ steps.workdir.outputs.dir }}
64
+ run : ${{ inputs.make_command }}
65
+
66
+ - name : Run tests
67
+ working-directory : ${{ steps.workdir.outputs.dir }}
68
+ run : |
69
+ uv run --no-sync python -m pytest -xv --cov --cov-report=xml --cov-branch
70
+
71
+ - name : Upload coverage to Codecov
72
+
73
+ with :
74
+ token : ${{ secrets.CODECOV_TOKEN }}
75
+ working-directory : ${{ steps.workdir.outputs.dir }}
76
+ fail_ci_if_error : false
77
+ flags : python-tests
78
+ name : codecov-umbrella
79
+ verbose : true
0 commit comments