|
| 1 | +.. SPDX-FileCopyrightText: 2026 cusy GmbH |
| 2 | +.. |
| 3 | +.. SPDX-License-Identifier: BSD-3-Clause |
| 4 | +
|
| 5 | +Separating environments |
| 6 | +======================= |
| 7 | + |
| 8 | +Current best practice is to separate different environments depending on what is |
| 9 | +to be done in each one. For example, in our `cusy.tasks |
| 10 | +<https://github.com/cusyio/cusy.tasks>`_ application, a distinction is made |
| 11 | +between the following environments: |
| 12 | + |
| 13 | +.. code-block:: toml |
| 14 | + :caption: pyproject.toml |
| 15 | +
|
| 16 | + [project] |
| 17 | +
|
| 18 | + dependencies = [ |
| 19 | + "rich", |
| 20 | + "tinydb", |
| 21 | + "typer", |
| 22 | + ] |
| 23 | +
|
| 24 | + [dependency-groups] |
| 25 | + dev = [ |
| 26 | + "pre-commit", |
| 27 | + "reuse", |
| 28 | + "tox-uv", |
| 29 | + "watchgha", |
| 30 | + { include-group = "docs" }, |
| 31 | + { include-group = "tests" }, |
| 32 | + ] |
| 33 | + docs = [ |
| 34 | + "furo", |
| 35 | + "interrogate", |
| 36 | + "matplotlib", |
| 37 | + "sphinx-copybutton", |
| 38 | + "sphinx-inline-tabs", |
| 39 | + "sphinxcontrib-napoleon", |
| 40 | + "sphinxext-opengraph", |
| 41 | + ] |
| 42 | + tests = [ |
| 43 | + "coverage[toml]", |
| 44 | + "faker", |
| 45 | + "pytest", |
| 46 | + "pytest-cov", |
| 47 | + ] |
| 48 | +
|
| 49 | +This means that when the application is running, only the dependencies required |
| 50 | +for that purpose are installed; additional dependencies are only installed when |
| 51 | +testing or deploying the documentation. Only the development environment |
| 52 | +contains all dependencies. |
| 53 | + |
| 54 | +Just as your Python environment should be kept up to date with immutable |
| 55 | +references, your :doc:`../git/advanced/hooks/checks` and GitHub Actions should |
| 56 | +also be updated regularly. |
| 57 | + |
| 58 | +In the :file:`.pre-commit-config.yaml` file, the versions of the checks and |
| 59 | +their hashes should be updated regularly, for example using: |
| 60 | + |
| 61 | +.. code-block:: console |
| 62 | +
|
| 63 | + $ uv run prek update --freeze --cooldown-days 7 |
| 64 | + https://github.com/pre-commit/pre-commit-hooks |
| 65 | + updating rev `v6.0.0` -> `3e8a8703264a2f4a69428a0aa4dcb512790b2c8c` (frozen: v6.0.0) |
| 66 | +
|
| 67 | +.. seealso:: |
| 68 | + :doc:`../git/advanced/hooks/prek` |
| 69 | + |
| 70 | +.. _pinact: |
| 71 | + |
| 72 | +Check your GitHub Actions |
| 73 | +------------------------- |
| 74 | + |
| 75 | +For GitHub Actions, you can use `pinact |
| 76 | +<https://github.com/suzuki-shunsuke/pinact>`_, for example with: |
| 77 | + |
| 78 | +.. code-block:: console |
| 79 | +
|
| 80 | + $ pinact run -u --min-age 7 |
| 81 | +
|
| 82 | +`zizmor <https://docs.zizmor.sh>`_ is a static analysis tool that detects |
| 83 | +security vulnerabilities in GitHub Actions workflows – including template |
| 84 | +injection, unpinned actions, excessive permissions, credential exposure and |
| 85 | +`more than 30 other checks <>https://docs.zizmor.sh/audits/`_. zizmor identifies |
| 86 | +vulnerabilities such as those exploited through :ref:`token_exfiltration`. |
| 87 | + |
| 88 | +.. seealso:: |
| 89 | + * :ref:`zizmorcore` |
0 commit comments