This project combines test-driven development with the Git feature branch workflow. Please submit your changes for review as a GitHub pull request. Changes must include functional and integration tests.
This project requires Python 3.10 and Docker 20.10 (or newer). To set up your development environment on Linux, run these commands from the project root directory:
-
sudo make build-deps
—installs build dependencies (Debian/Ubuntu only) -
make
—creates (or updates) a virtual environment named.venv
in the project root directory and performs an editable installation of this project plus development and testing tools -
make pre-commit
—installs optional pre-commit hooks that require the virtual environment to be active in your code editor or Git porcelain -
. .venv/bin/activate
(Bourne shells),source .venv/bin/activate.csh
(C shells), etc.—activates the virtual environment
Additional make(1) targets are available, several of which are listed below. Review the Makefile for details.
-
make test
—performs comprehensive functional and integration testing of this project -
make smoke
—runs a subset of the test suite (SQLite-only) -
make docker
—builds a fully tested and release-ready container image
The following code styles are in use:
This project implements Semantic Versioning 2.0.0 using Conventional Commits 1.0.0. Please use English in commit messages. The first line of the commit message should be at most 100 characters, while the rest of the commit message should be wrapped at column 70. A commit's description should be a verb phrase in the imperative present tense, with the starting verb in lower case and no ending punctuation.
Valid commit types are:
-
build—changes to the build system or external dependencies
-
ci—changes to the CI configuration files and scripts
-
docs—documentation-only changes
-
feat—a new feature
-
fix—a bug fix
-
perf—a code change that improves performance
-
refactor—a code change that neither fixes a bug nor adds a feature
-
test—new tests or corrections to existing tests
A commit's scope should be the second-level Python module name sans the lethbridge.
prefix or any suffixes with a few exceptions. Valid commit scopes are:
-
lethbridge and main—for the corresponding top-level dunder modules
-
config—the default configuration and related helper functions
-
database—the data model, defined using SQLAlchemy ORM
-
migrations—database schema migrations handled by Alembic
-
schemas—parsers for data imports and exports defined using marshmallow-sqlalchemy
-
packaging—package layout or other metadata, e.g., the arrangement of src/, alterations to pyproject.toml or Dockerfile
-
no scope—for refactor or test changes covering multiple scopes or for build, ci, or docs changes not specific to one scope
This project uses Alembic to manage the database schema on supported engines via the multidb migration template. Alembic commands MUST be run from the project root directory, i.e., the same directory as alembic.ini. For convenience's sake, the Makefile provides these targets:
-
make alembic-start
andmake alembic-stop
—creates or destroys databases for use by Alembic or other project development work -
make alembic-backup
andmake alembic-restore
—dumps or loads data into the above databases -
make alembic-<COMMAND> ARGS="[ARGUMENT]..."
—a generic wrapper for Alembic commands, e.g.,make alembic-history ARGS="-v -i"
; uses the databases created bymake alembic-start
To develop a new database migration:
-
After modifying the data model, generate a new schema revision with
make alembic-autogenerate MESSAGE="<revision summary>"
. WARNING: This command will delete any existing databases created bymake alembic-start
. Revision summaries should mirror the corresponding Git commit description, e.g.,address conflict with FDevIDs
. -
Review the new schema revision. Alembic cannot detect certain changes, e.g., renaming tables or column names, nor can it create data transformations. The developer must handle these cases. For more information, refer to "What does Autogenerate Detect (and what does it not detect?)" in the Alembic documentation.
-
Create database dumps for integration testing from the mock galaxy data with
make migration-test-fixtures
. WARNING: This command will delete any existing databases created bymake alembic-start
. -
Add the new revision to the database migration tests.
To add support for a new database engine:
-
In the Alembic configuration file, alembic.ini, add the engine to the
databases
list in alembic.ini. Add a section for that engine between the[alembic]
and[post_write_hooks]
sections. In the new database section, specify asqlalchemy.url
for the engine. DO NOT commit usernames or passwords as part of recorded changes to alembic.ini. -
In the Makefile, add support for the new engine to the
alembic-%
target and thegenerate-migration-test-fixture-target
macro.