django-spec-cli 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.
- django_spec_cli-0.1.0/.github/CODEOWNERS +1 -0
- django_spec_cli-0.1.0/.github/SECURITY.md +9 -0
- django_spec_cli-0.1.0/.github/dependabot.yml +26 -0
- django_spec_cli-0.1.0/.github/workflows/release.yml +112 -0
- django_spec_cli-0.1.0/.github/workflows/tests.yml +376 -0
- django_spec_cli-0.1.0/.github/workflows/upstream-drift.yml +149 -0
- django_spec_cli-0.1.0/.gitignore +639 -0
- django_spec_cli-0.1.0/.pre-commit-config.yaml +90 -0
- django_spec_cli-0.1.0/CHANGELOG.md +35 -0
- django_spec_cli-0.1.0/CLAUDE.md +188 -0
- django_spec_cli-0.1.0/LICENSE +21 -0
- django_spec_cli-0.1.0/Makefile +90 -0
- django_spec_cli-0.1.0/PKG-INFO +113 -0
- django_spec_cli-0.1.0/README.md +77 -0
- django_spec_cli-0.1.0/django_spec_cli/__init__.py +31 -0
- django_spec_cli-0.1.0/django_spec_cli/apps.py +31 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/__init__.py +13 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/add_spec_arguments.py +169 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/describe_parameters.py +80 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/parameter_descriptor.py +61 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/parsed_arguments.py +50 -0
- django_spec_cli-0.1.0/django_spec_cli/argv/utils.py +21 -0
- django_spec_cli-0.1.0/django_spec_cli/checks.py +133 -0
- django_spec_cli-0.1.0/django_spec_cli/exit_code_for.py +49 -0
- django_spec_cli-0.1.0/django_spec_cli/py.typed +0 -0
- django_spec_cli-0.1.0/django_spec_cli/render/__init__.py +13 -0
- django_spec_cli-0.1.0/django_spec_cli/render/render_json_lines.py +42 -0
- django_spec_cli-0.1.0/django_spec_cli/render/render_result.py +71 -0
- django_spec_cli-0.1.0/django_spec_cli/render/render_table.py +203 -0
- django_spec_cli-0.1.0/django_spec_cli/render/utils.py +16 -0
- django_spec_cli-0.1.0/django_spec_cli/render/wants_table.py +37 -0
- django_spec_cli-0.1.0/django_spec_cli/report/__init__.py +7 -0
- django_spec_cli-0.1.0/django_spec_cli/report/unguarded_message.py +29 -0
- django_spec_cli-0.1.0/django_spec_cli/settings.py +36 -0
- django_spec_cli-0.1.0/django_spec_cli/spec_command.py +344 -0
- django_spec_cli-0.1.0/django_spec_cli/types/__init__.py +7 -0
- django_spec_cli-0.1.0/django_spec_cli/types/exit_code.py +49 -0
- django_spec_cli-0.1.0/django_spec_cli/version.py +7 -0
- django_spec_cli-0.1.0/docs/__init__.py +1 -0
- django_spec_cli-0.1.0/docs/examples/__init__.py +1 -0
- django_spec_cli-0.1.0/docs/examples/commands.py +139 -0
- django_spec_cli-0.1.0/docs/index.md +277 -0
- django_spec_cli-0.1.0/docs/reference.md +57 -0
- django_spec_cli-0.1.0/mkdocs.yml +96 -0
- django_spec_cli-0.1.0/pyproject.toml +168 -0
- django_spec_cli-0.1.0/scripts/check-changelog +162 -0
- django_spec_cli-0.1.0/scripts/release-publish.sh +246 -0
- django_spec_cli-0.1.0/tests/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/argv/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/argv/test_add_spec_arguments.py +261 -0
- django_spec_cli-0.1.0/tests/argv/test_describe_parameters.py +145 -0
- django_spec_cli-0.1.0/tests/argv/test_parameter_descriptor.py +26 -0
- django_spec_cli-0.1.0/tests/argv/test_parsed_arguments.py +148 -0
- django_spec_cli-0.1.0/tests/argv/test_utils.py +13 -0
- django_spec_cli-0.1.0/tests/argv/utils.py +48 -0
- django_spec_cli-0.1.0/tests/commands_app/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/commands_app/apps.py +8 -0
- django_spec_cli-0.1.0/tests/commands_app/management/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/notes.py +225 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_bad_parser.py +37 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_broken_import.py +5 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_broken_init.py +15 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_empty.py +11 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_no_registry.py +8 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_plain.py +15 -0
- django_spec_cli-0.1.0/tests/commands_app/management/commands/unguarded_report.py +10 -0
- django_spec_cli-0.1.0/tests/commands_app/unguarded_registries.py +54 -0
- django_spec_cli-0.1.0/tests/conftest.py +103 -0
- django_spec_cli-0.1.0/tests/conftest_settings.py +48 -0
- django_spec_cli-0.1.0/tests/dispatch_app/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/dispatch_app/apps.py +8 -0
- django_spec_cli-0.1.0/tests/dispatch_app/models.py +24 -0
- django_spec_cli-0.1.0/tests/docs/__init__.py +1 -0
- django_spec_cli-0.1.0/tests/docs/test_commands_examples.py +118 -0
- django_spec_cli-0.1.0/tests/docs/test_reference.py +33 -0
- django_spec_cli-0.1.0/tests/render/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/render/test_render_json_lines.py +117 -0
- django_spec_cli-0.1.0/tests/render/test_render_result.py +142 -0
- django_spec_cli-0.1.0/tests/render/test_render_table.py +368 -0
- django_spec_cli-0.1.0/tests/render/test_utils.py +21 -0
- django_spec_cli-0.1.0/tests/render/test_wants_table.py +79 -0
- django_spec_cli-0.1.0/tests/render/utils.py +42 -0
- django_spec_cli-0.1.0/tests/report/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/report/test_unguarded_message.py +23 -0
- django_spec_cli-0.1.0/tests/test_apps.py +58 -0
- django_spec_cli-0.1.0/tests/test_checks.py +319 -0
- django_spec_cli-0.1.0/tests/test_conftest.py +63 -0
- django_spec_cli-0.1.0/tests/test_exit_code_for.py +79 -0
- django_spec_cli-0.1.0/tests/test_init.py +61 -0
- django_spec_cli-0.1.0/tests/test_kernel_copy_references.py +213 -0
- django_spec_cli-0.1.0/tests/test_settings.py +39 -0
- django_spec_cli-0.1.0/tests/test_spec_command.py +681 -0
- django_spec_cli-0.1.0/tests/types/__init__.py +0 -0
- django_spec_cli-0.1.0/tests/types/test_exit_code.py +20 -0
- django_spec_cli-0.1.0/tests/utils.py +34 -0
- django_spec_cli-0.1.0/uv.lock +1811 -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-cli
|
|
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,376 @@
|
|
|
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_cli
|
|
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[pydantic]`` 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 command 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, but it is a Django app whose
|
|
111
|
+
# AppConfig registers system checks, so it is imported the way a
|
|
112
|
+
# project imports it: listed, after django.setup() against
|
|
113
|
+
# configured settings.
|
|
114
|
+
settings.configure(
|
|
115
|
+
SECRET_KEY="x",
|
|
116
|
+
INSTALLED_APPS=[
|
|
117
|
+
"django.contrib.contenttypes",
|
|
118
|
+
"django.contrib.auth",
|
|
119
|
+
"django_spec_cli",
|
|
120
|
+
],
|
|
121
|
+
DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
|
|
122
|
+
)
|
|
123
|
+
django.setup()
|
|
124
|
+
|
|
125
|
+
import sys
|
|
126
|
+
|
|
127
|
+
import django_spec_cli
|
|
128
|
+
|
|
129
|
+
# The kernel it serves exists for dispatch without DRF, and a
|
|
130
|
+
# command line is one of the transports that needs none, so the
|
|
131
|
+
# install that proves the floors also proves neither package reaches
|
|
132
|
+
# for it. Nothing here installs DRF, so an import of it would already
|
|
133
|
+
# fail above; this names the claim.
|
|
134
|
+
assert "rest_framework" not in sys.modules, "the package imported DRF"
|
|
135
|
+
|
|
136
|
+
print("BASE IMPORT OK", django_spec_cli.__version__, django.get_version())
|
|
137
|
+
PY
|
|
138
|
+
|
|
139
|
+
test:
|
|
140
|
+
name: ${{ matrix.python-version }} / Django ${{ matrix.django-version }}
|
|
141
|
+
runs-on: ubuntu-latest
|
|
142
|
+
strategy:
|
|
143
|
+
fail-fast: false
|
|
144
|
+
matrix:
|
|
145
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
146
|
+
django-version: ["4.2", "5.0", "5.1", "5.2", "6.0", "6.1"]
|
|
147
|
+
exclude:
|
|
148
|
+
# Django 4.2 supports Python 3.8–3.12
|
|
149
|
+
- python-version: "3.13"
|
|
150
|
+
django-version: "4.2"
|
|
151
|
+
- python-version: "3.14"
|
|
152
|
+
django-version: "4.2"
|
|
153
|
+
# Django 5.0 supports Python 3.10–3.12
|
|
154
|
+
- python-version: "3.13"
|
|
155
|
+
django-version: "5.0"
|
|
156
|
+
- python-version: "3.14"
|
|
157
|
+
django-version: "5.0"
|
|
158
|
+
# Django 5.1 supports Python 3.10–3.13
|
|
159
|
+
- python-version: "3.14"
|
|
160
|
+
django-version: "5.1"
|
|
161
|
+
# Django 6.0 supports Python 3.12+
|
|
162
|
+
- python-version: "3.10"
|
|
163
|
+
django-version: "6.0"
|
|
164
|
+
- python-version: "3.11"
|
|
165
|
+
django-version: "6.0"
|
|
166
|
+
# Django 6.1 requires Python 3.12+
|
|
167
|
+
- python-version: "3.10"
|
|
168
|
+
django-version: "6.1"
|
|
169
|
+
- python-version: "3.11"
|
|
170
|
+
django-version: "6.1"
|
|
171
|
+
|
|
172
|
+
steps:
|
|
173
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
174
|
+
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
|
|
175
|
+
with:
|
|
176
|
+
enable-cache: true
|
|
177
|
+
- name: Install Python ${{ matrix.python-version }}
|
|
178
|
+
run: uv python install ${{ matrix.python-version }}
|
|
179
|
+
- name: Sync dev deps
|
|
180
|
+
run: uv sync --all-groups --python ${{ matrix.python-version }}
|
|
181
|
+
- name: Pin Django ${{ matrix.django-version }}
|
|
182
|
+
run: uv pip install --reinstall-package django "django~=${{ matrix.django-version }}.0"
|
|
183
|
+
- name: pytest
|
|
184
|
+
run: |
|
|
185
|
+
uv run --no-sync pytest \
|
|
186
|
+
--cov-report=xml:coverage.xml \
|
|
187
|
+
--cov-report=html:htmlcov
|
|
188
|
+
- name: Upload coverage artifact
|
|
189
|
+
if: always()
|
|
190
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
191
|
+
with:
|
|
192
|
+
name: coverage-py${{ matrix.python-version }}-django${{ matrix.django-version }}
|
|
193
|
+
path: |
|
|
194
|
+
coverage.xml
|
|
195
|
+
htmlcov/
|
|
196
|
+
if-no-files-found: ignore
|
|
197
|
+
|
|
198
|
+
coverage-badge:
|
|
199
|
+
# Publishes a shields.io-compatible coverage.json to gh-pages so the README
|
|
200
|
+
# badge reflects reality. Runs only on push to main, after the matrix has
|
|
201
|
+
# produced an artifact we can read from.
|
|
202
|
+
name: coverage badge
|
|
203
|
+
needs: test
|
|
204
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
205
|
+
runs-on: ubuntu-latest
|
|
206
|
+
permissions:
|
|
207
|
+
contents: write
|
|
208
|
+
steps:
|
|
209
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
210
|
+
with:
|
|
211
|
+
# Need the parent commit so the gate step below can diff
|
|
212
|
+
# version.py against ${{ github.event.before }}. The default
|
|
213
|
+
# shallow checkout (depth 1) would make `git show "$before:…"`
|
|
214
|
+
# fail with exit 128 and turn the whole job red.
|
|
215
|
+
fetch-depth: 2
|
|
216
|
+
# release.yml runs in parallel on the same push and owns gh-pages
|
|
217
|
+
# publishing on release commits (it bundles coverage.json into the
|
|
218
|
+
# mkdocs gh-deploy). If we also push here we get a second built-in
|
|
219
|
+
# "pages build and deployment" run that the first one cancels. The
|
|
220
|
+
# version-diff against ${{ github.event.before }} is the reliable
|
|
221
|
+
# signal — release.yml's tag isn't pushed until after PyPI publish,
|
|
222
|
+
# so a tag-existence check would race.
|
|
223
|
+
- name: Skip when release.yml owns this push
|
|
224
|
+
id: gate
|
|
225
|
+
run: |
|
|
226
|
+
set -euo pipefail
|
|
227
|
+
before="${{ github.event.before }}"
|
|
228
|
+
if [[ -z "$before" || "$before" =~ ^0+$ ]]; then
|
|
229
|
+
# First push to main on a brand-new repo — no prior state to diff.
|
|
230
|
+
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
231
|
+
exit 0
|
|
232
|
+
fi
|
|
233
|
+
# `before` may not be in the local object DB if the push
|
|
234
|
+
# contained more than one commit (fetch-depth: 2 only guarantees
|
|
235
|
+
# HEAD + 1 parent). Try to fetch just that commit; if it's not
|
|
236
|
+
# reachable, fall back to "don't skip" — better to double-push
|
|
237
|
+
# to gh-pages once than to turn the pipeline red.
|
|
238
|
+
if ! git cat-file -e "$before^{commit}" 2>/dev/null; then
|
|
239
|
+
git fetch --depth=1 origin "$before" 2>/dev/null || true
|
|
240
|
+
fi
|
|
241
|
+
old=""
|
|
242
|
+
if git cat-file -e "$before:django_spec_cli/version.py" 2>/dev/null; then
|
|
243
|
+
old="$(git show "$before:django_spec_cli/version.py" \
|
|
244
|
+
| awk -F'"' '/^__version__/ { print $2; exit }')"
|
|
245
|
+
fi
|
|
246
|
+
new="$(awk -F'"' '/^__version__/ { print $2; exit }' \
|
|
247
|
+
django_spec_cli/version.py)"
|
|
248
|
+
if [[ -n "$old" && "$old" != "$new" ]]; then
|
|
249
|
+
echo "Version bumped $old → $new; release.yml will deploy gh-pages."
|
|
250
|
+
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
251
|
+
else
|
|
252
|
+
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
253
|
+
fi
|
|
254
|
+
- name: Download canonical coverage artifact
|
|
255
|
+
if: steps.gate.outputs.skip != 'true'
|
|
256
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
257
|
+
with:
|
|
258
|
+
# Pin to one cell of the matrix — coverage is the same shape across
|
|
259
|
+
# all cells and we only need one number.
|
|
260
|
+
name: coverage-py3.13-django5.2
|
|
261
|
+
path: coverage-artifact/
|
|
262
|
+
- name: Render coverage.json
|
|
263
|
+
if: steps.gate.outputs.skip != 'true'
|
|
264
|
+
run: |
|
|
265
|
+
python - <<'PY'
|
|
266
|
+
import json
|
|
267
|
+
import xml.etree.ElementTree as ET
|
|
268
|
+
|
|
269
|
+
tree = ET.parse("coverage-artifact/coverage.xml")
|
|
270
|
+
pct = round(float(tree.getroot().attrib["line-rate"]) * 100, 1)
|
|
271
|
+
if pct >= 95:
|
|
272
|
+
color = "brightgreen"
|
|
273
|
+
elif pct >= 85:
|
|
274
|
+
color = "green"
|
|
275
|
+
elif pct >= 70:
|
|
276
|
+
color = "yellow"
|
|
277
|
+
else:
|
|
278
|
+
color = "red"
|
|
279
|
+
payload = {
|
|
280
|
+
"schemaVersion": 1,
|
|
281
|
+
"label": "coverage",
|
|
282
|
+
"message": f"{pct}%",
|
|
283
|
+
"color": color,
|
|
284
|
+
}
|
|
285
|
+
with open("coverage.json", "w") as fh:
|
|
286
|
+
json.dump(payload, fh)
|
|
287
|
+
fh.write("\n")
|
|
288
|
+
print(json.dumps(payload))
|
|
289
|
+
PY
|
|
290
|
+
- name: Publish coverage.json to gh-pages
|
|
291
|
+
if: steps.gate.outputs.skip != 'true'
|
|
292
|
+
env:
|
|
293
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
294
|
+
run: |
|
|
295
|
+
set -euo pipefail
|
|
296
|
+
git config user.name 'github-actions[bot]'
|
|
297
|
+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
298
|
+
|
|
299
|
+
tmp="$(mktemp -d)"
|
|
300
|
+
cp coverage.json "$tmp/coverage.json"
|
|
301
|
+
|
|
302
|
+
git fetch origin gh-pages --depth=1 2>/dev/null || true
|
|
303
|
+
if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
|
|
304
|
+
git worktree add gh-pages origin/gh-pages
|
|
305
|
+
cp "$tmp/coverage.json" gh-pages/coverage.json
|
|
306
|
+
cd gh-pages
|
|
307
|
+
if [[ -n "$(git status --porcelain coverage.json)" ]]; then
|
|
308
|
+
git add coverage.json
|
|
309
|
+
git commit -m "coverage badge: update from ${GITHUB_SHA::7}"
|
|
310
|
+
git push origin HEAD:gh-pages
|
|
311
|
+
else
|
|
312
|
+
echo "coverage.json unchanged, skipping push"
|
|
313
|
+
fi
|
|
314
|
+
else
|
|
315
|
+
# First run before docs deploy. Lay down an orphan gh-pages with
|
|
316
|
+
# just the badge file; the docs deploy will overwrite the rest.
|
|
317
|
+
git worktree add --detach gh-pages
|
|
318
|
+
cd gh-pages
|
|
319
|
+
git checkout --orphan gh-pages
|
|
320
|
+
git rm -rf . >/dev/null 2>&1 || true
|
|
321
|
+
cp "$tmp/coverage.json" coverage.json
|
|
322
|
+
git add coverage.json
|
|
323
|
+
git commit -m "coverage badge: initial publish from ${GITHUB_SHA::7}"
|
|
324
|
+
git push origin gh-pages
|
|
325
|
+
fi
|
|
326
|
+
|
|
327
|
+
secrets:
|
|
328
|
+
name: secret scan
|
|
329
|
+
runs-on: ubuntu-latest
|
|
330
|
+
steps:
|
|
331
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
332
|
+
with:
|
|
333
|
+
fetch-depth: 0
|
|
334
|
+
- name: Install gitleaks
|
|
335
|
+
run: |
|
|
336
|
+
curl -sSL https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz | tar -xz gitleaks
|
|
337
|
+
sudo mv gitleaks /usr/local/bin/
|
|
338
|
+
- name: Scan repo + history
|
|
339
|
+
run: gitleaks git --redact --no-banner .
|
|
340
|
+
|
|
341
|
+
tests-passed:
|
|
342
|
+
name: tests
|
|
343
|
+
# always(), never !cancelled(): a skipped job reports a skipped check, and
|
|
344
|
+
# branch protection counts a skipped required check as passing.
|
|
345
|
+
if: always()
|
|
346
|
+
needs: [lint, docs, floor, test]
|
|
347
|
+
runs-on: ubuntu-latest
|
|
348
|
+
steps:
|
|
349
|
+
# Pass on an exact `success` from every job above, rather than failing on
|
|
350
|
+
# a list of bad results: such a list passes whatever it does not name, and
|
|
351
|
+
# GitHub reports a result it does not document. A job no hosted runner
|
|
352
|
+
# ever picks up ("The job was not acquired by Runner of type hosted even
|
|
353
|
+
# after multiple attempts") shows as cancelled on its own check but
|
|
354
|
+
# reaches `needs` as `abandoned`, and a gate that failed only on `failure`
|
|
355
|
+
# and `cancelled` went green over exactly that while the jobs it guards
|
|
356
|
+
# never ran. A matrix reaches `needs` as one result, and one cell that did
|
|
357
|
+
# not succeed is enough to make it something other than `success`.
|
|
358
|
+
#
|
|
359
|
+
# None of the jobs above has an `if:`, so `skipped` can only mean one of
|
|
360
|
+
# them never ran, and it fails like any other result. A job that gains a
|
|
361
|
+
# legitimate skip gets an exception naming it, never `skipped` accepted
|
|
362
|
+
# from all of them.
|
|
363
|
+
#
|
|
364
|
+
# The results come in through `env` rather than being spliced into the
|
|
365
|
+
# script, and every one is printed, so a red gate says which job and what
|
|
366
|
+
# GitHub reported for it.
|
|
367
|
+
- name: Verify every required job succeeded
|
|
368
|
+
env:
|
|
369
|
+
NEEDS: ${{ toJSON(needs) }}
|
|
370
|
+
run: |
|
|
371
|
+
echo "$NEEDS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
|
|
372
|
+
not_ok="$(echo "$NEEDS" | jq -r '[to_entries[] | select(.value.result != "success") | "\(.key)=\(.value.result)"] | join(" ")')"
|
|
373
|
+
if [ -n "$not_ok" ]; then
|
|
374
|
+
echo "::error::required jobs did not succeed: $not_ok"
|
|
375
|
+
exit 1
|
|
376
|
+
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
|
+
}
|