|
2 | 2 |
|
3 | 3 | ## Project Overview |
4 | 4 |
|
5 | | -Django Minify Compress Staticfiles: A Django package for minifying and compressing static files (CSS/JS) |
6 | | -with gzip and brotli support. |
| 5 | +`django-minify-compress-staticfiles` is a Django package for minifying and compressing static files with gzip and brotli support. |
7 | 6 |
|
8 | | -## Development Setup |
| 7 | +Core code lives in `django_minify_compress_staticfiles/`: |
9 | 8 |
|
10 | | -- Install dependencies: `pip install -e .` |
11 | | -- For testing with all features: `pip install -e .[test]` |
| 9 | +- Package modules implement static file minification, compression, storage helpers, and path safety checks. |
| 10 | +- Tests live in `tests/` and `test_staticfiles/`. |
12 | 11 |
|
13 | | -## Code Formatting |
| 12 | +## Source of Truth |
14 | 13 |
|
15 | | -To format code, run: |
| 14 | +- Use `README.rst` for setup and package usage. |
| 15 | +- Use `.github/workflows/ci.yml` for CI-tested dependencies, QA/test commands, env vars, and supported Python/Django versions. |
| 16 | +- Use GitHub issue/PR templates when asked to open issues or PRs. |
16 | 17 |
|
17 | | -```bash |
18 | | -openwisp-qa-format |
19 | | -``` |
| 18 | +If instructions conflict, repository config and CI workflows win first, docs next, and this file is supplemental. |
20 | 19 |
|
21 | | -## Testing |
| 20 | +## Development Notes |
22 | 21 |
|
23 | | -Run tests with: |
| 22 | +- Keep changes focused. Avoid unrelated refactors and formatting churn. |
| 23 | +- Preserve public APIs, storage behavior, compression outputs, and path safety checks unless explicitly required. |
| 24 | +- Avoid unnecessary blank lines inside function and method bodies. |
| 25 | +- Update docs when behavior, settings, public APIs, setup steps, or supported versions change. |
24 | 26 |
|
25 | | -```bash |
26 | | -python runtests.py |
27 | | -``` |
| 27 | +## Testing and QA |
28 | 28 |
|
29 | | -Coverage report: |
| 29 | +- Add or update tests for every behavior change. |
| 30 | +- For bug fixes, write the regression test first, run it against the unfixed code, confirm it fails for the expected reason, then implement the fix. |
| 31 | +- Run tests with `python runtests.py`; use `coverage run runtests.py && coverage report` when checking coverage. |
| 32 | +- Run `openwisp-qa-format` after editing. |
| 33 | +- Run `./run-qa-checks` before considering the change complete. Treat failures as blocking unless confirmed unrelated and reported. |
| 34 | +- Keep coverage above the repository threshold. |
30 | 35 |
|
31 | | -```bash |
32 | | -coverage run runtests.py |
33 | | -coverage report |
34 | | -``` |
| 36 | +## Security Notes |
35 | 37 |
|
36 | | -## QA Checks |
37 | | - |
38 | | -Run QA checks with: |
39 | | - |
40 | | -```bash |
41 | | -./run-qa-checks |
42 | | -``` |
43 | | - |
44 | | -This validates: |
45 | | - |
46 | | -- Python code formatting (isort, black, flake8) |
47 | | -- Blank endline checks |
48 | | -- ReStructuredText syntax |
49 | | -- Commit message format |
50 | | - |
51 | | -## General Guidelines |
52 | | - |
53 | | -- **Avoid unnecessary blank lines** - they bloat the code with no benefit. Use blank lines sparingly, only where PEP 8 requires them (e.g., between class methods, between imports and code). |
54 | | -- **Keep test coverage above 90%** - every new feature must include tests. |
55 | | -- Avoid other arbitrary formatting changes. |
56 | | -- Run `./run-qa-checks` before committing to ensure compliance. |
57 | | - |
58 | | -## Code Review Checklist |
59 | | - |
60 | | -When reviewing changes, always watch out for: |
61 | | - |
62 | | -- Missing tests (aim for >90% coverage). |
63 | | -- Unnecessary blank lines added. |
64 | | -- Performance penalties. |
65 | | -- Inconsistencies and duplication which can lead to maintenance overhead. |
66 | | -- Security issues (e.g., no secrets in code, safe file path validation). |
67 | | -- Path traversal vulnerabilities (ensure `is_safe_path()` is used). |
68 | | - |
69 | | -## Contributing Guidelines |
70 | | - |
71 | | -- [Follow OpenWISP contributing guidelines](https://openwisp.io/docs/dev/developer/contributing.html). |
72 | | -- Ensure commit messages follow the format: `[type] Description` (e.g., `[fix] Resolved compression issue`). |
| 38 | +- Watch for path traversal, unsafe file handling, malformed static file paths, and secrets in code. |
| 39 | +- Preserve validation around safe paths, minified output paths, compressed file creation, and static file discovery. |
| 40 | +- Write comments and docstrings only when they explain why code is shaped a certain way. Put comments before the relevant code block instead of scattering them inside it. |
73 | 41 |
|
74 | 42 | ## Troubleshooting |
75 | 43 |
|
76 | | -- QA/format commands fail: Ensure Python virtualenv is active and dependencies are installed. |
77 | | -- Tests fail: Check that `pip install -e .` was run. |
78 | | -- Coverage issues: Run `coverage run runtests.py && coverage report` locally. |
79 | | -- CI issues: Refer to `.github/workflows/ci.yml`. |
| 44 | +- If setup, QA, or tests fail, check docs first, then compare with CI. If commands diverge, follow CI. |
0 commit comments