-
Notifications
You must be signed in to change notification settings - Fork 53
176 lines (176 loc) · 5.47 KB
/
lint-test-deploy.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
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
on:
push:
branches: [master, develop]
tags:
- '*'
pull_request:
workflow_dispatch:
name: Tests
env:
PYTHONWARNINGS: all
TERM: xterm-256color
jobs:
pre-commit:
name: Various quality checks with pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ vars.MAIN_PYTHON }}
- uses: pre-commit/[email protected]
env:
SKIP: "mypy,ruff"
ruff:
name: Lint with ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: ${{ vars.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
run: uv python install ${{ vars.MAIN_PYTHON }}
- name: Ruff Lint
run: uv run ruff check .
- name: Ruff Format
run: uv run ruff format .
mypy:
name: Type check with mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: ${{ vars.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
run: uv python install ${{ vars.MAIN_PYTHON }}
- run: uv run mypy .
initial-test:
name: Test One Version First
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: ${{ vars.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
run: uv python install ${{ vars.MAIN_PYTHON }}
- name: Install the project
run: uv sync --all-extras --dev
- run: uv run pytest
name: Run tests
- run: uv run coverage lcov
name: Generate coverage report for this run
- name: Upload coverage report for this run to coveralls
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: .cov/coverage.lcov
parallel: true
test:
name: Pytest via uv
needs:
- pre-commit
- ruff
- mypy
- initial-test
strategy:
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8", "pypy3.10", "3.13.0-rc.1", "3.14.0-alpha.0"]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: ubuntu-latest
python-version: ${{ vars.MAIN_PYTHON }}
#we already did this one
continue-on-error: ${{ contains(matrix.python-version,'3.13') || contains(matrix.python-version,'3.14') || (contains(matrix.python-version, 'pypy') && matrix.os == 'windows-latest')}}
runs-on: ${{ matrix.os }}
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: ${{ vars.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
if: ${{ ! (contains(matrix.python-version,'3.13') || contains(matrix.python-version,'3.14')) }}
run: uv python install ${{ matrix.python-version }}
- uses: actions/setup-python@v5
if: ${{ (contains(matrix.python-version,'3.13') || contains(matrix.python-version,'3.14')) }}
with:
python-version: ${{ matrix.python-version }}
- name: Install the project
run: uv sync --all-extras --dev
- run: uv run pytest
name: Run tests
- run: uv run coverage lcov
name: Generate coverage report for this run
- name: Upload coverage report for this run to coveralls
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: .cov/coverage.lcov
parallel: true
coveralls:
name: Finalize coveralls data
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: .cov/coverage.lcov
parallel-finished: true
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Status of final test results
needs: [test]
steps:
- run: |
result="${{ needs.test.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
build-and-publish:
name: Build and publish Python distributions to PyPI and TestPyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
permissions:
id-token: write
needs:
- pre-commit
- ruff
- mypy
- test
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: ${{ vars.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1