Skip to content

Advanced

To host your own template based on opentemplate, you can follow these steps:

  1. Fork the repository ⧉ to your own GitHub account/organization
  2. Make it a template repository ⧉
  3. Follow the steps in the quick start guide (e.g. hardening)
  4. Clone the repository, pdm setup and 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 for template related 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:

  1. Check if the tool is available as a Python package (e.g. on PyPI ⧉)

  2. If yes and it fits in one of the categories (e.g. dev-python):

    1. Add the package to pyproject.toml (usually dev-<category> in [dependency-groups] section)

    2. Specify only the major version (e.g. >=1) if above 1.0.0, or the exact version if below 1.0.0

    3. Add the tool call to [tool.pdm.scripts] under check-<category> and fix-<category> if applicable

    4. Go to testing steps below

  3. If yes, but the appropriate category does not exist:

    1. Create a new dev-<category> and put the package there

    2. Create appropriate entry in .pre-commit-config.yaml under the - repo: "local" section, id: <category>

    3. Create an entry in .github/renovate.json with appropriate matchPackageNames ⧉

    4. Create three workflows in .github/workflows (see GitHub Actions guide for more details):

      1. <category>.yml - checker run on human PRs

      2. <category>-renovate.yml - checker run on Renovate PRs

      3. <category>-reusable.yml - checker run used by the other two and which (probably) uses .github/workflows/check-reusable.yml

    5. Go to testing steps below

  4. If not:

    1. Create appropriate entry in .pre-commit-config.yaml if the tool is available as a pre-commit hook (or try to create one if not)

    2. Add support for the tool in .github/renovate.json/ (if applicable and available)

    3. Create three workflows in .github/workflows (see GitHub Actions guide for more details):

      1. <category>.yml - checker run on human PRs

      2. <category>-update.yml - if the tool requires updates, but not supported by renovate ⧉

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).