Synapse Module Cookiecutter Template
This is a Cookiecutter template for creating new Synapse modules.
What you get:
- a Synapse module package
- a
README
with basic instructions on installation, development and releasing setup.cfg
metadata (the declarative equivalent ofsetup.py
)- CI configurations for
- GitHub Actions
- GitLab
- code checking tools (invokable with
tox
, checked in CI)- code formatting using
black
andisort
- code style checking using
flake8
- type checking using
mypy
(with checking against Synapse supported in Synapse 1.46 and later)- strict by default (configurable in
mypy.ini
)
- strict by default (configurable in
- code formatting using
- unit testing using
trial
(invokable withtox
, checked in CI) - Specific to the 'Synapse Team' variant:
CODEOWNERS
for automatic review requests for thesynapse-core
team on GitHub when a pull request is opened- The Apache 2.0 licence with copyright notices
Please refer to the Synapse 'Writing a module' documentation for descriptions and examples (at the bottom of most pages) of using the Synapse module API, including registering callbacks.
How to use this template
Install Cookiecutter
To use this template, you will first need to install Cookiecutter.
Full instructions to do so can be found in the Cookiecutter documentation,
but in summary, pip install --user cookiecutter
or sudo apt install cookiecutter
will do if you use pip
or apt
.
Use Cookiecutter to get your project going
cd
to a directory where you would like to create a new project as a subdirectory, then run
cookiecutter https://github.com/matrix-org/synapse-module-cookiecutter-template.git
You will then be asked a series of questions to populate your project:
directory_name
: Specify the name of a project directory. This directory will be created.module_human_name
: Specify a human-readable module name here. This is used in theREADME
file and the changelog.package_description
: Specify a human-readable module description. This is used in theREADME
file andsetup.cfg
file.package_name
: Specify a snake_case Python package name here. This will be used as the package name for your module.module_class_name
: Specify a PascalCase Python class name here. This will be used as the class name for your module class.main_git_branch
: Specify the name of your main Git branch here. Although this template does not initialise a Git repository automatically, the CI configuration and suggested release instructions mention it. This is commonlymain
,master
,trunk
,default
ordevelop
.variant
: Choose whether or not to include the 'Synapse Team'-specific customisations; picksynapse_team
if the module will be maintained by the Synapse Team. Otherwise, pickstandard
.
If all goes well, you should now have a project starter!
Set up Git
What you do from here on is up to you!
However, it's probably worth initialising a Git repository and making the first commit be exactly what is produced by this template. (Doing this may make it easier to upgrade an existing project to a later version of the template in the future: you could branch off from the initial commit, re-run the template generator, commit, and then merge that branch into your main branch.)
If you use GitHub or GitLab, you should use its web interface to enable the included CI configuration.
Notes for developing this template
During development, you can clone this repository and call
cookiecutter path/to/synapse-module-cookiecutter-template
when needed, to test your changes.