-
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) Β· 2.64 KB
/
reusable-python.yml
File metadata and controls
100 lines (89 loc) Β· 2.64 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
name: Reusable Python Workflow
on:
workflow_call:
inputs:
python-version:
description: Python version to use
required: false
type: string
default: '3.11'
install-system-deps:
description: Install Linux system dependencies and unlock keyring
required: false
type: boolean
default: true
install-extras:
description: Optional extras to install from pyproject (for example test,typing)
required: false
type: string
default: ''
extra-packages:
description: Optional extra packages to install with uv pip
required: false
type: string
default: ''
run-tests:
description: Run tests
required: false
type: boolean
default: false
test-command:
description: Test command to run when run-tests=true
required: false
type: string
default: 'pytest -q'
run-mypy:
description: Run mypy
required: false
type: boolean
default: false
mypy-target:
description: Package/module path to type-check
required: false
type: string
default: ''
run-pre-commit:
description: Run pre-commit
required: false
type: boolean
default: false
jobs:
python-checks:
runs-on: ubuntu-latest
steps:
- name: Install system dependencies
if: inputs.install-system-deps
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-3 libdbus-1-dev libglib2.0-dev
- name: Checkout
uses: actions/checkout@v6
- name: Setup UV
uses: astral-sh/setup-uv@v7
with:
version: latest
python-version: ${{ inputs.python-version }}
activate-environment: true
- name: Install dependencies
run: |
uv pip install .
if [[ -n "${{ inputs.install-extras }}" ]]; then
uv pip install ".[${{ inputs.install-extras }}]"
fi
if [[ -n "${{ inputs.extra-packages }}" ]]; then
uv pip install ${{ inputs.extra-packages }}
fi
- name: Unlock keyring
if: inputs.install-system-deps
uses: t1m0thyj/unlock-keyring@v1
- name: Configure git to use https
run: git config --global hub.protocol https
- name: Run tests
if: inputs.run-tests
run: ${{ inputs.test-command }}
- name: Run mypy
if: inputs.run-mypy
run: mypy ${{ inputs.mypy-target }}
- name: Run pre-commit
if: inputs.run-pre-commit
run: pre-commit run --all-files