Debian Codegraph @

docs/src/contributing.md

raw
1 # Contributing guide
2
3 django-dbbackup is free licensed software and community contributions are
4 welcome. This guide explains how to develop, test, and propose changes.
5
6 ## Creating a development environment
7
8 If you plan to make code changes to this repository, you will need to install the following dependencies first:
9
10 - [Git](https://git-scm.com/downloads)
11 - [Python 3.9+](https://www.python.org/downloads/)
12 - [Hatch](https://hatch.pypa.io/latest/)
13
14 Once you finish installing these dependencies, you can clone this repository:
15
16 ```shell
17 git clone https://github.com/Archmonger/django-dbbackup.git
18 cd django-dbbackup
19 ```
20
21 ## Executing test environment commands
22
23 `hatch` manages isolated environments; the commands below cover common tasks.
24
25 ### Tests
26
27 | Command | Description |
28 | ------------------------------------- | --------------------------------------------------------------- |
29 | `hatch test` | Run Python tests using the current environment's Python version |
30 | `hatch test --all` | Run tests using all compatible Python and Django versions |
31 | `hatch test --python 3.9` | Run tests using a specific Python version |
32 | `hatch test --include "django=5.1"` | Run tests using a specific Django version |
33 | `hatch test -k test_backup_filter` | Run only a specific test |
34 | `hatch run functional:sqlite --all` | Run end-to-end SQLite backup and restore tests |
35 | `hatch run functional:postgres --all` | Run end-to-end PostgreSQL tests using all compatible connectors |
36
37 ??? question "What other arguments are available to me?"
38
39 The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`.
40
41 Any additional arguments in the `test` command are directly passed on to pytest. See the [pytest documentation](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags) for what additional arguments are available.
42
43 ### Linting and Formatting
44
45 | Command | Description |
46 | ---------------------------- | ------------------------------------------------------------------------------------------ |
47 | `hatch fmt` | Run formatters to fix code style |
48 | `hatch fmt --check` | Check code formatting without making changes |
49 | `hatch run precommit:check` | Run all [`pre-commit`](https://pre-commit.com/) checks configured within this repository |
50 | `hatch run precommit:update` | Update the [`pre-commit`](https://pre-commit.com/) hooks configured within this repository |
51
52 ??? tip "Configure your IDE for linting"
53
54 This repository uses `ruff` for linting and formatting.
55
56 You can install `ruff` as a plugin to your preferred code editor to create a similar environment.
57
58 ### Documentation
59
60 | Command | Description |
61 | ---------------------- | ---------------------------------------------------------------------------------- |
62 | `hatch run docs:serve` | Start the [`mkdocs`](https://www.mkdocs.org/) server to view documentation locally |
63 | `hatch run docs:build` | Build the documentation |
64
65 ### Environment Management
66
67 | Command | Description |
68 | --------------------------- | -------------------------------------------------- |
69 | `hatch build --clean` | Build the package from source |
70 | `hatch env prune` | Delete all virtual environments created by `hatch` |
71 | `hatch python install 3.12` | Install a specific Python version to your system |
72
73 ??? tip "Check out Hatch for all available commands!"
74
75 This documentation only covers commonly used commands.
76
77 You can type `hatch --help` to see all available commands.
78
79 ## Submit a bug, issue or enhancement
80
81 Track bugs, feature proposals, and questions via
82 [GitHub Issues](https://github.com/Archmonger/django-dbbackup/issues). Open an
83 issue if:
84
85 - You have an improvement idea
86 - You found a bug
87 - You've got a question
88 - More generally something seems wrong for you
89
90 ## Make a patch
91
92 We use [pull requests](https://github.com/Archmonger/django-dbbackup/pulls) for
93 all code changes. To streamline review:
94
95 1. Fork the project and make a new branch
96 2. Make your changes with tests if possible and documentation if needed
97 3. Run `hatch test` and `hatch run functional:all` to verify your changes
98 4. Run `hatch fmt` to ensure code quality
99 5. Push changes to your fork repository and test it with GitHub Actions
100 6. If it succeeds, open a pull request
101 7. Follow up politely if there's no feedback after a few days
102
103 !!! note
104
105 We recommend testing with multiple Python and Django versions using
106 `hatch test --all` before pushing. DBBackup uses a lot of file operations,
107 so breaks between versions are possible.
108
109 ## Test environment configuration
110
111 The test suite uses a self contained Django project (`dbbackup.tests`). These
112 environment variables adjust its behavior:
113
114 **`DB_ENGINE`** - Default: `django.db.backends.sqlite3`
115
116 Database engine to use. See `django.db.backends` for default backends.
117
118 **`DB_NAME`** - Default: `:memory:`
119
120 Database name. Adjust for non-SQLite backends.
121
122 **`DB_USER`** - Default: `None`
123
124 Database username
125
126 **`DB_PASSWORD`** - Default: `None`
127
128 Database password
129
130 **`DB_HOST`** - Default: `None`
131
132 Database host
133
134 **`MEDIA_ROOT`** - Default: `tmp/media/`
135
136 Django `MEDIA_ROOT`; override to test media backup from a custom path.
137
138 **`STORAGE`** - Default: `dbbackup.tests.utils.FakeStorage`
139
140 Storage class used for backups.
141
142 **`STORAGE_OPTIONS`**
143
144 Comma separated `key=value` pairs parsed into a dict passed to the storage
145 constructor.