django-spec-html 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. django_spec_html-0.1.0/.github/CODEOWNERS +1 -0
  2. django_spec_html-0.1.0/.github/SECURITY.md +9 -0
  3. django_spec_html-0.1.0/.github/dependabot.yml +26 -0
  4. django_spec_html-0.1.0/.github/workflows/release.yml +112 -0
  5. django_spec_html-0.1.0/.github/workflows/tests.yml +374 -0
  6. django_spec_html-0.1.0/.github/workflows/upstream-drift.yml +149 -0
  7. django_spec_html-0.1.0/.gitignore +639 -0
  8. django_spec_html-0.1.0/.pre-commit-config.yaml +90 -0
  9. django_spec_html-0.1.0/CHANGELOG.md +46 -0
  10. django_spec_html-0.1.0/CLAUDE.md +225 -0
  11. django_spec_html-0.1.0/LICENSE +21 -0
  12. django_spec_html-0.1.0/Makefile +90 -0
  13. django_spec_html-0.1.0/PKG-INFO +121 -0
  14. django_spec_html-0.1.0/README.md +85 -0
  15. django_spec_html-0.1.0/django_spec_html/__init__.py +34 -0
  16. django_spec_html-0.1.0/django_spec_html/http/__init__.py +25 -0
  17. django_spec_html-0.1.0/django_spec_html/http/add_argument_errors.py +80 -0
  18. django_spec_html-0.1.0/django_spec_html/http/adispatch_request.py +97 -0
  19. django_spec_html-0.1.0/django_spec_html/http/async_spec_view.py +40 -0
  20. django_spec_html-0.1.0/django_spec_html/http/dispatch_request.py +98 -0
  21. django_spec_html-0.1.0/django_spec_html/http/error_response.py +104 -0
  22. django_spec_html-0.1.0/django_spec_html/http/request_arguments.py +362 -0
  23. django_spec_html-0.1.0/django_spec_html/http/request_principal.py +42 -0
  24. django_spec_html-0.1.0/django_spec_html/http/route_arguments.py +44 -0
  25. django_spec_html-0.1.0/django_spec_html/http/spec_view.py +64 -0
  26. django_spec_html-0.1.0/django_spec_html/http/unsupported_media_type.py +23 -0
  27. django_spec_html-0.1.0/django_spec_html/http/utils.py +266 -0
  28. django_spec_html-0.1.0/django_spec_html/py.typed +0 -0
  29. django_spec_html-0.1.0/django_spec_html/version.py +7 -0
  30. django_spec_html-0.1.0/django_spec_html/views/__init__.py +5 -0
  31. django_spec_html-0.1.0/django_spec_html/views/spec_form_view.py +529 -0
  32. django_spec_html-0.1.0/docs/__init__.py +1 -0
  33. django_spec_html-0.1.0/docs/examples/__init__.py +1 -0
  34. django_spec_html-0.1.0/docs/examples/http.py +147 -0
  35. django_spec_html-0.1.0/docs/examples/spec_form.py +140 -0
  36. django_spec_html-0.1.0/docs/http.md +314 -0
  37. django_spec_html-0.1.0/docs/index.md +40 -0
  38. django_spec_html-0.1.0/docs/pages.md +177 -0
  39. django_spec_html-0.1.0/docs/reference.md +39 -0
  40. django_spec_html-0.1.0/mkdocs.yml +98 -0
  41. django_spec_html-0.1.0/pyproject.toml +169 -0
  42. django_spec_html-0.1.0/scripts/check-changelog +162 -0
  43. django_spec_html-0.1.0/scripts/release-publish.sh +246 -0
  44. django_spec_html-0.1.0/tests/__init__.py +0 -0
  45. django_spec_html-0.1.0/tests/adapter_app/__init__.py +0 -0
  46. django_spec_html-0.1.0/tests/adapter_app/apps.py +8 -0
  47. django_spec_html-0.1.0/tests/adapter_app/models.py +68 -0
  48. django_spec_html-0.1.0/tests/conftest.py +107 -0
  49. django_spec_html-0.1.0/tests/conftest_settings.py +61 -0
  50. django_spec_html-0.1.0/tests/dispatch/__init__.py +0 -0
  51. django_spec_html-0.1.0/tests/dispatch/utils.py +176 -0
  52. django_spec_html-0.1.0/tests/dispatch_app/__init__.py +0 -0
  53. django_spec_html-0.1.0/tests/dispatch_app/apps.py +8 -0
  54. django_spec_html-0.1.0/tests/dispatch_app/models.py +26 -0
  55. django_spec_html-0.1.0/tests/docs/__init__.py +1 -0
  56. django_spec_html-0.1.0/tests/docs/test_http_examples.py +209 -0
  57. django_spec_html-0.1.0/tests/docs/test_spec_form_examples.py +245 -0
  58. django_spec_html-0.1.0/tests/http/__init__.py +0 -0
  59. django_spec_html-0.1.0/tests/http/test_add_argument_errors.py +187 -0
  60. django_spec_html-0.1.0/tests/http/test_adispatch_request.py +206 -0
  61. django_spec_html-0.1.0/tests/http/test_async_spec_view.py +148 -0
  62. django_spec_html-0.1.0/tests/http/test_dispatch_request.py +391 -0
  63. django_spec_html-0.1.0/tests/http/test_error_response.py +227 -0
  64. django_spec_html-0.1.0/tests/http/test_request_arguments.py +806 -0
  65. django_spec_html-0.1.0/tests/http/test_request_principal.py +46 -0
  66. django_spec_html-0.1.0/tests/http/test_route_arguments.py +49 -0
  67. django_spec_html-0.1.0/tests/http/test_spec_view.py +216 -0
  68. django_spec_html-0.1.0/tests/http/test_unsupported_media_type.py +59 -0
  69. django_spec_html-0.1.0/tests/http/test_utils.py +120 -0
  70. django_spec_html-0.1.0/tests/http/utils.py +136 -0
  71. django_spec_html-0.1.0/tests/templates/spec_form.html +1 -0
  72. django_spec_html-0.1.0/tests/test_conftest.py +84 -0
  73. django_spec_html-0.1.0/tests/test_init.py +84 -0
  74. django_spec_html-0.1.0/tests/test_kernel_copy_references.py +287 -0
  75. django_spec_html-0.1.0/tests/views/__init__.py +0 -0
  76. django_spec_html-0.1.0/tests/views/test_spec_form_view.py +1174 -0
  77. django_spec_html-0.1.0/uv.lock +1662 -0
