Debian Codegraph @

CONTRIBUTING.md

raw
1 # Contributing
2
3 Contributions are encouraged! Please use the issue page to submit feature requests or bug reports. Issues with attached PRs will be given priority and have a much higher likelihood of acceptance. Please also open an issue and associate it with any submitted PRs.
4
5 This is a [django-commons](https://django-commons.org) project. If you wish to contribute, [please join the organization!](https://django-commons.org/#how-to-join-as-a-contributor)
6
7 We are actively seeking additional maintainers. If you're interested, please open an issue or [contact me](https://github.com/bckohan).
8
9 ## Installation
10
11 ### Install Just
12
13 We provide a platform independent justfile with recipes for all the development tasks. You should [install just](https://just.systems/man/en/) if it is not on your system already.
14
15 [django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) uses [uv](https://docs.astral.sh/uv) for environment, package, and dependency management. ``just setup`` will install the necessary build tooling if you do not already have it:
16
17 ```bash
18 just setup
19 ```
20
21 Setup also may take a python version:
22
23 ```bash
24 just setup 3.12
25 ```
26
27 If you already have uv and python installed running install will just install the development dependencies:
28
29 ```bash
30 just install
31 ```
32
33 **To run pre-commit checks you will have to install just.**
34
35 ## Documentation
36
37 `django-polymorphic` documentation is generated using [Sphinx](https://www.sphinx-doc.org) with the [furo](https://github.com/pradyunsg/furo) theme. Any new feature PRs must provide updated documentation for the features added. To build the docs run doc8 to check for formatting issues then run Sphinx:
38
39 ```bash
40 just docs # builds docs
41 just check-docs # lint the docs
42 just check-docs-links # check for broken links in the docs
43 ```
44
45 Run the docs with auto rebuild using:
46
47 ```bash
48 just docs-live
49 ```
50
51 ## Static Analysis
52
53 `django-polymorphic` uses [ruff](https://docs.astral.sh/ruff/) for Python linting, header import standardization and code formatting. Before any PR is accepted the following must be run, and static analysis tools should not produce any errors or warnings. Disabling certain errors or warnings where justified is acceptable:
54
55 To fix formatting and linting problems that are fixable run:
56
57 ```bash
58 just fix
59 ```
60
61 To run all static analysis without automated fixing you can run:
62
63 ```bash
64 just check
65 ```
66
67 To format source files you can run:
68
69 ```bash
70 just format
71 ```
72
73 ### Type Checking
74
75 Both [mypy](https://www.mypy-lang.org) and [pyright](https://microsoft.github.io/pyright) are used to verify static typing. You can run them together or individually:
76
77 ```bash
78 just check-types
79 just check-types-mypy
80 just check-types-pyright
81 ```
82
83 ## Running Tests
84
85 `django-polymorphic` is set up to use [pytest](https://docs.pytest.org) to run unit tests. All the tests are housed in `src/polymorphic/tests`. Before a PR is accepted, all tests must be passing and the code coverage must be at 100%. A small number of exempted error handling branches are acceptable.
86
87 To run the full suite:
88
89 ```bash
90 just test
91 ```
92
93 To run a single test, or group of tests in a class:
94
95 ```bash
96 just test <path_to_tests_file>::ClassName::FunctionName
97 ```
98
99 For instance, to run all admin tests, and then just the test_admin_registration test you would do:
100
101 ```bash
102 just test src/polymorphic/tests/test_admin.py
103 just test src/polymorphic/tests/test_admin.py::PolymorphicAdminTests::test_admin_registration
104 ```
105
106 ### Running UI Tests
107
108 Make sure you have playwright installed:
109
110 ```bash
111 just install-playwright
112 ```
113
114 If you want to see the test step through the UI actions you can run the test like so:
115
116 ```bash
117 just debug-test -k <test_name>
118 ```
119
120 This will open a browser and the debugger at the start of the test, you can then ``next`` through and see the UI actions happen.
121
122 ## Versioning
123
124 [django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) strictly adheres to [semantic versioning](https://semver.org).
125
126 ## Issuing Releases
127
128 The release workflow is triggered by tag creation. You must have [git tag signing enabled](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits). Our justfile has a release shortcut:
129
130 ```bash
131 just release x.x.x
132 ```
133
134 ## Just Recipes
135
136 ```bash
137 build # build docs and package
138 build-docs # build the docs
139 build-docs-html # build html documentation
140 build-docs-pdf # build pdf documentation
141 check # run all static checks
142 check-all # run all checks including doc link staleness (slow)
143 check-docs # lint the documentation
144 check-docs-links # check the documentation links for broken links
145 check-format # check if the code needs formatting
146 check-lint # lint the code
147 check-package # run package checks
148 check-readme # check that the readme renders
149 check-types # run all static type checking
150 check-types-isolated # run all static type checking in an isolated environment
151 check-types-mypy *RUN_ARGS # run static type checking with mypy
152 check-types-pyright *RUN_ARGS # run static type checking with pyright
153 clean # remove all non repository artifacts
154 clean-docs # remove doc build artifacts-
155 clean-env # remove the virtual environment
156 clean-git-ignored # remove all git ignored files
157 coverage # generate the test coverage report
158 debug-test *TESTS # debug an test
159 docs # build and open the documentation
160 docs-live # serve the documentation, with auto-reload
161 fetch-refs LIB # get the intersphinx references for the given library
162 fix # fix formatting, linting issues and import sorting
163 format # format the code and sort imports
164 install *OPTS # update and install development dependencies
165 install-playwright # install playwright dependencies
166 install-precommit # install git pre-commit hooks
167 install_uv # install the uv package manager
168 lint # sort the imports and fix linting issues
169 manage *COMMAND # run the django admin
170 open-docs # open the html documentation
171 precommit # run the pre-commit checks
172 release VERSION # issue a release for the given semver string (e.g. 2.1.0)
173 remake-test-migrations # regenerate test migrations using the lowest version of Django
174 run +ARGS # run the command in the virtual environment
175 setup python="python" # setup the venv, pre-commit hooks and playwright dependencies
176 sort-imports # sort the python imports
177 test *TESTS # run tests
178 test-db DB_CLIENT="dev" *TESTS # test against the specified database backend
179 test-drf *TESTS # test django rest framework integration
180 test-extra-views *TESTS # test django extra views integration
181 test-guardian *TESTS # test guardian integration
182 test-integrations DB_CLIENT="dev" # run all third party integration tests
183 test-lock +PACKAGES # lock to specific python and versions of given dependencies
184 test-reversion *TESTS # test django-revision integration
185 validate_version VERSION # validate the given version string against the lib version
186 ```