Development

There’s a basic Django project in devproject/ to make it easier to work on the app. This might be enough to get things up and running (assumes pipenv is installed):

$ cd devproject
$ virtualenv --prompt ditto-devproject venv
$ source venv/bin/activate
(ditto-devproject)$ pyenv local 3.10.5
(ditto-devproject)$ python -m pip install -r requirements.txt

Then run migrations and start the server:

(ditto-devproject)$ ./manage.py migrate
(ditto-devproject)$ ./manage.py runserver

pre-commit will run flake8, black, isort and prettier across all files on commit. I think you just need to do this first:

$ pre-commit install

You can add a .env file in devproject/ and its environment variables will be read in devproject/devproject/settings.py. e.g.:

DJANGO_SECRET_KEY="your-secret-key"
DJANGO_LOG_LEVEL="INFO"

pre-commit will run flake8, black, isort and prettier across all files on commit. I think you just need to do this first:

$ pre-commit install

Tests

Run tests with tox. Install it with:

$ pip install tox

You’ll need to have all versions of python available that are tested against (see tox.ini). This might mean deactivating a virtualenv if you’re using one with devproject/. Then run all tests in all environments like:

$ tox

To run tests in only one environment, specify it. In this case, Python 3.11 and Django 4.2:

$ tox -e py311-django42

To run a specific test, add its path after --, eg:

$ tox -e py311-django42 -- tests.flickr.test_views.HomeViewTests.test_home_templates

Running the tests in all environments will generate coverage output. There will also be an htmlcov/ directory containing an HTML report. You can also generate these reports without running all the other tests:

$ tox -e coverage

Other notes for development

Coverage

Using coverage.py to check test coverage:

$ coverage run --source='.' ./manage.py test
$ coverage report

Instead of the in-terminal report, get an HTML version:

$ coverage html
$ open -a "Google Chrome" htmlcov/index.html

Documentation

You’ll need sphinx installed. You could do this using pip and the requirements.txt file:

$ cd docs
$ virtualenv --prompt ditto-docs venv
$ source venv/bin/activate
(ditto-docs)$ python -m pip install -r requirements.txt

Build the documentation:

(ditto-docs)$ make html

Packaging

Set version number in ditto/__init__.py.

Rebuild documentation (which includes the version number).

Ensure CHANGELOG.md is up-to-date for new version.

Commit changes to git.

Ensure GitHub Actions still build OK.

Add a version tag:

$ python setup.py tag

Then:

$ python setup.py publish