Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ Always test backup and restore functionality after making changes using function
ls tmp/media/ # should show restored test.txt
```

4. **Single Backend Functional Runs (if triaging):**
4. **Single Backend Functional Runs:**
```bash
hatch run functional:sqlite --all
hatch run functional:postgres --all
hatch run functional:mysql --all
```

## Troubleshooting Known Issues
Expand All @@ -102,7 +103,9 @@ Modern development process using Hatch:
1. **Bootstrap environment**: `pip install --upgrade pip hatch uv`
2. **Make your changes** to the codebase
3. **Run unit tests**: `hatch test` (≈30s) **All must pass - failures are never expected or allowed.**
4. **Run functional tests**: `hatch run functional:all` (≈10–15s)
4. **Run functional tests**: `hatch run functional:all` (≈15–25s)
- Includes SQLite, PostgreSQL, and MySQL live tests
- MySQL tests are automatically skipped if MySQL server is not available
5. **Run linting**: `hatch run lint:check` (5 seconds)
6. **Auto-format code**: `hatch run lint:format` (2 seconds)
7. **Test documentation**: `hatch run docs:build` (2 seconds)
Expand All @@ -127,7 +130,7 @@ Key directories and files:
- `management/commands/` – Django management commands (dbbackup, dbrestore, mediabackup, mediarestore, listbackups)
- Core modules: `storage.py`, `settings.py`, `log.py`, `signals.py`, `utils.py`
- `tests/` – comprehensive test suite (unit + helpers)
- `scripts/` – live functional test scripts (`sqlite_live_test.py`, `postgres_live_test.py`)
- `scripts/` – live functional test scripts (`sqlite_live_test.py`, `postgres_live_test.py`, `mysql_live_test.py`)
- `docs/` – MkDocs Material source (built site output under `docs/site/` when building locally)
- `pyproject.toml` – project + Hatch environment configuration
- `.github/workflows/ci.yml` – CI matrix & publish pipeline
Expand All @@ -153,6 +156,7 @@ hatch test --python 3.12 # Test specific Python version subset
hatch run functional:all # Functional tests (SQLite + PostgreSQL)
hatch run functional:sqlite --all # Functional tests (SQLite only)
hatch run functional:postgres --all # Functional tests (PostgreSQL only)
hatch run functional:mysql --all # Functional tests (MySQL only)
hatch run lint:check # Lint (ruff + pylint)
hatch run lint:format # Auto-format
hatch run lint:format-check # Format check only
Expand Down Expand Up @@ -181,7 +185,7 @@ Modern isolated environments configured in pyproject.toml:
### Testing Environments

- **hatch-test**: Unit testing (Python 3.9–3.13 × Django 4.2/5.0/5.1/5.2 matrix)
- **functional**: End-to-end backup/restore (filesystem storage; live SQLite & PostgreSQL scripts)
- **functional**: End-to-end backup/restore (filesystem storage; live SQLite, PostgreSQL & MySQL scripts)

### Development Environments

Expand Down Expand Up @@ -225,7 +229,7 @@ Core runtime dependency:

Development dependencies (managed by hatch):

- **Testing**: coverage, django-storages, psycopg2-binary, python-gnupg, testfixtures, python-dotenv
- **Testing**: coverage, django-storages, psycopg2-binary, mysqlclient, python-gnupg, testfixtures, python-dotenv
- **Linting**: ruff, pylint
- **Documentation**: mkdocs, mkdocs-material, mkdocs-git-revision-date-localized-plugin, mkdocs-include-markdown-plugin, mkdocs-spellcheck[all], mkdocs-git-authors-plugin, mkdocs-minify-plugin, mike, linkcheckmd
- **Pre-commit**: pre-commit
Expand All @@ -236,7 +240,7 @@ Modern GitHub Actions workflow (.github/workflows/build.yml):

- **Lint Python**: Code quality checks (temporarily set to pass)
- **Test Python**: Matrix testing across Python 3.9-3.13 with coverage
- **Functional Tests**: End-to-end backup/restore verification (SQLite + PostgreSQL live scripts)
- **Functional Tests**: End-to-end backup/restore verification (SQLite, PostgreSQL & MySQL live scripts)
- **Coverage**: Artifact-based coverage combining with 80% threshold
- **Build**: Package building with hatch
- **Publish GitHub**: Automated GitHub release creation on tags
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ jobs:
cache: pip
- name: Install dependencies
run: python -m pip install --upgrade pip hatch uv
- name: Setup MySQL
if: matrix.os == 'ubuntu-latest'
uses: kayqueGovetri/[email protected]
with:
mysql_root_password: "mysql"
mysql_port: 3306
- name: Setup postgres
uses: ikalnytskyi/action-setup-postgres@v7
- run: psql postgresql://postgres:postgres@localhost:5432/postgres -c "SELECT 1"
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to
# install dependencies, you'll need the `contents: read` permission. If you don't
# clone the repository in your setup steps, Copilot will do this for you automatically
# after the steps complete.
contents: read

# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install MySQL
uses: kayqueGovetri/[email protected]
with:
mysql_root_password: "mysql"
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ environment variables adjust its behavior:

Database engine to use. See `django.db.backends` for default backends.

**`DB_NAME`** - Default: `:memory:`
**`DB_NAME`** - Default: `/tmp/test_db.sqlite3`

Database name. Adjust for non-SQLite backends.

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extra-dependencies = [
"testfixtures",
"django",
"psycopg2-binary",
# "mysqlclient",
"mysqlclient",
]

[tool.hatch.envs.functional.env-vars]
Expand All @@ -190,9 +190,11 @@ DB_NAME = "tmp/test_db.sqlite3"
all = [
"hatch run functional:sqlite --all {args}",
"hatch run functional:postgres --all {args}",
"hatch run functional:mysql --all {args}",
]
sqlite = ["python scripts/sqlite_live_test.py {args}"]
postgres = ["python scripts/postgres_live_test.py {args}"]
mysql = ["python scripts/mysql_live_test.py {args}"]

# >>> Generic Tools <<<

Expand Down
11 changes: 9 additions & 2 deletions scripts/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
print(SYMS['PASS'], 'Test passed')

Provided symbol keys:
PASS, FAIL, SUMMARY, TEST, PG
PASS, FAIL, SUMMARY, TEST, PG, MYSQL

The ``PG`` key is only used by the PostgreSQL live test; others are shared.
The ``PG`` key is only used by the PostgreSQL live test; ``MYSQL`` is only
used by the MySQL live test; others are shared.
"""

from __future__ import annotations
Expand All @@ -26,15 +27,21 @@
"FAIL": "❌",
"SUMMARY": "📊",
"TEST": "📋",
"SKIP": "⏭️",
"INFO": "ℹ️",
"PG": "🐘",
"MYSQL": "🐬",
}

_ASCII_SYMBOLS = {
"PASS": "PASS:",
"FAIL": "FAIL:",
"SUMMARY": "SUMMARY:",
"TEST": "TEST:",
"SKIP": "SKIP:",
"INFO": "INFO:",
"PG": ">>",
"MYSQL": ">>",
}


Expand Down
Loading
Loading