@@ -0,0 +1 @@
1
+ * @Artui
@@ -0,0 +1,9 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues **privately** via GitHub's
6
+ [Report a vulnerability](../../security/advisories/new) button rather than opening a public issue.
7
+ I aim to acknowledge reports within 72 hours.
8
+
9
+ Supported: the latest released version on the default branch.
@@ -0,0 +1,26 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ # Dependabot already holds a new version for 3 days before proposing it; a
8
+ # week is the more useful threshold. A compromised release is typically
9
+ # yanked within days, so the gap between "published" and "found" is exactly
10
+ # the window an automatic upgrade walks into. This costs nothing in
11
+ # responsiveness that matters: cooldown covers version updates only, and
12
+ # security advisories are proposed immediately regardless.
13
+ cooldown:
14
+ default-days: 7
15
+ groups:
16
+ actions:
17
+ patterns: ["*"]
18
+ - package-ecosystem: "uv"
19
+ directory: "/"
20
+ schedule:
21
+ interval: "weekly"
22
+ cooldown:
23
+ default-days: 7
24
+ groups:
25
+ python:
26
+ patterns: ["*"]
@@ -0,0 +1,112 @@
1
+ name: release
2
+
3
+ # Main-triggered: every merge to `main` runs `release-publish-prepare`, which
4
+ # short-circuits to a no-op unless the version in source has been bumped past
5
+ # the most recent `vX.Y.Z` tag. The previous tag-trigger flow has been removed
6
+ # — `make release-bump` + merge to main is now the only path.
7
+ on:
8
+ push:
9
+ branches: [main]
10
+
11
+ concurrency:
12
+ group: release-main
13
+ cancel-in-progress: false
14
+
15
+ # Actions are pinned to a commit SHA rather than a tag: a tag is mutable, and an
16
+ # action owner (or anyone who takes over the account) can silently repoint one at
17
+ # new code that then runs with this workflow's token. The trailing version comment
18
+ # is not decoration -- Dependabot reads it to know which release the SHA is, and
19
+ # rewrites both together when a newer one ships.
20
+ jobs:
21
+ release:
22
+ name: release
23
+ runs-on: ubuntu-latest
24
+ environment:
25
+ name: pypi
26
+ url: https://pypi.org/p/django-spec-html
27
+ permissions:
28
+ id-token: write # PyPI OIDC trusted publishing
29
+ contents: write # tag push + gh release create
30
+ steps:
31
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32
+ with:
33
+ fetch-depth: 0
34
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
35
+ with:
36
+ enable-cache: true
37
+ - name: Install
38
+ run: uv sync --all-groups
39
+
40
+ - name: Prepare release (version check, test, build dist)
41
+ id: prepare
42
+ run: make release-publish-prepare
43
+
44
+ - name: Publish to PyPI
45
+ if: steps.prepare.outputs.released == 'true'
46
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
47
+ with:
48
+ # Idempotent on purpose. What gates a release is the git tag, not the
49
+ # index (see `prepare`), so re-running this job after a failure in a
50
+ # later step arrives here having already uploaded these files. Without
51
+ # this the upload is the step that makes that re-run impossible, and
52
+ # every recovery becomes manual — which is how one release lost its tag,
53
+ # its GitHub Release and its docs deploy to a single transient push
54
+ # failure, with the package already published.
55
+ # PyPI never lets a file be replaced, so skipping one cannot overwrite
56
+ # a published artefact.
57
+ skip-existing: true
58
+
59
+ - name: Tag + GitHub Release
60
+ if: steps.prepare.outputs.released == 'true'
61
+ env:
62
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
+ run: make release-publish-finalize
64
+
65
+ # On release commits we own the single gh-pages push: embed the
66
+ # coverage badge JSON into the docs build so mkdocs gh-deploy carries
67
+ # it alongside the site, and tests.yml's coverage-badge job
68
+ # short-circuits to avoid a second push (and a second built-in
69
+ # "pages build and deployment" run).
70
+ - name: Render coverage badge for the docs site
71
+ if: steps.prepare.outputs.released == 'true' && hashFiles('mkdocs.yml') != ''
72
+ run: |
73
+ set -euo pipefail
74
+ # release-publish-prepare's pytest run wrote .coverage to the
75
+ # workspace root; convert to coverage.xml so the same parser
76
+ # we use in tests.yml can score it.
77
+ uv run coverage xml -o coverage.xml
78
+ python - <<'PY'
79
+ import json
80
+ import xml.etree.ElementTree as ET
81
+
82
+ tree = ET.parse("coverage.xml")
83
+ pct = round(float(tree.getroot().attrib["line-rate"]) * 100, 1)
84
+ if pct >= 95:
85
+ color = "brightgreen"
86
+ elif pct >= 85:
87
+ color = "green"
88
+ elif pct >= 70:
89
+ color = "yellow"
90
+ else:
91
+ color = "red"
92
+ payload = {
93
+ "schemaVersion": 1,
94
+ "label": "coverage",
95
+ "message": f"{pct}%",
96
+ "color": color,
97
+ }
98
+ # docs/ is mkdocs' source dir; non-.md files are copied verbatim
99
+ # into site/, which lands at the gh-pages root after gh-deploy.
100
+ with open("docs/coverage.json", "w") as fh:
101
+ json.dump(payload, fh)
102
+ fh.write("\n")
103
+ print(json.dumps(payload))
104
+ PY
105
+
106
+ - name: Deploy docs + coverage badge to gh-pages
107
+ if: steps.prepare.outputs.released == 'true' && hashFiles('mkdocs.yml') != ''
108
+ run: |
109
+ git config user.name 'github-actions[bot]'
110
+ git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
111
+ DJANGO_SETTINGS_MODULE=tests.conftest_settings \
112
+ uv run mkdocs gh-deploy --force --clean --config-file mkdocs.yml
@@ -0,0 +1,374 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: tests-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ # Actions are pinned to a commit SHA rather than a tag: a tag is mutable, and an
13
+ # action owner (or anyone who takes over the account) can silently repoint one at
14
+ # new code that then runs with this workflow's token. The trailing version comment
15
+ # is not decoration -- Dependabot reads it to know which release the SHA is, and
16
+ # rewrites both together when a newer one ships.
17
+ jobs:
18
+ lint:
19
+ name: lint
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
24
+ with:
25
+ enable-cache: true
26
+ - name: Install
27
+ run: uv sync --all-groups
28
+ - name: ruff check
29
+ run: uv run ruff check .
30
+ - name: ruff format check
31
+ run: uv run ruff format --check --diff .
32
+ - name: ty
33
+ run: uv run ty check django_spec_html
34
+
35
+ docs:
36
+ name: docs build
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
41
+ with:
42
+ enable-cache: true
43
+ - name: Install with docs group
44
+ run: uv sync --all-groups
45
+ - name: mkdocs build --strict
46
+ # mkdocstrings imports the package, and a Django package can read
47
+ # ``django.conf.settings`` at import time. Pointing at the test settings
48
+ # module keeps the build hermetic rather than dependent on whether any
49
+ # module happens to do so today.
50
+ run: DJANGO_SETTINGS_MODULE=tests.conftest_settings uv run mkdocs build --strict
51
+
52
+ floor:
53
+ name: lowest declared versions
54
+ runs-on: ubuntu-latest
55
+ steps:
56
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
57
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
58
+ with:
59
+ enable-cache: true
60
+ # A floor is a claim about the *oldest* version that works, and a lockfile
61
+ # can only ever check the newest. Development and CI both resolve the
62
+ # newest in-range dependency, so every gate passes while a consumer whose
63
+ # own constraints pull an older one gets a package that does not import.
64
+ #
65
+ # `lowest-direct` pins every *declared* dependency to the bottom of its
66
+ # window while letting transitives resolve normally, so this asserts the
67
+ # floors mean what they say. A per-PR gate rather than a scheduled job,
68
+ # because a floor stops being true the moment someone imports a newer
69
+ # upstream symbol -- a code change, not the passage of time.
70
+ #
71
+ # Pinned to the oldest supported Python rather than whatever interpreter
72
+ # the runner exposes. The floor claim is about the oldest configuration
73
+ # we support, so that is the one to install, and leaving the choice to
74
+ # the image makes the answer drift when the image does.
75
+ - name: Install Python 3.10
76
+ run: uv python install 3.10
77
+ # `--refresh` on both resolutions below. This job's whole claim is "what a
78
+ # consumer resolving from scratch would get", and the runner's uv cache is
79
+ # shared across runs: without it the answer comes from whatever package
80
+ # list that cache happens to hold, which can be hours behind the index.
81
+ - name: Resolve every declared dependency at its floor
82
+ run: uv lock --resolution lowest-direct --refresh
83
+ # `--frozen` here and `--no-sync` below, not a bare `uv sync` / `uv run`.
84
+ # uv records the resolution mode in the lockfile and silently discards one
85
+ # resolved in a different mode, so a plain `uv sync` re-resolves at
86
+ # `highest` and undoes the step above -- the job would then measure the
87
+ # newest versions twice while reporting that it tested the oldest.
88
+ - name: Install
89
+ run: uv sync --frozen --all-groups --all-extras --python 3.10
90
+ - name: Name the versions that produced
91
+ run: uv pip list
92
+ - name: Test
93
+ run: uv run --no-sync pytest
94
+
95
+ # The step above installs every group, and a group can hold a shared
96
+ # dependency *above* the floor being claimed -- the dev group's
97
+ # ``django-service-specs[filter]`` does -- masking the lie rather than
98
+ # exposing it. So the floor claim is also checked on the install shape
99
+ # with the fewest constraints: the package alone, no dev group. That
100
+ # shape is what a Django project adding a page actually gets.
101
+ - name: Import the package installed alone, at its floors
102
+ run: |
103
+ uv venv --python 3.10 .venv-floor
104
+ uv pip install --python .venv-floor/bin/python --resolution lowest-direct --refresh -e .
105
+ uv pip list --python .venv-floor/bin/python
106
+ .venv-floor/bin/python - <<'PY'
107
+ import django
108
+ from django.conf import settings
109
+
110
+ # The package defines no models and needs no app listed: a project
111
+ # imports its views from a URLconf, after django.setup() against
112
+ # configured settings, so it is imported that way here.
113
+ settings.configure(
114
+ SECRET_KEY="x",
115
+ INSTALLED_APPS=[
116
+ "django.contrib.contenttypes",
117
+ "django.contrib.auth",
118
+ ],
119
+ DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
120
+ )
121
+ django.setup()
122
+
123
+ import sys
124
+
125
+ import django_spec_html
126
+
127
+ # The kernel it serves exists for dispatch without DRF, and a
128
+ # plain-Django view is one of the transports that needs none, so the
129
+ # install that proves the floors also proves neither package reaches
130
+ # for it. Nothing here installs DRF, so an import of it would already
131
+ # fail above; this names the claim.
132
+ assert "rest_framework" not in sys.modules, "the package imported DRF"
133
+
134
+ print("BASE IMPORT OK", django_spec_html.__version__, django.get_version())
135
+ PY
136
+
137
+ test:
138
+ name: ${{ matrix.python-version }} / Django ${{ matrix.django-version }}
139
+ runs-on: ubuntu-latest
140
+ strategy:
141
+ fail-fast: false
142
+ matrix:
143
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
144
+ django-version: ["4.2", "5.0", "5.1", "5.2", "6.0", "6.1"]
145
+ exclude:
146
+ # Django 4.2 supports Python 3.8–3.12
147
+ - python-version: "3.13"
148
+ django-version: "4.2"
149
+ - python-version: "3.14"
150
+ django-version: "4.2"
151
+ # Django 5.0 supports Python 3.10–3.12
152
+ - python-version: "3.13"
153
+ django-version: "5.0"
154
+ - python-version: "3.14"
155
+ django-version: "5.0"
156
+ # Django 5.1 supports Python 3.10–3.13
157
+ - python-version: "3.14"
158
+ django-version: "5.1"
159
+ # Django 6.0 supports Python 3.12+
160
+ - python-version: "3.10"
161
+ django-version: "6.0"
162
+ - python-version: "3.11"
163
+ django-version: "6.0"
164
+ # Django 6.1 requires Python 3.12+
165
+ - python-version: "3.10"
166
+ django-version: "6.1"
167
+ - python-version: "3.11"
168
+ django-version: "6.1"
169
+
170
+ steps:
171
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
172
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
173
+ with:
174
+ enable-cache: true
175
+ - name: Install Python ${{ matrix.python-version }}
176
+ run: uv python install ${{ matrix.python-version }}
177
+ - name: Sync dev deps
178
+ run: uv sync --all-groups --python ${{ matrix.python-version }}
179
+ - name: Pin Django ${{ matrix.django-version }}
180
+ run: uv pip install --reinstall-package django "django~=${{ matrix.django-version }}.0"
181
+ - name: pytest
182
+ run: |
183
+ uv run --no-sync pytest \
184
+ --cov-report=xml:coverage.xml \
185
+ --cov-report=html:htmlcov
186
+ - name: Upload coverage artifact
187
+ if: always()
188
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
189
+ with:
190
+ name: coverage-py${{ matrix.python-version }}-django${{ matrix.django-version }}
191
+ path: |
192
+ coverage.xml
193
+ htmlcov/
194
+ if-no-files-found: ignore
195
+
196
+ coverage-badge:
197
+ # Publishes a shields.io-compatible coverage.json to gh-pages so the README
198
+ # badge reflects reality. Runs only on push to main, after the matrix has
199
+ # produced an artifact we can read from.
200
+ name: coverage badge
201
+ needs: test
202
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
203
+ runs-on: ubuntu-latest
204
+ permissions:
205
+ contents: write
206
+ steps:
207
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
208
+ with:
209
+ # Need the parent commit so the gate step below can diff
210
+ # version.py against ${{ github.event.before }}. The default
211
+ # shallow checkout (depth 1) would make `git show "$before:…"`
212
+ # fail with exit 128 and turn the whole job red.
213
+ fetch-depth: 2
214
+ # release.yml runs in parallel on the same push and owns gh-pages
215
+ # publishing on release commits (it bundles coverage.json into the
216
+ # mkdocs gh-deploy). If we also push here we get a second built-in
217
+ # "pages build and deployment" run that the first one cancels. The
218
+ # version-diff against ${{ github.event.before }} is the reliable
219
+ # signal — release.yml's tag isn't pushed until after PyPI publish,
220
+ # so a tag-existence check would race.
221
+ - name: Skip when release.yml owns this push
222
+ id: gate
223
+ run: |
224
+ set -euo pipefail
225
+ before="${{ github.event.before }}"
226
+ if [[ -z "$before" || "$before" =~ ^0+$ ]]; then
227
+ # First push to main on a brand-new repo — no prior state to diff.
228
+ echo "skip=false" >> "$GITHUB_OUTPUT"
229
+ exit 0
230
+ fi
231
+ # `before` may not be in the local object DB if the push
232
+ # contained more than one commit (fetch-depth: 2 only guarantees
233
+ # HEAD + 1 parent). Try to fetch just that commit; if it's not
234
+ # reachable, fall back to "don't skip" — better to double-push
235
+ # to gh-pages once than to turn the pipeline red.
236
+ if ! git cat-file -e "$before^{commit}" 2>/dev/null; then
237
+ git fetch --depth=1 origin "$before" 2>/dev/null || true
238
+ fi
239
+ old=""
240
+ if git cat-file -e "$before:django_spec_html/version.py" 2>/dev/null; then
241
+ old="$(git show "$before:django_spec_html/version.py" \
242
+ | awk -F'"' '/^__version__/ { print $2; exit }')"
243
+ fi
244
+ new="$(awk -F'"' '/^__version__/ { print $2; exit }' \
245
+ django_spec_html/version.py)"
246
+ if [[ -n "$old" && "$old" != "$new" ]]; then
247
+ echo "Version bumped $old → $new; release.yml will deploy gh-pages."
248
+ echo "skip=true" >> "$GITHUB_OUTPUT"
249
+ else
250
+ echo "skip=false" >> "$GITHUB_OUTPUT"
251
+ fi
252
+ - name: Download canonical coverage artifact
253
+ if: steps.gate.outputs.skip != 'true'
254
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
255
+ with:
256
+ # Pin to one cell of the matrix — coverage is the same shape across
257
+ # all cells and we only need one number.
258
+ name: coverage-py3.13-django5.2
259
+ path: coverage-artifact/
260
+ - name: Render coverage.json
261
+ if: steps.gate.outputs.skip != 'true'
262
+ run: |
263
+ python - <<'PY'
264
+ import json
265
+ import xml.etree.ElementTree as ET
266
+
267
+ tree = ET.parse("coverage-artifact/coverage.xml")
268
+ pct = round(float(tree.getroot().attrib["line-rate"]) * 100, 1)
269
+ if pct >= 95:
270
+ color = "brightgreen"
271
+ elif pct >= 85:
272
+ color = "green"
273
+ elif pct >= 70:
274
+ color = "yellow"
275
+ else:
276
+ color = "red"
277
+ payload = {
278
+ "schemaVersion": 1,
279
+ "label": "coverage",
280
+ "message": f"{pct}%",
281
+ "color": color,
282
+ }
283
+ with open("coverage.json", "w") as fh:
284
+ json.dump(payload, fh)
285
+ fh.write("\n")
286
+ print(json.dumps(payload))
287
+ PY
288
+ - name: Publish coverage.json to gh-pages
289
+ if: steps.gate.outputs.skip != 'true'
290
+ env:
291
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
292
+ run: |
293
+ set -euo pipefail
294
+ git config user.name 'github-actions[bot]'
295
+ git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
296
+
297
+ tmp="$(mktemp -d)"
298
+ cp coverage.json "$tmp/coverage.json"
299
+
300
+ git fetch origin gh-pages --depth=1 2>/dev/null || true
301
+ if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
302
+ git worktree add gh-pages origin/gh-pages
303
+ cp "$tmp/coverage.json" gh-pages/coverage.json
304
+ cd gh-pages
305
+ if [[ -n "$(git status --porcelain coverage.json)" ]]; then
306
+ git add coverage.json
307
+ git commit -m "coverage badge: update from ${GITHUB_SHA::7}"
308
+ git push origin HEAD:gh-pages
309
+ else
310
+ echo "coverage.json unchanged, skipping push"
311
+ fi
312
+ else
313
+ # First run before docs deploy. Lay down an orphan gh-pages with
314
+ # just the badge file; the docs deploy will overwrite the rest.
315
+ git worktree add --detach gh-pages
316
+ cd gh-pages
317
+ git checkout --orphan gh-pages
318
+ git rm -rf . >/dev/null 2>&1 || true
319
+ cp "$tmp/coverage.json" coverage.json
320
+ git add coverage.json
321
+ git commit -m "coverage badge: initial publish from ${GITHUB_SHA::7}"
322
+ git push origin gh-pages
323
+ fi
324
+
325
+ secrets:
326
+ name: secret scan
327
+ runs-on: ubuntu-latest
328
+ steps:
329
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
330
+ with:
331
+ fetch-depth: 0
332
+ - name: Install gitleaks
333
+ run: |
334
+ curl -sSL https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz | tar -xz gitleaks
335
+ sudo mv gitleaks /usr/local/bin/
336
+ - name: Scan repo + history
337
+ run: gitleaks git --redact --no-banner .
338
+
339
+ tests-passed:
340
+ name: tests
341
+ # always(), never !cancelled(): a skipped job reports a skipped check, and
342
+ # branch protection counts a skipped required check as passing.
343
+ if: always()
344
+ needs: [lint, docs, floor, test]
345
+ runs-on: ubuntu-latest
346
+ steps:
347
+ # Pass on an exact `success` from every job above, rather than failing on
348
+ # a list of bad results: such a list passes whatever it does not name, and
349
+ # GitHub reports a result it does not document. A job no hosted runner
350
+ # ever picks up ("The job was not acquired by Runner of type hosted even
351
+ # after multiple attempts") shows as cancelled on its own check but
352
+ # reaches `needs` as `abandoned`, and a gate that failed only on `failure`
353
+ # and `cancelled` went green over exactly that while the jobs it guards
354
+ # never ran. A matrix reaches `needs` as one result, and one cell that did
355
+ # not succeed is enough to make it something other than `success`.
356
+ #
357
+ # None of the jobs above has an `if:`, so `skipped` can only mean one of
358
+ # them never ran, and it fails like any other result. A job that gains a
359
+ # legitimate skip gets an exception naming it, never `skipped` accepted
360
+ # from all of them.
361
+ #
362
+ # The results come in through `env` rather than being spliced into the
363
+ # script, and every one is printed, so a red gate says which job and what
364
+ # GitHub reported for it.
365
+ - name: Verify every required job succeeded
366
+ env:
367
+ NEEDS: ${{ toJSON(needs) }}
368
+ run: |
369
+ echo "$NEEDS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
370
+ not_ok="$(echo "$NEEDS" | jq -r '[to_entries[] | select(.value.result != "success") | "\(.key)=\(.value.result)"] | join(" ")')"
371
+ if [ -n "$not_ok" ]; then
372
+ echo "::error::required jobs did not succeed: $not_ok"
373
+ exit 1
374
+ fi
@@ -0,0 +1,149 @@
1
+ # What a fresh install would get today, run on a schedule.
2
+ #
3
+ # ``uv.lock`` is what every other job resolves against, so a dependency can be
4
+ # unconstrained in ``pyproject.toml`` and still frozen everywhere it is actually
5
+ # tested. That gap is why the Django 6.1 break was invisible while the matrix
6
+ # was green: the cell that found it installed unpinned and resolved 6.1 by
7
+ # accident.
8
+ #
9
+ # This job closes it deliberately. It ignores the lock, resolves the newest
10
+ # versions ``pyproject.toml`` allows, and runs the suite — so an upstream
11
+ # release that breaks us is found by a scheduled run rather than by a consumer.
12
+ #
13
+ # It is also the control that makes dropping dependency ceilings safe. A
14
+ # ceiling is a guess about which future versions will break; this is a
15
+ # measurement of which ones do. Do not delete it to quieten a noisy week
16
+ # without replacing what it measures.
17
+ name: upstream drift
18
+
19
+ on:
20
+ schedule:
21
+ # Mondays, 06:00 UTC. Weekly rather than nightly: the failure this guards
22
+ # against is an upstream release, which is measured in weeks, and six repos
23
+ # running nightly is six chances a day to learn nothing.
24
+ - cron: "0 6 * * 1"
25
+ workflow_dispatch:
26
+
27
+ concurrency:
28
+ group: upstream-drift-${{ github.ref }}
29
+ cancel-in-progress: true
30
+
31
+ permissions:
32
+ contents: read
33
+ issues: write
34
+
35
+ # Actions are pinned to a commit SHA rather than a tag: a tag is mutable, and an
36
+ # action owner (or anyone who takes over the account) can silently repoint one at
37
+ # new code that then runs with this workflow's token. The trailing version comment
38
+ # is not decoration -- Dependabot reads it to know which release the SHA is, and
39
+ # rewrites both together when a newer one ships.
40
+ jobs:
41
+ resolve-latest:
42
+ name: resolve unpinned + test
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
46
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
47
+ with:
48
+ enable-cache: false
49
+
50
+ # One cell, not the matrix. The matrix answers "does this combination
51
+ # work"; this answers "has an upstream moved under us", and the newest
52
+ # supported Python is where a new release lands first.
53
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
54
+ with:
55
+ python-version: "3.14"
56
+
57
+ - name: Resolve the newest versions pyproject allows
58
+ run: uv lock --upgrade
59
+
60
+ - name: Report what changed against the committed lock
61
+ # Informational, and the most useful line in the log when this fails:
62
+ # it names the upgrade that broke the build.
63
+ run: git --no-pager diff --stat uv.lock || true
64
+
65
+ - name: Install
66
+ id: install
67
+ run: uv sync --all-groups --all-extras
68
+
69
+ - name: Show the resolved versions
70
+ run: uv pip list
71
+
72
+ # A resolve can succeed by backing off. When the newest release of a
73
+ # direct dependency conflicts with something else this project requires,
74
+ # uv takes the newest version that does resolve and logs an ordinary
75
+ # "Updated" line, so the suite below passes against a release nobody
76
+ # chose. That is how django-ag-ui's run went green with pydantic-ai-slim
77
+ # at 2.46 and 2.54 out: from 2.47 its [ag-ui] extra caps ag-ui-protocol
78
+ # below the 1.0 django-ag-ui requires. This compares every direct
79
+ # dependency with PyPI, fails on one held below a release that has been
80
+ # out longer than the Dependabot cooldown, and asks uv what holds it. A
81
+ # ceiling declared in pyproject.toml is honoured, which is how a hold is
82
+ # accepted on purpose. One copy for every repo, pinned like any action.
83
+ - name: Check no direct dependency is held back
84
+ id: held-back
85
+ uses: Artui/held-back-check@b64bbb88fd63c9c96675caba477cce13714de93e # v0.1.0
86
+
87
+ # Runs whether or not the check above failed: they answer different
88
+ # questions, and a hold is no reason to stop measuring what did resolve.
89
+ - name: Test
90
+ id: test
91
+ if: ${{ !cancelled() && steps.install.outcome == 'success' }}
92
+ run: uv run pytest
93
+
94
+ - name: Open or update an issue on failure
95
+ # Main only. A dispatch on any other branch is a trial of that branch's
96
+ # manifest, and an issue saying the unpinned resolve is failing would be
97
+ # filed against the wrong tree.
98
+ if: failure() && github.ref == 'refs/heads/main'
99
+ env:
100
+ HELD_BACK: ${{ steps.held-back.outcome }}
101
+ TESTS: ${{ steps.test.outcome }}
102
+ REPORT: ${{ steps.held-back.outputs.report }}
103
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
104
+ with:
105
+ script: |
106
+ const fs = require("fs");
107
+ const title = "upstream drift: the unpinned resolve is failing";
108
+ const run = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
109
+ const sections = [];
110
+ if (process.env.TESTS === "failure") {
111
+ sections.push([
112
+ "The weekly unpinned resolve failed. A dependency released a version",
113
+ "that `pyproject.toml` admits and the suite does not survive.",
114
+ "",
115
+ "The `git diff --stat uv.lock` step in that run names what moved.",
116
+ ].join("\n"));
117
+ }
118
+ if (process.env.HELD_BACK === "failure") {
119
+ sections.push(fs.existsSync(process.env.REPORT)
120
+ ? fs.readFileSync(process.env.REPORT, "utf8")
121
+ : "The held-back check failed before writing its report; the run's log says why.");
122
+ }
123
+ if (!sections.length) {
124
+ sections.push("A step before the suite failed; the run's log names it.");
125
+ }
126
+ const body = [
127
+ ...sections,
128
+ "",
129
+ `Run: ${run}`,
130
+ "",
131
+ "Fix forward (adopt the new version) or add a floor/ceiling that says",
132
+ "why, but do not silence the job — it is the control that lets this",
133
+ "repo declare open-ended dependency windows.",
134
+ ].join("\n");
135
+ const existing = await github.rest.issues.listForRepo({
136
+ owner: context.repo.owner, repo: context.repo.repo,
137
+ state: "open", labels: "upstream-drift",
138
+ });
139
+ if (existing.data.length) {
140
+ await github.rest.issues.createComment({
141
+ owner: context.repo.owner, repo: context.repo.repo,
142
+ issue_number: existing.data[0].number, body,
143
+ });
144
+ } else {
145
+ await github.rest.issues.create({
146
+ owner: context.repo.owner, repo: context.repo.repo,
147
+ title, body, labels: ["upstream-drift"],
148
+ });
149
+ }