Skip to content

Commit

Permalink
Update matrix generation tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti committed Dec 11, 2024
1 parent f86e4e4 commit a5f618d
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions exasol/toolbox/nox/_ci.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
import json
import logging

import nox
from nox import Session

from noxconfig import (
PROJECT_CONFIG,
Config,
)

def _python_matrix():
return {"python-version": ["3.9", "3.10", "3.11", "3.12"]}
_log = logging.getLogger(__name__)

_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
_EXASOL_VERSIONS = ["7.1.9"]

def _exasol_matrix():
return {"exasol-version": ["7.1.9"]}

def _python_matrix(config: Config):
attr = "python_versions"
python_versions = getattr(config, attr, _PYTHON_VERSIONS)
if not hasattr(config, attr):
_log.warning(
"Config does not contain '%s' setting. Using default: %s",
attr,
_PYTHON_VERSIONS,
)
return {"python-version": python_versions}


def _exasol_matrix(config: Config):
attr = "exasol_versions"
exasol_versions = getattr(config, attr, _EXASOL_VERSIONS)
if not hasattr(config, attr):
_log.warning(
"Config does not contain '%s' setting. Using default: %s",
attr,
_EXASOL_VERSIONS,
)
return {"exasol-version": exasol_versions}


@nox.session(name="matrix:python", python=False)
def python_matrix(session: Session) -> None:
"""Output the build matrix for Python versions as JSON."""
print(json.dumps(_python_matrix()))
print(json.dumps(_python_matrix(PROJECT_CONFIG)))


@nox.session(name="matrix:exasol", python=False)
def exasol_matrix(session: Session) -> None:
"""Output the build matrix for Exasol versions as JSON."""
print(json.dumps(_exasol_matrix()))
print(json.dumps(_exasol_matrix(PROJECT_CONFIG)))


@nox.session(name="matrix:all", python=False)
def full_matrix(session: Session) -> None:
"""Output the full build matrix for Python & Exasol versions as JSON."""
matrix = _python_matrix()
matrix.update(_exasol_matrix())
matrix = _python_matrix(PROJECT_CONFIG)
matrix.update(_exasol_matrix(PROJECT_CONFIG))
print(json.dumps(matrix))

0 comments on commit a5f618d

Please sign in to comment.