88 - ' **'
99 pull_request : {}
1010
11+ # no permissions by default, the release job grants itself what it needs
12+ permissions : {}
13+
1114env :
1215 COLUMNS : 150
16+ UV_FROZEN : ' 1'
1317
1418jobs :
1519 lint :
1620 runs-on : ubuntu-latest
1721
1822 steps :
19- - uses : actions/checkout@v3
20-
21- - uses : actions/setup-python@v4
23+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2224 with :
23- python-version : ' 3.10 '
25+ persist-credentials : false
2426
25- - run : pip install -r requirements/linting.txt -r requirements/pyproject.txt
27+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
28+ with :
29+ python-version : ' 3.12'
30+ enable-cache : true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
2631
27- - run : mypy devtools
32+ - run : uv sync --group dev
2833
29- - uses : pre-commit/action@v3.0.0
30- with :
31- extra_args : --all-files --verbose
34+ - run : make lint
3235
3336 docs-build :
3437 runs-on : ubuntu-latest
3538 steps :
36- - uses : actions/checkout@v3
39+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40+ with :
41+ persist-credentials : false
3742
38- - uses : actions /setup-python@v4
43+ - uses : astral-sh /setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
3944 with :
40- python-version : ' 3.10'
45+ python-version : ' 3.12'
46+ enable-cache : false
4147
42- - run : pip install -r requirements/docs.txt -r requirements/pyproject.txt
43- - run : pip install .
48+ - run : uv sync --group docs
4449
4550 - run : make docs
4651
4752 - name : Store docs site
48- uses : actions/upload-artifact@v3
53+ uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
4954 with :
5055 name : docs
5156 path : site
@@ -55,109 +60,135 @@ jobs:
5560 strategy :
5661 fail-fast : false
5762 matrix :
58- os : [ubuntu, macos, windows]
59- python-version : ['3.7', '3.8', '3.9', '3.10', '3.11']
60-
61- env :
62- PYTHON : ${{ matrix.python-version }}
63- OS : ${{ matrix.os }}
64- EXTRAS : yes
63+ os : [ubuntu-latest, macos-latest, windows-latest]
64+ python-version : ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15']
6565
66- runs-on : ${{ matrix.os }}-latest
66+ runs-on : ${{ matrix.os }}
6767
6868 steps :
69- - uses : actions/checkout@v3
69+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
70+ with :
71+ persist-credentials : false
7072
71- - name : set up python
72- uses : actions/setup-python@v4
73+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
7374 with :
7475 python-version : ${{ matrix.python-version }}
76+ enable-cache : true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions
77+
78+ - run : uv sync --group dev
7579
76- - run : pip install -r requirements/testing.txt -r requirements/pyproject.txt
80+ - run : uv pip freeze
7781
78- - run : pip freeze
82+ - run : mkdir coverage
7983
8084 - name : test with extras
81- run : make test
85+ run : uv run coverage run -m pytest
86+ env :
87+ COVERAGE_FILE : coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-with-extras
88+ CONTEXT : ${{ runner.os }}-py${{ matrix.python-version }}-with-extras
8289
83- - run : coverage xml
90+ - name : uninstall extras
91+ run : uv pip uninstall multidict numpy pydantic asyncpg sqlalchemy
8492
85- - uses : codecov/codecov-action@v3
93+ - name : test without extras
94+ run : uv run coverage run -m pytest
95+ env :
96+ COVERAGE_FILE : coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-extras
97+ CONTEXT : ${{ runner.os }}-py${{ matrix.python-version }}-without-extras
98+
99+ - name : Store coverage files
100+ uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
86101 with :
87- file : ./coverage.xml
88- env_vars : EXTRAS,PYTHON,OS
102+ name : coverage-${{ matrix.os }}-${{ matrix.python-version }}
103+ path : coverage
104+ include-hidden-files : true
89105
90- - name : uninstall extras
91- run : pip uninstall -y multidict numpy pydantic asyncpg sqlalchemy
106+ coverage-combine :
107+ needs : [test]
108+ runs-on : ubuntu-latest
92109
93- - name : test without extras
94- run : make test
110+ steps :
111+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
112+ with :
113+ persist-credentials : false
95114
96- - run : coverage xml
115+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
116+ with :
117+ python-version : ' 3.12'
118+ enable-cache : false
97119
98- - uses : codecov/codecov-action@v3
99- with :
100- file : ./coverage.xml
101- env_vars : EXTRAS,PYTHON,OS
102- env :
103- EXTRAS : no
120+ - name : Get coverage files
121+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
122+ with :
123+ merge-multiple : true
124+ pattern : coverage-*
125+ path : coverage
126+
127+ - run : uv sync --group dev
128+
129+ - run : ls -la coverage
130+ - run : uv run coverage combine coverage
131+ - run : uv run coverage report
132+ - run : uv run coverage html --show-contexts --title "devtools coverage for ${{ github.sha }}"
133+
134+ - name : Store coverage HTML
135+ uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
136+ with :
137+ name : coverage-html
138+ path : htmlcov
104139
105140 # https://github.com/marketplace/actions/alls-green#why used for branch protection checks
106141 check :
107142 if : always()
108- needs : [test, lint, docs-build]
143+ needs : [test, lint, docs-build, coverage-combine ]
109144 runs-on : ubuntu-latest
110145 steps :
111146 - name : Decide whether the needed jobs succeeded or failed
112- uses : re-actors/alls-green@release/v1
147+ uses : re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # release/v1
113148 with :
114149 jobs : ${{ toJSON(needs) }}
115150
116- deploy :
151+ release :
117152 needs :
118153 - check
119154 if : " success() && startsWith(github.ref, 'refs/tags/')"
120155 runs-on : ubuntu-latest
156+ environment : release
157+ permissions :
158+ # for trusted publishing to PyPI
159+ id-token : write
121160
122161 steps :
123- - uses : actions/checkout@v3
162+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
163+ with :
164+ persist-credentials : false
124165
125- - name : set up python
126- uses : actions/setup-python@v4
166+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
127167 with :
128- python-version : ' 3.10'
168+ python-version : ' 3.12'
169+ enable-cache : false
129170
130171 - name : get docs
131- uses : actions/download-artifact@v3
172+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
132173 with :
133174 name : docs
134175 path : site
135176
136177 - name : check GITHUB_REF matches package version
137178 id : check-tag
138- uses : samuelcolvin/check-python-version@v4 .1
179+ uses : samuelcolvin/check-python-version@17d859ba0a6af9ffcaac5c70608fed36ed33e32a # v5 .1
139180 with :
140- version_file_path : devtools/version.py
141-
142- - name : install
143- run : pip install build twine
144-
145- - name : build
146- run : python -m build
181+ version_file_path : pyproject.toml
147182
148- - run : twine check dist/*
183+ - run : uv build
149184
150185 - name : upload to pypi
151- run : twine upload dist/*
152- env :
153- TWINE_USERNAME : __token__
154- TWINE_PASSWORD : ${{ secrets.pypi_token }}
186+ run : uv publish --trusted-publishing always
155187
156188 - name : publish docs
157189 if : ' !fromJSON(steps.check-tag.outputs.IS_PRERELEASE)'
158- uses : cloudflare/wrangler-action@2.0.0
190+ uses : cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
159191 with :
160192 apiToken : ${{ secrets.cloudflare_api_token }}
161- command : pages publish --project-name=python-devtools --branch=main site
162- env :
163- CLOUDFLARE_ACCOUNT_ID : ${{ secrets.cloudflare_account_id }}
193+ accountId : ${{ secrets.cloudflare_account_id }}
194+ command : pages deploy --project-name=python-devtools --branch=main site
0 commit comments