Skip to content

Commit b059a64

Browse files
CopilotArchmonger
andcommitted
Complete Hatch migration - remove legacy files and modernize workflow
Co-authored-by: Archmonger <16909269+Archmonger@users.noreply.github.com>
1 parent cd492f0 commit b059a64

File tree

8 files changed

+170
-210
lines changed

8 files changed

+170
-210
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ jobs:
6363
- name: Run tests
6464
run: |
6565
hatch test --cover --python ${{ matrix.python-version }}
66+
mv .coverage ".coverage.py${{ matrix.python-version }}"
6667
67-
- name: Upload coverage
68-
uses: codecov/codecov-action@v5
68+
- name: Upload coverage data
69+
uses: actions/upload-artifact@v4
6970
with:
70-
name: Python ${{ matrix.python-version }} Codecov
71-
fail_ci_if_error: true
72-
token: ${{ secrets.CODECOV_TOKEN }}
71+
name: "coverage-data-py${{ matrix.python-version }}"
72+
path: ".coverage.py${{ matrix.python-version }}"
73+
if-no-files-found: error
74+
include-hidden-files: true
75+
retention-days: 7
7376

7477
test-functional:
7578
name: Functional Tests
@@ -92,3 +95,36 @@ jobs:
9295
- name: Run functional tests
9396
run: |
9497
hatch run functional:test
98+
99+
coverage-python:
100+
name: Check Python Coverage
101+
runs-on: ubuntu-latest
102+
needs:
103+
- test-python
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- uses: actions/setup-python@v5
108+
with:
109+
python-version: "3.x"
110+
cache: pip
111+
112+
- name: Install dependencies
113+
run: python -m pip install --upgrade coverage[toml]
114+
115+
- name: Download data
116+
uses: actions/download-artifact@v4
117+
with:
118+
merge-multiple: true
119+
120+
- name: Combine coverage and fail if it's <80%
121+
run: |
122+
python -m coverage combine
123+
python -m coverage html --skip-covered --skip-empty
124+
python -m coverage report --fail-under=80
125+
126+
- name: Upload HTML report
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: coverage-report
130+
path: htmlcov

Makefile

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

codecov.yml

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

dbbackup/tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
import django
3+
4+
def pytest_configure():
5+
"""Configure Django for pytest."""
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dbbackup.tests.settings")
7+
django.setup()

docs/contributing.md

Lines changed: 91 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,89 @@
11
# Contributing guide
22

3-
Dbbackup is a free license software where all help are welcomed. This
3+
Django-dbbackup is a free license software where all help is welcomed. This
44
documentation aims to help users or developers to bring their contributions
55
to this project.
66

