Advanced¶
To host your own template based on opentemplate, you can follow these steps:
- Fork the repository ⧉ to your own GitHub account/organization
- Make it a template repository ⧉
- Follow the steps in the quick start guide (e.g. hardening)
- Clone the repository,
pdm setupand perform your changes
Tip
Improvements to opentemplate are welcome! Please open an issue, discuss with the maintainers and your features might be upstreamed.
General¶
Many of the adjustments will be tested as you develop them, as opentemplate is also a Python package.
Caveats to remember:
.github/workflows/template-*- files should be of special interest as they are used fortemplaterelated functionality, e.g. testing.github/workflows/release*.yml- most complex workflow, a few parts are not fully tested currently.
Tips¶
When adding a new feature (e.g. tool/check) you might consider the following algorithm-like steps:
-
Check if the tool is available as a Python package (e.g. on
PyPI⧉) -
If yes and it fits in one of the categories (e.g.
dev-python):-
Add the package to
pyproject.toml(usuallydev-<category>in[dependency-groups]section) -
Specify only the major version (e.g.
>=1) if above1.0.0, or the exact version if below1.0.0 -
Add the tool call to
[tool.pdm.scripts]undercheck-<category>andfix-<category>if applicable -
Go to testing steps below
-
-
If yes, but the appropriate category does not exist:
-
Create a new
dev-<category>and put the package there -
Create appropriate entry in
.pre-commit-config.yamlunder the- repo: "local"section,id: <category> -
Create an entry in
.github/renovate.jsonwith appropriatematchPackageNames⧉ -
Create three workflows in
.github/workflows(seeGitHub Actionsguide for more details):-
<category>.yml- checker run on human PRs -
<category>-renovate.yml- checker run on Renovate PRs -
<category>-reusable.yml- checker run used by the other two and which (probably) uses.github/workflows/check-reusable.yml
-
-
Go to testing steps below
-
-
If not:
-
Create appropriate entry in
.pre-commit-config.yamlif the tool is available as apre-commithook (or try to create one if not) -
Add support for the tool in
.github/renovate.json/(if applicable and available) -
Create three workflows in
.github/workflows(seeGitHub Actionsguide for more details):-
<category>.yml- checker run on human PRs -
<category>-update.yml- if the tool requires updates, but not supported byrenovate⧉
-
-
Tip
Order of the .pre-commit-config.yaml entries is important. Make sure to think about the implications of the changes done by your entry on the whole pipeline.
Caution
This is a rough guide and in many specific cases you might have to consult specific functionalities and their implementation (start by consulting details documentation).