Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: ./.github/actions/python-environment

- name: Check Version(s)
run: poetry run version-check `poetry run -- python -c "from noxconfig import PROJECT_CONFIG; print(PROJECT_CONFIG.version_file)"`
run: poetry run -- nox -s version:check -- `poetry run -- python -c "from noxconfig import PROJECT_CONFIG; print(PROJECT_CONFIG.version_file)"`

Documentation:
name: Docs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import subprocess
import sys
from argparse import (
Expand All @@ -15,6 +16,9 @@
Union,
)

import nox
from nox import Session

Version = namedtuple("Version", ["major", "minor", "patch"])

_SUCCESS = 0
Expand All @@ -23,9 +27,9 @@
# fmt: off
_VERSION_MODULE_TEMPLATE = cleandoc('''
# ATTENTION:
# This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using:
# This file is generated by exasol/toolbox/nox/_package_version.py when using:
# * either "poetry run -- nox -s project:fix"
# * or "poetry run -- version-check <path/version.py> --fix"
# * or "poetry run -- nox version:check <path/version.py> --fix"
# Do not edit this file manually!
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = {major}
Expand Down Expand Up @@ -88,7 +92,10 @@ def write_version_module(version: Version, path: str, exists_ok: bool = True) ->


def _create_parser() -> ArgumentParser:
parser = ArgumentParser()
parser = ArgumentParser(
prog="nox -s version:check",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("version_module", help="Path to version module")
parser.add_argument("files", nargs="*")
parser.add_argument(
Expand Down Expand Up @@ -138,12 +145,11 @@ def _main(args: Namespace) -> int:
return _FAILURE


def main(argv: Union[Iterable[str], None] = None) -> int:
@nox.session(name="version:check", python=False)
def version_check(session: Session) -> None:
""""""
parser = _create_parser()
args = parser.parse_args()
args = parser.parse_args(session.posargs)
entry_point = _main if not args.debug else _main_debug
return entry_point(args)


if __name__ == "__main__":
sys.exit(main())
if entry_point(args):
session.error()
4 changes: 2 additions & 2 deletions exasol/toolbox/nox/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def _deny_filter(files: Iterable[Path], deny_list: Iterable[str]) -> Iterable[Pa


def _version(session: Session, mode: Mode, version_file: Path) -> None:
command = ["version-check"]
command = command if mode == Mode.Check else command + ["--fix"]
command = ["nox", "-s", "version:check"]
command = command if mode == Mode.Check else command + ["--"] + ["--fix"]
session.run(*command, f"{version_file}")


Expand Down
2 changes: 2 additions & 0 deletions exasol/toolbox/nox/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,7 @@ def check(session: Session) -> None:
audit
)

from exasol.toolbox.nox._package_version import version_check

# isort: on
# fmt: on
2 changes: 1 addition & 1 deletion exasol/toolbox/templates/github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
echo "Please enable the version check by replacing this output with shell command bellow:"
echo ""
echo "poetry run -- version-check <<VERSION_PY>>"
echo "poetry run nox -s version:check -- <<VERSION_PY>>"
echo ""
echo "Note: <<VERSION_PY>> needs to point to the version file of the project (version.py)."
exit 1
Expand Down
4 changes: 2 additions & 2 deletions exasol/toolbox/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ATTENTION:
# This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using:
# This file is generated by exasol/toolbox/nox/_package_version.py when using:
# * either "poetry run -- nox -s project:fix"
# * or "poetry run -- version-check <path/version.py> --fix"
# * or "poetry run -- nox version:check <path/version.py> --fix"
# Do not edit this file manually!
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = 1
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,5 @@ module = [
ignore_errors = true

[tool.poetry.plugins."console_scripts"]
version-check = "exasol.toolbox.pre_commit_hooks.package_version:main"
tbx = 'exasol.toolbox.tools.tbx:CLI'
sphinx-multiversion = 'exasol.toolbox.sphinx.multiversion:main'