-
Notifications
You must be signed in to change notification settings - Fork 226
269 lines (232 loc) · 9.68 KB
/
main.yml
File metadata and controls
269 lines (232 loc) · 9.68 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: CI
on:
push:
branches:
- main
tags:
- "**"
pull_request: { }
env:
CI: true
# https://github.com/samuelcolvin/pytest-pretty#usage-with-github-actions
COLUMNS: 180
permissions: { }
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- name: Install dependencies
run: uv sync --python 3.12 --frozen
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --all-files --verbose
env:
SKIP: no-commit-to-branch
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- run: uv sync --python 3.12 --frozen --group docs
- run: uv pip install --upgrade mkdocs-material 'mkdocstrings-python<2.0.3' 'mkdocstrings<1' griffe==0.48.0
env:
UV_EXTRA_INDEX_URL: ${{ secrets.UV_EXTRA_INDEX_URL }}
- run: |
if [[ -n "$HEAD_REF" && "$REPOSITORY" != "$HEAD_REPO_FULL_NAME" ]]; then
uv run --no-sync mkdocs build --no-strict
else
uv run --no-sync mkdocs build
fi
env:
ALGOLIA_WRITE_API_KEY: ${{ secrets.ALGOLIA_WRITE_API_KEY }}
HEAD_REF: ${{ github.head_ref }}
REPOSITORY: ${{ github.repository }}
HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
test:
name: test on Python ${{ matrix.python-version }}, pydantic ${{ matrix.pydantic-version }}, otel ${{ matrix.otel-version }}
# Use Depot 4-core runners for maintainer PRs (faster CPUs/more cores)
# Use 'ci:slow' label to force standard GitHub runners (e.g. during Depot outages)
# Use 'ci:fast' label to opt-in fork PRs to Depot runners
runs-on: >-
${{
!contains(github.event.pull_request.labels.*.name, 'ci:slow')
&& (
github.event.pull_request.head.repo.full_name == github.repository
|| contains(github.event.pull_request.labels.*.name, 'ci:fast')
)
&& 'depot-ubuntu-24.04-4'
|| 'ubuntu-latest'
}}
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
pydantic-version: [ "2" ] # i.e. the latest
otel-version: [ "1" ] # i.e. the latest
include:
- python-version: "3.12"
pydantic-version: "2.4"
otel-version: "1" # i.e. the latest
- python-version: '3.14'
pydantic-version: '2' # i.e. the latest
otel-version: '1.39'
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Ensure requests to production domains fail
if: runner.os == 'Linux'
run: |
echo "203.0.113.0 logfire.dev" | sudo tee -a /etc/hosts
echo "203.0.113.0 logfire-api.pydantic.dev" | sudo tee -a /etc/hosts
echo "203.0.113.0 logfire.pydantic.dev" | sudo tee -a /etc/hosts
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- run: uv sync --python ${{ matrix.python-version }}
- name: Install pydantic ${{ matrix.pydantic-version }}
# installs the most recent patch on the minor version's track, ex 2.6.* -> 2.6.4
run: uv pip install 'pydantic==${{ matrix.pydantic-version }}.*'
- name: Install OTel SDK ${{ matrix.otel-version }}
# installs the most recent patch on the minor version's track, ex 2.6.* -> 2.6.4
run: |
uv pip install 'opentelemetry-sdk==${{ matrix.otel-version }}.*'
uv pip install 'opentelemetry-exporter-otlp-proto-http==${{ matrix.otel-version }}.*'
- run: mkdir coverage
- run: uv run --no-sync coverage run -m pytest --junitxml=coverage/test-results.xml
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-otel-${{ matrix.otel-version }}
- name: store coverage files
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-otel-${{ matrix.otel-version }}
path: coverage
include-hidden-files: true
coverage:
runs-on: ubuntu-latest
needs: [ test ]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- name: Create venv
run: uv venv --python 3.12
- name: get coverage files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
merge-multiple: true
path: coverage
- run: uv pip install coverage[toml]
- run: uv run coverage combine coverage
- run: uv run coverage xml
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
file: ./coverage.xml
env_vars: PYTHON
- run: uv run coverage report --fail-under 100
- name: Upload test results to Codecov
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 #v1.2.1
with:
files: coverage/test-results.xml
test-pyodide:
name: test on Pyodide
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "23"
package-manager-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- run: make test-pyodide
env:
UV_PYTHON: ${{ matrix.python-version }}
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [ lint, docs, test, coverage, test-pyodide ]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
trigger-docs:
needs: [ check ]
if: "success() && github.ref == 'refs/heads/main'"
runs-on: ubuntu-latest
steps:
- name: Generate app token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: app-token
with:
app-id: ${{ vars.DOCS_APP_ID }}
private-key: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: unified-docs
- name: Trigger unified-docs deployment
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh api repos/pydantic/unified-docs/dispatches \
--method POST \
-f event_type=docs-update \
-f "client_payload[source]=pydantic/logfire@${{ github.sha }}"
release:
needs: [ check ]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.11.1"
enable-cache: false
- name: Set up Python 3.12
run: uv python install 3.12
- name: check GITHUB_REF matches package version
uses: samuelcolvin/check-python-version@ee87cddb8049d2694cc03badc8569765a05cef00 # v5
with:
version_file_path: pyproject.toml
- name: Build artifacts
run: uv build --all
- name: Publish logfire and logfire-api to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
skip-existing: true
verbose: true