Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
53934b3
Fix indentation error in unreleased.md
ArBridgeman Jan 21, 2026
73bfc42
Prepare BaseConfig for usage in jinja templates
ArBridgeman Jan 21, 2026
ba966dc
Modify templates & add render code for output and diff
ArBridgeman Jan 22, 2026
d8fff5c
Adapt unit test as updated BaseConfig
ArBridgeman Jan 22, 2026
1465482
Expand test to check all of them
ArBridgeman Jan 22, 2026
4496bae
Simplify code and add tests for DependencyManager
ArBridgeman Jan 22, 2026
ac88dd2
Add test for os_version check
ArBridgeman Jan 22, 2026
d9f2035
Fix type error
ArBridgeman Jan 22, 2026
c9aa61d
Add yaml and yaml stubs
ArBridgeman Jan 22, 2026
472298e
Fix type errors
ArBridgeman Jan 22, 2026
3c96a2a
Add changelog entry
ArBridgeman Jan 22, 2026
077e4dc
Update poetry lock
ArBridgeman Jan 22, 2026
5f4c92d
Add deprecation warnings
ArBridgeman Jan 22, 2026
1794215
Temporarily allow noxconfig import for this usecase only
ArBridgeman Jan 22, 2026
eba731f
Add test for _render_template
ArBridgeman Jan 22, 2026
43baa27
Merge branch 'main' into feature/667_fill_in_templates_with_defaults
ArBridgeman Jan 22, 2026
61f1afe
Fix unit test post main merge
ArBridgeman Jan 22, 2026
0047a5a
Fix security concern by putting autoescape to True
ArBridgeman Jan 22, 2026
e3739c0
Remove unneeded ref
ArBridgeman Jan 22, 2026
9840640
Take suggestion to move information into the docs
ArBridgeman Jan 23, 2026
d963a67
Apply review modification
ArBridgeman Jan 23, 2026
d4f48c1
Apply review modification
ArBridgeman Jan 23, 2026
e2301a5
Generalize comment to reduce where changes needed
ArBridgeman Jan 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .import_linter_config
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ignore_imports =
# To reduce the effort in using nox sessions (i.e. having to pass the config path
# in each CLI usage), we allow the noxconfig to be imported within these modules.
exasol.toolbox.nox.* -> noxconfig
exasol.toolbox.tools.template -> noxconfig
37 changes: 25 additions & 12 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ In previous versions, the default value for `poetry-version` was `2.1.2`, and it
* Depending on its poetry version, a repository relying on the default behavior of said
action may run into breaking changes. This can easily be resolved with explicitly setting the
`poetry-version` when calling the GitHub action. It is, however, recommended whenever
possible to update the poetry version of the affected repository. Unfortunately,
there is not a quick and easy way to update all the places where `poetry-version`
could be specified in the GitHub workflows.
possible to update the poetry version of the affected repository. Since this major release,
you can, if needed, alter the `poetry-version` via the `noxconfig.py::PROJECT_CONFIG`
by changing `dependency_manager_version`. If you do this, please create an issue to
update to `2.3.0` at your earliest convenience.

* Projects migrating to this version should:

