-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (171 loc) · 5.27 KB
/
python.yml
File metadata and controls
185 lines (171 loc) · 5.27 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Python checks
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
# Get changed files and store them in outputs
changed-files:
runs-on: ubuntu-latest
name: Get changed files
outputs:
any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }}
all_changed_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v4
- name: Get changed python files
id: raw-changed-python-files
uses: tj-actions/changed-files@v46
with:
files: |
**.py
**.ipynb
pyproject.toml
uv.lock
- name: Check changed python files
id: changed-python-files
env:
CHANGED_PYTHON_FILES: ${{ steps.raw-changed-python-files.outputs.all_changed_files }}
run: |
echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"
lint:
name: Check style with Ruff
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync --group lint
- name: Check style with Ruff
run: |
uv run ruff check --output-format=github .
format:
name: Check format with Ruff
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync --group lint
- name: Check format with Ruff
run: |
uv run ruff format --check --diff .
verify-nbstripout:
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync --group lint
- name: Check all notebooks
run: |
set -euo pipefail
mapfile -d '' notebooks < <(find . -name '*.ipynb' -print0)
if [ "${#notebooks[@]}" -eq 0 ]; then
echo "No notebooks found."
exit 0
fi
failed=0
for nb in "${notebooks[@]}"; do
if uv run nbstripout --verify --keep-output "${nb}"; then
echo "OK ${nb}"
else
echo "FAIL ${nb}"
failed=1
fi
done
exit "${failed}"
mypy:
name: Check type hints with mypy
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync --all-extras
- name: Check type hints with mypy
run: |
uv run mypy --show-error-codes --check-untyped-defs --config-file ./pyproject.toml ./
mypy-notebooks:
name: Check notebook type hints with mypy
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync --all-extras
uv pip install jupyter
- name: Check notebook type hints with mypy
run: |
./.github/workflows/mypy_notebooks.sh
test:
name: Run tests
runs-on: [self-hosted, linux]
needs: changed-files
if: needs.changed-files.outputs.any_python_changed == 'true'
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
env:
PYTEST_ADDOPTS: "--color=yes"
steps:
- uses: actions/checkout@v6
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --all-extras
source .venv/bin/activate
- name: Test with coverage
run: |
uv run pytest --cov=plistsync --cov-report xml:coverage.xml --junitxml=junit.xml -o junit_family=legacy -v
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
docs:
name: Build Sphinx docs
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
- name: Install docs dependencies
run: |
uv sync --group docs
- name: Build Sphinx docs
run: |
cd docs
uv run sphinx-build -b html . _build/html -W --keep-going -j auto