Skip to content

Commit 797d631

Browse files
authored
Merge branch 'main' into update-readme
2 parents 7b3e569 + 4096b67 commit 797d631

45 files changed

Lines changed: 2440 additions & 1464 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.codecov.yml‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎.github/workflows/ci.yml‎

Lines changed: 100 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,49 @@ on:
88
- '**'
99
pull_request: {}
1010

11+
# no permissions by default, the release job grants itself what it needs
12+
permissions: {}
13+
1114
env:
1215
COLUMNS: 150
16+
UV_FROZEN: '1'
1317

1418
jobs:
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
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Upload previews
2+
3+
on: # zizmor: ignore[dangerous-triggers] -- workflow_run is used safely here; no code checkout occurs
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
7+
8+
permissions:
9+
# smokeshow sets a commit status with the coverage result
10+
statuses: write
11+
12+
jobs:
13+
upload-previews:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# DO NOT run actions/checkout here, for security reasons
19+
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
20+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
21+
with:
22+
python-version: '3.12'
23+
24+
- run: pip install smokeshow
25+
26+
- uses: dawidd6/action-download-artifact@eab87c9830c39eff17e5a6eadb20bfb4bc880477 # v27
27+
with:
28+
workflow: ci.yml
29+
commit: ${{ github.event.workflow_run.head_sha }}
30+
31+
- run: smokeshow upload coverage-html
32+
env:
33+
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
34+
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90
35+
SMOKESHOW_GITHUB_CONTEXT: coverage
36+
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
38+
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ old-version/
1818
/site/
1919
/site.zip
2020
/build/
21+
.venv/

‎.pre-commit-config.yaml‎

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
4-
hooks:
5-
- id: check-yaml
6-
- id: check-toml
7-
- id: end-of-file-fixer
8-
- id: trailing-whitespace
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-yaml
6+
- id: check-toml
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
99

10-
- repo: local
11-
hooks:
12-
- id: ruff
13-
name: Ruff
14-
entry: ruff
15-
args: [--fix, --exit-non-zero-on-fix]
16-
types: [python]
17-
language: system
18-
files: ^devtools/|^tests/
19-
- id: black
20-
name: Black
21-
entry: black
22-
types: [python]
23-
language: system
24-
files: ^devtools/|^tests/
25-
exclude: test_expr_render.py
10+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
11+
rev: v1.30.1
12+
hooks:
13+
- id: zizmor
14+
15+
- repo: local
16+
hooks:
17+
- id: format
18+
name: Format
19+
entry: make
20+
args: [format]
21+
types: [python]
22+
language: system
23+
pass_filenames: false
24+
- id: lint
25+
name: Lint
26+
entry: make
27+
args: [lint]
28+
types: [python]
29+
language: system
30+
pass_filenames: false

0 commit comments

Comments
 (0)