Repository navigation
194 lines (154 loc) · 5.71 KB
/
Copy pathci.yml
File metadata and controls
194 lines (154 loc) · 5.71 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
name: CI
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}
# no permissions by default, the release job grants itself what it needs
permissions: {}
env:
COLUMNS: 150
UV_FROZEN: '1'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: '3.12'
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- run: uv sync --group dev
- run: make lint
docs-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: '3.12'
enable-cache: false
- run: uv sync --group docs
- run: make docs
- name: Store docs site
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: docs
path: site
test:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
- run: uv sync --group dev
- run: uv pip freeze
- run: mkdir coverage
- name: test with extras
run: uv run coverage run -m pytest
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-with-extras
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-extras
- name: uninstall extras
run: uv pip uninstall multidict numpy pydantic asyncpg sqlalchemy
- name: test without extras
run: uv run coverage run -m pytest
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-extras
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-extras
- name: Store coverage files
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage
include-hidden-files: true
coverage-combine:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: '3.12'
enable-cache: false
- name: Get coverage files
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
merge-multiple: true
pattern: coverage-*
path: coverage
- run: uv sync --group dev
- run: ls -la coverage
- run: uv run coverage combine coverage
- run: uv run coverage report
- run: uv run coverage html --show-contexts --title "devtools coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-html
path: htmlcov
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test, lint, docs-build, coverage-combine]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # release/v1
with:
jobs: ${{ toJSON(needs) }}
release:
needs:
- check
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release
permissions:
# for trusted publishing to PyPI
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: '3.12'
enable-cache: false
- name: get docs
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: docs
path: site
- name: check GITHUB_REF matches package version
id: check-tag
uses: samuelcolvin/check-python-version@17d859ba0a6af9ffcaac5c70608fed36ed33e32a # v5.1
with:
version_file_path: pyproject.toml
- run: uv build
- name: upload to pypi
run: uv publish --trusted-publishing always
- name: publish docs
if: '!fromJSON(steps.check-tag.outputs.IS_PRERELEASE)'
uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
with:
apiToken: ${{ secrets.cloudflare_api_token }}
accountId: ${{ secrets.cloudflare_account_id }}
command: pages deploy --project-name=python-devtools --branch=main site