Workflow Variables#

Workflow Templates#

Underlying the CLI, the PTB uses Jinja to dynamically generate project-specific workflows. The rendering process is supported by the github_template_dict found in your noxconfig.py::PROJECT_CONFIG. This dictionary is inherited by default from exasol.toolbox.config.BaseConfig.github_template_dict, ensuring a standardized baseline that can be overridden in individual projects.

    def github_template_dict(self) -> dict[str, Any]:
        """
        Dictionary of variables to dynamically render Jinja2 templates into valid YAML
        configurations.
        """
        cd_extension = self.github_workflow_directory / "cd-extension.yml"
        fast_tests_extension = (
            self.github_workflow_directory / "fast-tests-extension.yml"
        )
        merge_gate_extension = (
            self.github_workflow_directory / "merge-gate-extension.yml"
        )

        return {
            "dependency_manager_version": self.dependency_manager.version,
            "minimum_python_version": self.minimum_python_version,
            "os_version": self.os_version,
            "python_versions": self.python_versions,
            "sonar_token_name": self.sonar_token_name,
            "workflow_header": f"{WORKFLOW_HEADER_PREFIX}{__version__}.",
            "workflow_extension": {
                "cd": cd_extension.is_file(),
                "fast_tests": fast_tests_extension.is_file(),
                "merge_gate": merge_gate_extension.is_file(),
            },
        }

Matrix Combinations#

The matrix.yml is used to generate different combinations of workflow inputs, such as Python versions, Exasol versions, and any project-specific values exposed by the config. This lets the PTB render workflows from a single matrix definition instead of maintaining separate variants.

Extending the Matrix#

If you need to expose additional values via the matrix.yml, you can extend exasol.toolbox.config.BaseConfig.

The example adds two additional matrix dimensions: A declared one extra_matrix_value and a computed one computed_matrix_value. Each of them returning only a simple string value.

PTB’s Nox task generate:matrix will then be able to use each of the these dimensions when generating a build matrix.

from pydantic import computed_field

from exasol.toolbox.config import BaseConfig


class Config(BaseConfig):
    extra_matrix_value: str = "extra"

    @computed_field  # type: ignore[misc]
    @property
    def computed_matrix_value(self) -> str:
        # This can be requested when generating the matrix. If it is a simple
        # string value, like is shown here, the generator wraps it in an array.
        return f"{self.project_name}-computed"

You can consume the additional value in a workflow by passing the relevant matrix_keys_json entries when calling matrix.yml:

jobs:
  build-matrix:
    uses: ./.github/workflows/matrix.yml
    with:
      matrix_keys_json: '["extra_matrix_value","computed_matrix_value"]'