* Update their `pyproject.toml` to have:
```toml
requires-poetry = ">=2.3.0"
```
* Run `poetry check` and resolve any issues
* (optional) Run `poetry lock` to update the lock
* (optional) Update their `pyproject.toml` to fit:
* [PEP-621](https://peps.python.org/pep-0621/)
* [PEP-735](https://peps.python.org/pep-0735/)
* Update their `pyproject.toml` to have:
```toml
requires-poetry = ">=2.3.0"
```
* Run `poetry check` and resolve any issues
* (optional) Run `poetry lock` to update the lock
* (optional) Update their `pyproject.toml` to fit:
* [PEP-621](https://peps.python.org/pep-0621/)
* [PEP-735](https://peps.python.org/pep-0735/)

Note that [uvx migrate-to-uv](https://github.com/mkniewallner/migrate-to-uv) seems to
do a good job with automating many of the PEP-related changes; though developers should
Expand All @@ -65,6 +66,16 @@ take care and will need to make manual changes to ensure it still works with
* #647: Added summary to changelog template
* #657: Updated `release:prepare` to modify cookiecutter template exasol-toolbox version range
* #665: Added SECURITY.md to the cookiecutter template
* #667: Switched GitHub workflow templates to be controlled by PROJECT_CONFIG:
* The values in `BaseConfig.github_template_dict` are used to render the following values in
the templates
* `dependency_manager_version` - used for `poetry-version` in the workflows.
The default it `2.3.0`.
* `minimum_python_version` - used for `python-version` in the workflows whenever
`python-version` for actions that are run once. The default is the minimum value
in your project's defined `python_versions`
* `os_version` - used for the GitHub runner in the workflows. The default is
`ubuntu-24.04`

## Refactoring

Expand All @@ -74,3 +85,5 @@ take care and will need to make manual changes to ensure it still works with
* `upload-pages-artifact` from v3 to [v4](https://github.com/actions/upload-pages-artifact/releases/tag/v4.0.0) - breaking change
* `download-artifact`from v6 to [v7](https://github.com/actions/download-artifact/releases/tag/v7.0.0) - using Node.js 24
* `upload-artifact` from v5 to [v6](https://github.com/actions/upload-artifact/releases/tag/v6.0.0) - using Node.js 24
* #667: Added deprecation warnings to `tbx workflow x` endpoints as some are unneeded
(will be removed) and others need updates (will be moved to a nox session)
59 changes: 56 additions & 3 deletions doc/user_guide/dependencies.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,62 @@
Dependencies
============

Core dependencies
+++++++++++++++++
Core Dependencies
-----------------

- Python >= 3.10
- poetry >= 2.3.0
- `Poetry <https://python-poetry.org/docs/#installing-with-the-official-installer>`__ >= 2.3.0
- `poetry export <https://github.com/python-poetry/poetry-plugin-export>`__

Supported Poetry Versions by PTB
--------------------------------

.. list-table:: PTB Poetry Version Compatibility
:header-rows: 1

* - PTB Version
- Default in PTB
- Range Allowed
- Migration Information
* - >=1.0.0, <5.0.0
- 2.1.2
- >=2.1.0,<3.0
- None
* - >=5.0.0
- 2.3.0
- >=2.3.0,<3.0
- :ref:`migration_to_2.3.x`

Migration Information
---------------------

.. _migration_to_2.3.x:

From Poetry ``2.1.x`` to ``2.3.0``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is **highly** encouraged that a developer update their ``pyproject.toml`` and
system-wide Poetry installation to most use effectively use Poetry ``2.3.0``:

#. In your terminal, update your system-wide Poetry version:

.. code-block:: bash

poetry self update 2.3.0

#. In your project's ``pyproject.toml``, update the ``requires-poetry`` value:

.. code-block:: toml

requires-poetry = ">=2.3.0"

#. In your terminal, execute ``poetry check`` and resolve any listed issues
#. In your terminal, run ``poetry lock`` to update the lock
#. (optional but recommended) In your project's ``pyproject.toml``, update it to fit:
* `PEP-621 <https://peps.python.org/pep-0621/>`__
* `PEP-735 <https://peps.python.org/pep-0735/>`__

.. note::
Note that `uvx migrate-to-uv <https://github.com/mkniewallner/migrate-to-uv>`__
seems to do a good job with automating many of the PEP-related changes.
Though, a developer should take care to verify the changes, as some are unneeded
as it completes the migration to ``uv`` which the PTB does NOT yet support.
2 changes: 1 addition & 1 deletion doc/user_guide/features/documentation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Deploying documentation
multiversion
troubleshooting

The PTB uses ref:`sphinx <https://www.sphinx-doc.org/>`__ to build and validate the contents
The PTB uses `sphinx <https://www.sphinx-doc.org/>`__ to build and validate the contents
of your project's documentation. PTB expects the project's documentation in directory ``doc``,
primarily as ``rst`` files. The ``doc/conf.py`` acts as the configuration file for building the
documentation.
Expand Down
56 changes: 56 additions & 0 deletions exasol/toolbox/config.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import inspect
import warnings
from collections.abc import Callable
from pathlib import Path
from typing import (
Annotated,
Any,
Literal,
)

from packaging import version
from pydantic import (
AfterValidator,
BaseModel,
ConfigDict,
Field,
computed_field,
field_validator,
)
from pydantic_core.core_schema import ValidationInfo

from exasol.toolbox.nox.plugin import (
METHODS_SPECIFIED_FOR_HOOKS,
Expand Down Expand Up @@ -93,6 +98,26 @@ def valid_version_string(version_string: str) -> str:
}


class DependencyManager(BaseModel):
# Restricted to only allow "poetry" at the moment
name: Literal["poetry"]
version: ValidVersionStr

@field_validator("version")
@classmethod
def check_minimum_version(cls, v: str, info: ValidationInfo) -> str:
tool = info.data.get("name")
if tool == "poetry":
prefix = "Poetry version "
if version.parse(v) < (min_version := version.parse("2.1.4")):
raise ValueError(prefix + f"must be >= {min_version}")
elif version.parse(v) >= (max_version := version.parse("3.0.0")):
raise ValueError(prefix + f"must be < {max_version}")
elif version.parse(v) > (current_version := version.parse("2.3.0")):
warnings.warn(prefix + f"exceeds last tested version {current_version}")
return v


class BaseConfig(BaseModel):
"""
Basic configuration for projects using the PTB
Expand Down Expand Up @@ -142,6 +167,24 @@ class BaseConfig(BaseModel):
possible plugin options are defined in `exasol.toolbox.nox.plugins.NoxTasks`.
""",
)
dependency_manager: DependencyManager = Field(
default=DependencyManager(name="poetry", version="2.3.0"),
description="""
This is used to define which dependency manager is used to install dependencies
in the CI. For more details on which PTB version pairs with which
dependency manager, see:
https://exasol.github.io/python-toolbox/main/user_guide/dependencies.html
""",
)
os_version: str = Field(
default="ubuntu-24.04",
pattern=r"^ubuntu-.*",
description="""
This is used to set the OS-runner in the GitHub workflows that are
provided as templates from the PTB. Currently, only ubuntu-based runners
are supported.
""",
)
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)

@computed_field # type: ignore[misc]
Expand Down Expand Up @@ -222,3 +265,16 @@ def version_filepath(self) -> Path:
the nox sessions ``version:check`` and ``release:prepare``.
"""
return self.source_code_path / "version.py"

@computed_field # type: ignore[misc]
@property
def github_template_dict(self) -> dict[str, Any]:
"""
Dictionary of variables to dynamically render Jinja2 templates into valid YAML
configurations.
"""
return {
"dependency_manager_version": self.dependency_manager.version,
"minimum_python_version": self.minimum_python_version,
"os_version": self.os_version,
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

cd-job:
name: Continuous Delivery
runs-on: ubuntu-24.04
runs-on: "(( os_version ))"
permissions:
contents: write
steps:
Expand All @@ -19,6 +19,9 @@ jobs:

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@v4
with:
python-version: "(( minimum_python_version ))"
poetry-version: "(( dependency_manager_version ))"

- name: Build Artifacts
run: poetry build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:

check-tag-version-job:
name: Check Tag Version
runs-on: ubuntu-24.04
runs-on: "(( os_version ))"
permissions:
contents: read
steps:
Expand All @@ -16,6 +16,9 @@ jobs:

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@v4
with:
python-version: "(( minimum_python_version ))"
poetry-version: "(( dependency_manager_version ))"

- name: Check Tag Version
# make sure the pushed/created tag matched the project version
Expand Down
Loading