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
@@ -56,114 +61,134 @@ jobs:
5661 fail-fast : false
5762 matrix :
5863 os : [ubuntu-latest, macos-latest, windows-latest]
59- python-version : ['3.7', '3.8', '3.9', '3.10', '3.11']
60- exclude :
61- - os : macos-latest
62- python-version : ' 3.7'
63- include :
64- - os : macos-13
65- python-version : ' 3.7'
66-
67- env :
68- PYTHON : ${{ matrix.python-version }}
69- OS : ${{ matrix.os }}
70- EXTRAS : yes
64+ python-version : ['3.10', '3.11', '3.12', '3.13', '3.14']
7165
7266 runs-on : ${{ matrix.os }}
7367
7468 steps :
75- - uses : actions/checkout@v3
69+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
70+ with :
71+ persist-credentials : false
7672
77- - name : set up python
78- uses : actions/setup-python@v4
73+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
7974 with :
8075 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
8179
82- - run : pip install -r requirements/testing.txt -r requirements/pyproject.txt
80+ - run : uv pip freeze
8381
84- - run : pip freeze
82+ - run : mkdir coverage
8583
8684 - name : test with extras
87- 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
8889
89- - run : coverage xml
90+ - name : uninstall extras
91+ run : uv pip uninstall multidict numpy pydantic asyncpg sqlalchemy
9092
91- - 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
92101 with :
93- file : ./coverage.xml
94- env_vars : EXTRAS,PYTHON,OS
102+ name : coverage-${{ matrix.os }}-${{ matrix.python-version }}
103+ path : coverage
104+ include-hidden-files : true
95105
96- - name : uninstall extras
97- run : pip uninstall -y multidict numpy pydantic asyncpg sqlalchemy
106+ coverage-combine :
107+ needs : [test]
108+ runs-on : ubuntu-latest
98109
99- - name : test without extras
100- run : make test
110+ steps :
111+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
112+ with :
113+ persist-credentials : false
101114
102- - run : coverage xml
115+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
116+ with :
117+ python-version : ' 3.12'
118+ enable-cache : false
103119
104- - uses : codecov/codecov-action@v3
105- with :
106- file : ./coverage.xml
107- env_vars : EXTRAS,PYTHON,OS
108- env :
109- 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
110139
111140 # https://github.com/marketplace/actions/alls-green#why used for branch protection checks
112141 check :
113142 if : always()
114- needs : [test, lint, docs-build]
143+ needs : [test, lint, docs-build, coverage-combine ]
115144 runs-on : ubuntu-latest
116145 steps :
117146 - name : Decide whether the needed jobs succeeded or failed
118- uses : re-actors/alls-green@release/v1
147+ uses : re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # release/v1
119148 with :
120149 jobs : ${{ toJSON(needs) }}
121150
122- deploy :
151+ release :
123152 needs :
124153 - check
125154 if : " success() && startsWith(github.ref, 'refs/tags/')"
126155 runs-on : ubuntu-latest
156+ environment : release
157+ permissions :
158+ # for trusted publishing to PyPI
159+ id-token : write
127160
128161 steps :
129- - uses : actions/checkout@v3
162+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
163+ with :
164+ persist-credentials : false
130165
131- - name : set up python
132- uses : actions/setup-python@v4
166+ - uses : astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
133167 with :
134- python-version : ' 3.10'
168+ python-version : ' 3.12'
169+ enable-cache : false
135170
136171 - name : get docs
137- uses : actions/download-artifact@v3
172+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
138173 with :
139174 name : docs
140175 path : site
141176
142177 - name : check GITHUB_REF matches package version
143178 id : check-tag
144- uses : samuelcolvin/check-python-version@v4 .1
179+ uses : samuelcolvin/check-python-version@17d859ba0a6af9ffcaac5c70608fed36ed33e32a # v5 .1
145180 with :
146- version_file_path : devtools/version.py
147-
148- - name : install
149- run : pip install build twine
150-
151- - name : build
152- run : python -m build
181+ version_file_path : pyproject.toml
153182
154- - run : twine check dist/*
183+ - run : uv build
155184
156185 - name : upload to pypi
157- run : twine upload dist/*
158- env :
159- TWINE_USERNAME : __token__
160- TWINE_PASSWORD : ${{ secrets.pypi_token }}
186+ run : uv publish --trusted-publishing always
161187
162188 - name : publish docs
163189 if : ' !fromJSON(steps.check-tag.outputs.IS_PRERELEASE)'
164- uses : cloudflare/wrangler-action@2.0.0
190+ uses : cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
165191 with :
166192 apiToken : ${{ secrets.cloudflare_api_token }}
167- command : pages publish --project-name=python-devtools --branch=main site
168- env :
169- 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