|
1 | 1 | import json |
| 2 | +import logging |
2 | 3 |
|
3 | 4 | import nox |
4 | 5 | from nox import Session |
5 | 6 |
|
| 7 | +from noxconfig import ( |
| 8 | + PROJECT_CONFIG, |
| 9 | + Config, |
| 10 | +) |
6 | 11 |
|
7 | | -def _python_matrix(): |
8 | | - return {"python-version": ["3.9", "3.10", "3.11", "3.12"]} |
| 12 | +_log = logging.getLogger(__name__) |
9 | 13 |
|
| 14 | +_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"] |
| 15 | +_EXASOL_VERSIONS = ["7.1.9"] |
10 | 16 |
|
11 | | -def _exasol_matrix(): |
12 | | - return {"exasol-version": ["7.1.9"]} |
| 17 | + |
| 18 | +def _python_matrix(config: Config): |
| 19 | + attr = "python_versions" |
| 20 | + python_versions = getattr(config, attr, _PYTHON_VERSIONS) |
| 21 | + if not hasattr(config, attr): |
| 22 | + _log.warning( |
| 23 | + "Config does not contain '%s' setting. Using default: %s", |
| 24 | + attr, |
| 25 | + _PYTHON_VERSIONS, |
| 26 | + ) |
| 27 | + return {"python-version": python_versions} |
| 28 | + |
| 29 | + |
| 30 | +def _exasol_matrix(config: Config): |
| 31 | + attr = "exasol_versions" |
| 32 | + exasol_versions = getattr(config, attr, _EXASOL_VERSIONS) |
| 33 | + if not hasattr(config, attr): |
| 34 | + _log.warning( |
| 35 | + "Config does not contain '%s' setting. Using default: %s", |
| 36 | + attr, |
| 37 | + _EXASOL_VERSIONS, |
| 38 | + ) |
| 39 | + return {"exasol-version": exasol_versions} |
13 | 40 |
|
14 | 41 |
|
15 | 42 | @nox.session(name="matrix:python", python=False) |
16 | 43 | def python_matrix(session: Session) -> None: |
17 | 44 | """Output the build matrix for Python versions as JSON.""" |
18 | | - print(json.dumps(_python_matrix())) |
| 45 | + print(json.dumps(_python_matrix(PROJECT_CONFIG))) |
19 | 46 |
|
20 | 47 |
|
21 | 48 | @nox.session(name="matrix:exasol", python=False) |
22 | 49 | def exasol_matrix(session: Session) -> None: |
23 | 50 | """Output the build matrix for Exasol versions as JSON.""" |
24 | | - print(json.dumps(_exasol_matrix())) |
| 51 | + print(json.dumps(_exasol_matrix(PROJECT_CONFIG))) |
25 | 52 |
|
26 | 53 |
|
27 | 54 | @nox.session(name="matrix:all", python=False) |
28 | 55 | def full_matrix(session: Session) -> None: |
29 | 56 | """Output the full build matrix for Python & Exasol versions as JSON.""" |
30 | | - matrix = _python_matrix() |
31 | | - matrix.update(_exasol_matrix()) |
| 57 | + matrix = _python_matrix(PROJECT_CONFIG) |
| 58 | + matrix.update(_exasol_matrix(PROJECT_CONFIG)) |
32 | 59 | print(json.dumps(matrix)) |
0 commit comments