7+
## Creating a development environment
8+
9+
If you plan to make code changes to this repository, you will need to install the following dependencies first:
10+
11+
- [Git](https://git-scm.com/downloads)
12+
- [Python 3.9+](https://www.python.org/downloads/)
13+
- [Hatch](https://hatch.pypa.io/latest/)
14+
15+
Once you finish installing these dependencies, you can clone this repository:
16+
17+
```shell
18+
git clone https://github.com/Archmonger/django-dbbackup.git
19+
cd django-dbbackup
20+
```
21+
22+
## Executing test environment commands
23+
24+
By utilizing `hatch`, the following commands are available to manage the development environment.
25+
26+
### Tests
27+
28+
| Command | Description |
29+
| --- | --- |
30+
| `hatch test` | Run Python tests using the current environment's Python version |
31+
| `hatch test --all` | Run tests using all compatible Python and Django versions |
32+
| `hatch test --python 3.9` | Run tests using a specific Python version |
33+
| `hatch test --include "django=5.1"` | Run tests using a specific Django version |
34+
| `hatch test -k test_backup_filter` | Run only a specific test |
35+
36+
??? question "What other arguments are available to me?"
37+
38+
The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`.
39+
40+
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.
41+
42+
### Linting and Formatting
43+
44+
| Command | Description |
45+
| --- | --- |
46+
| `hatch run lint:format` | Run formatters to fix code style |
47+
| `hatch run lint:format-check` | Check code formatting without making changes |
48+
| `hatch run lint:check` | Run all linters |
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` and `pylint` 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+
### Functional Testing
59+
60+
| Command | Description |
61+
| --- | --- |
62+
| `hatch run functional:test` | Run end-to-end backup and restore tests |
63+
64+
The functional tests perform real database and media backup/restore cycles to ensure the commands work correctly.
65+
66+
### Documentation
67+
68+
| Command | Description |
69+
| --- | --- |
70+
| `hatch run docs:serve` | Start the [`mkdocs`](https://www.mkdocs.org/) server to view documentation locally |
71+
| `hatch run docs:build` | Build the documentation |
72+
73+
### Environment Management
74+
75+
| Command | Description |
76+
| --- | --- |
77+
| `hatch build --clean` | Build the package from source |
78+
| `hatch env prune` | Delete all virtual environments created by `hatch` |
79+
| `hatch python install 3.12` | Install a specific Python version to your system |
80+
81+
??? tip "Check out Hatch for all available commands!"
82+
83+
This documentation only covers commonly used commands.
84+
85+
You can type `hatch --help` to see all available commands.
86+
787
## Submit a bug, issue or enhancement
888

989
All communication are made with [GitHub issues](https://github.com/Archmonger/django-dbbackup/issues). Do not hesitate to open a
@@ -21,62 +101,26 @@ of requests we advise you to:
21101

22102
1. Fork the project and make a new branch
23103
2. Make your changes with tests if possible and documentation if needed
24-
3. Push changes to your fork repository and test it with Travis
25-
4. If it succeeds, open a pull request
26-
5. Bother us until we give you an answer
104+
3. Run `hatch test` and `hatch run functional:test` to verify your changes
105+
4. Run `hatch run lint:check` to ensure code quality
106+
5. Push changes to your fork repository and test it with GitHub Actions
107+
6. If it succeeds, open a pull request
108+
7. Bother us until we give you an answer
27109

28110
!!! note
29-
We advise you to launch it with Python 2 & 3 before push and try it in
30-
Travis. DBBackup uses a lot of file operations, so breaks between Python
31-
versions are easy.
32-
33-
## Test environment
34-
35-
We provides tools to help developers to quickly test and develop DBBackup.
36-
There are 2 majors scripts:
37-
38-
* `runtests.py`: Unit tests launcher and equivalent of `manage.py` in
39-
the test project.
40-
* `functional.sh`: Shell script that use `runtests.py` to create a
41-
database backup and restore it, the same with media, and test if they are
42-
restored.
43-
44-
### `runtests.py`
45-
46-
You can test code on your local machine with the `runtests.py` script:
47-
48-
```bash
49-
python runtests.py
50-
```
51-
52-
But if argument are provided, it acts as `manage.py` so you can simply
53-
launch some other command to test deeply, example:
54-
55-
```bash
56-
# Enter in Python shell
57-
python runtests.py shell
58-
59-
# Launch a particular test module
60-
python runtests.py test dbbackup.tests.test_utils
61-
```
62-
63-
All tests are stored in `dbbackup.tests`.
64-
65-
### `functional.sh`
66-
67-
It tests at a higher level if backup/restore mechanism is alright. It
68-
becomes powerful because of the configuration you can give to it. See the next
69-
chapter for explanation about it.
111+
We recommend testing with multiple Python and Django versions using
112+
`hatch test --all` before pushing. DBBackup uses a lot of file operations,
113+
so breaks between versions are possible.
70114

71-
### Configuration
115+
## Test environment configuration
72116

73117
DBBackup contains a test Django project at `dbbackup.tests` and its
74118
`settings` module. This configuration takes care of the following
75119
environment variables:
76120

77121
**DB_ENGINE** - Default: `django.db.backends.sqlite3`
78122

79-
Databank-Engine to use. See in django.db.backends for default backends.
123+
Database engine to use. See django.db.backends for default backends.
80124

81125
**DB_NAME** - Default: `:memory:`
82126

functional.sh

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

0 commit comments

Comments
 (0)