-
Notifications
You must be signed in to change notification settings - Fork 4
192 lines (186 loc) · 5.88 KB
/
Copy pathtest-and-publish.yml
File metadata and controls
192 lines (186 loc) · 5.88 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
186
187
188
189
190
191
192
name: Test and Publish
on:
pull_request:
push:
branches:
- main
- develop
- feature-*
schedule:
- cron: "0 7 * * *"
release:
types:
- published
jobs:
docs-check:
name: Docs Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.9.18
python-version: "3.11"
enable-cache: true
cache-suffix: test-and-publish
cache-dependency-glob: uv.lock
- name: Synchronize project dependencies
run: uv sync --group dev
- name: Build docs with MkDocs
run: uv run mkdocs build --strict
- name: Upload docs preview artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docs-site
path: site/
retention-days: 7
tests:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
permissions:
id-token: write
contents: read
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.9.18
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-suffix: test-and-publish
cache-dependency-glob: uv.lock
- name: Run tests with nox
run: uvx nox --python ${{ matrix.python-version }} --session tests -- -n 5 -m "not live"
- name: Fetch base branch for diff-cover
if: github.event_name == 'pull_request'
run: |
if git rev-parse --is-shallow-repository | grep -q true; then
git fetch --no-tags --prune origin ${{ github.base_ref }} --unshallow
else
git fetch --no-tags --prune origin ${{ github.base_ref }}
fi
- name: Run diff-cover (new code must be >= 90%)
if: github.event_name == 'pull_request'
run: >
uv run diff-cover coverage/py${{ matrix.python-version }}/coverage.xml
--compare-branch origin/${{ github.base_ref }}
--fail-under 90
--format markdown:coverage/py${{ matrix.python-version }}/diff-cover.md
- name: Check client class function coverage
run: >
uv run python scripts/check_class_function_coverage.py
coverage/py${{ matrix.python-version }}/coverage.json
--class PdfRestClient
--class AsyncPdfRestClient
--class _FilesClient
--class _AsyncFilesClient
--fail-under 90
--markdown-report coverage/py${{ matrix.python-version }}/class-function-coverage.md
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage/py${{ matrix.python-version }}
live-tests:
name: Live Tests (Python 3.11)
if: github.event_name == 'pull_request' || github.event_name == 'schedule'
runs-on: ubuntu-latest
environment: ci-live
permissions:
id-token: write
contents: read
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.9.18
python-version: "3.11"
enable-cache: true
cache-suffix: test-and-publish
cache-dependency-glob: uv.lock
- name: Run live tests with nox
run: uvx nox --python 3.11 --session tests -- -n 5 -m live
env:
PDFREST_API_KEY: ${{ secrets.PDFREST_API_KEY }}
- name: Upload live coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-live-3.11
path: coverage/py3.11
examples:
name: Examples (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
environment: ci-live
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
permissions:
id-token: write
contents: read
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.9.18
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-suffix: test-and-publish
cache-dependency-glob: uv.lock
- name: Run examples with nox
run: uvx nox --python ${{ matrix.python-version }} --session examples
env:
PDFREST_API_KEY: ${{ secrets.PDFREST_API_KEY }}
publish:
name: Publish to PyPI
needs:
- docs-check
- tests
- examples
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
env:
UV_PROJECT_ENVIRONMENT: .venv-release
UV_TRUSTED_PUBLISHING: always
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.9.18
enable-cache: true
cache-suffix: pre-commit
cache-dependency-glob: uv.lock
- name: Restore venv cache
uses: actions/cache@v4
with:
path: |
${{ env.UV_PROJECT_ENVIRONMENT }}
key: ${{ runner.os }}-uv-release-${{ hashFiles('pyproject.toml') }}
- name: Synchronize project dependencies
run: uv sync --group dev
- name: Build distribution artifacts
run: uv build --python 3.11
- name: Publish package to PyPI (Trusted Publishing)
run: uv publish --trusted-publishing always --keyring-provider disabled