diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e6d198462..992aaed4d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,7 +59,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run lint - run: poetry run nox -s lint + run: poetry run nox -s lint:code - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -87,7 +87,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run type-check - run: poetry run nox -s type-check + run: poetry run nox -s lint:typing Security: name: Security Checks (Python-${{ matrix.python-version }}) @@ -108,7 +108,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run security linter - run: poetry run nox -s security + run: poetry run nox -s lint:security - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -139,7 +139,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run Tests and Collect Coverage - run: poetry run nox -s coverage -- -- --db-version ${{ matrix.exasol-version }} + run: poetry run nox -s test:coverage -- -- --db-version ${{ matrix.exasol-version }} - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml index a4f9f4dff..c8c7b3473 100644 --- a/.github/workflows/report.yml +++ b/.github/workflows/report.yml @@ -35,7 +35,7 @@ jobs: cp security-python3.9/.security.json ../ - name: Generate Report - run: poetry run nox -s report -- -- --format json | tee metrics.json + run: poetry run nox -s project:report -- -- --format json | tee metrics.json - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -46,7 +46,7 @@ jobs: - name: Generate GitHub Summary run: | echo -e "# Summary\n" >> $GITHUB_STEP_SUMMARY - poetry run nox -s report -- -- --format markdown >> $GITHUB_STEP_SUMMARY + poetry run nox -s project:report -- -- --format markdown >> $GITHUB_STEP_SUMMARY echo -e "\n\n# Coverage\n" >> $GITHUB_STEP_SUMMARY poetry run coverage report -- --format markdown >> $GITHUB_STEP_SUMMARY echo -e "\n\n# Static Code Analysis\n" >> $GITHUB_STEP_SUMMARY diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index 852ae8304..5ff7b9f57 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -3,10 +3,23 @@ ## 🚨 Breaking Changes * Dropped python 3.8 support -* Changed names of Documentation related nox tasks - - `build-docs` -> `docs:build` - - `open-docs` -> `docs:open` - - `clean-docs` -> `docs:clean` +* Changed names of all nox tasks + + | Old Name | New Name | Description | + |--------------------|------------------------|----------------------------------------------------------------| + | fix | project:fix | Runs all automated fixes on the code base | + | check | project:check | Runs all available checks on the project | + | report | project:report | Collects and generates metrics summary for the workspace | + | unit-tests | test:unit | Runs all unit tests | + | integration-tests | test:integration | Runs all the integration tests | + | coverage | test:coverage | Runs all tests (unit + integration) and reports the code coverage | + | lint | lint:code | Runs the static code analyzer on the project | + | type-check | lint:typing | Runs the type checker on the project | + | security | lint:security | Runs the security linter on the project | + | build-build | docs:build | Builds the project documentation | + | open-open | docs:open | Opens the built project documentation | + | clean-docs | docs:clean | Removes the documentations build folder | + | prepare-release | release:prepare | Prepares the project for a new release | ## ✨ Added diff --git a/doc/developer_guide/development.rst b/doc/developer_guide/development.rst index 184ce55de..c8ff61977 100644 --- a/doc/developer_guide/development.rst +++ b/doc/developer_guide/development.rst @@ -17,7 +17,7 @@ This can be achieved by running the following command: .. code-block:: shell - nox -s prepare-release -- .. + nox -s release:prepare -- .. Replace ``, ``, and `` with the appropriate version numbers. Once the PR is successfully merged, the release can be triggered (see next section). diff --git a/doc/metrics.rst b/doc/metrics.rst index 0308bff6a..9fdb315a4 100644 --- a/doc/metrics.rst +++ b/doc/metrics.rst @@ -84,7 +84,7 @@ Tooling Projects ________ -Projects can run the nox task :code:`nox -s report` to generate their project metrics if they are using the :code:`exasol-toolbox`. +Projects can run the nox task :code:`nox -s project:report` to generate their project metrics if they are using the :code:`exasol-toolbox`. Development diff --git a/doc/user_guide/getting_started.rst b/doc/user_guide/getting_started.rst index f8799e97f..e126d96b6 100644 --- a/doc/user_guide/getting_started.rst +++ b/doc/user_guide/getting_started.rst @@ -77,7 +77,7 @@ Execute the unit tests of the project: .. code-block:: shell - nox -s unit-tests + nox -s test:unit .. _existing: @@ -184,17 +184,20 @@ You are ready to use the toolbox. With *nox -l* you can list all available tasks $ nox -l Sessions defined in /noxfile.py: - * fix -> Runs all automated fixes on the code base - - check -> Runs all available checks on the project - - lint -> Runs the linter on the project - - type-check -> Runs the type checker on the project - - unit-tests -> Runs all unit tests - - integration-tests -> Runs the all integration tests - - coverage -> Runs all tests (unit + integration) and reports the code coverage + * project:fix -> Runs all automated fixes on the code base + - project:check -> Runs all available checks on the project + - project:report -> Collects and generates metrics summary for the workspace + - test:unit -> Runs all unit tests + - test:integration -> Runs the all integration tests + - test:coverage -> Runs all tests (unit + integration) and reports the code coverage + - lint:code -> Runs the static code analyzer on the project + - lint:typing -> Runs the type checker on the project + - lint:security -> Runs the security linter on the project + - docs:multiversion -> Builds the multiversion project documentation - docs:build -> Builds the project documentation - docs:open -> Opens the built project documentation - docs:clean -> Removes the documentations build folder - - report -> Collects and generates a metrics summary for the workspace + - release:prepare -> Prepares the project for a new release. sessions marked with * are selected, sessions marked with - are skipped. diff --git a/exasol/toolbox/nox/_documentation.py b/exasol/toolbox/nox/_documentation.py index 709f3f228..8564f21da 100644 --- a/exasol/toolbox/nox/_documentation.py +++ b/exasol/toolbox/nox/_documentation.py @@ -38,7 +38,7 @@ def _build_multiversion_docs(session: nox.Session, config: Config) -> None: @nox.session(name="docs:multiversion", python=False) def build_multiversion(session: Session) -> None: - """Builds the project documentation""" + """Builds the multiversion project documentation""" _build_multiversion_docs(session, PROJECT_CONFIG) diff --git a/exasol/toolbox/nox/_format.py b/exasol/toolbox/nox/_format.py index d8f95008c..f89cd3b18 100644 --- a/exasol/toolbox/nox/_format.py +++ b/exasol/toolbox/nox/_format.py @@ -33,7 +33,7 @@ def _pyupgrade(session: Session, files: Iterable[str]) -> None: ) -@nox.session(python=False) +@nox.session(name="project:fix", python=False) def fix(session: Session) -> None: """Runs all automated fixes on the code base""" py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] diff --git a/exasol/toolbox/nox/_lint.py b/exasol/toolbox/nox/_lint.py index b7382aae2..ab5f87e2c 100644 --- a/exasol/toolbox/nox/_lint.py +++ b/exasol/toolbox/nox/_lint.py @@ -65,21 +65,21 @@ def _security_lint(session: Session, files: Iterable[str]) -> None: ) -@nox.session(python=False) +@nox.session(name="lint:code", python=False) def lint(session: Session) -> None: - """Runs the linter on the project""" + "Runs the static code analyzer on the project" py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] _pylint(session, py_files) -@nox.session(name="type-check", python=False) +@nox.session(name="lint:typing", python=False) def type_check(session: Session) -> None: """Runs the type checker on the project""" py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] _type_check(session, py_files) -@nox.session(name="security", python=False) +@nox.session(name="lint:security", python=False) def security_lint(session: Session) -> None: """Runs the security linter on the project""" py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] diff --git a/exasol/toolbox/nox/_metrics.py b/exasol/toolbox/nox/_metrics.py index d00ba06ea..b662f8fd3 100644 --- a/exasol/toolbox/nox/_metrics.py +++ b/exasol/toolbox/nox/_metrics.py @@ -13,7 +13,7 @@ from noxconfig import PROJECT_CONFIG -@nox.session(name="report", python=False) +@nox.session(name="project:report", python=False) def report(session: Session) -> None: """ Collects and generates metrics summary for the workspace @@ -28,11 +28,12 @@ def report(session: Session) -> None: * :code:`rm .coverage .lint.txt` * Run the following targets: - - :code:`nox -s coverage` - - :code:`nox -s lint` + - :code:`nox -s test:coverage` + - :code:`nox -s lint:code` + - :code:`nox -s lint:security` """ formats = tuple(fmt.name.lower() for fmt in Format) - usage = "nox -s report -- [options]" + usage = "nox -s project:report -- [options]" parser = argparse.ArgumentParser( description="Generates status report for the project", usage=usage ) @@ -51,7 +52,7 @@ def report(session: Session) -> None: ) if not all(file.exists() for file in required_files): session.error( - "Please make sure you run the `coverage`, `security` and the `lint` target first" + "Please make sure you run the `test:coverage`, `lint:security` and the `lint:code` target first" ) sha1 = str( session.run("git", "rev-parse", "HEAD", external=True, silent=True) diff --git a/exasol/toolbox/nox/_release.py b/exasol/toolbox/nox/_release.py index 424e0a9bf..02d676d70 100644 --- a/exasol/toolbox/nox/_release.py +++ b/exasol/toolbox/nox/_release.py @@ -28,8 +28,8 @@ def _create_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( - prog="nox -s prepare-release", - usage="nox -s prepare-release -- [-h] version", + prog="nox -s release:prepare", + usage="nox -s release:prepare -- [-h] version", formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument( @@ -89,7 +89,7 @@ def _add_files_to_index(session: Session, files: list[Path]) -> None: session.run("git", "add", f"{file}") -@nox.session(name="prepare-release", python=False) +@nox.session(name="release:prepare", python=False) def prepare_release(session: Session, python=False) -> None: """ Prepares the project for a new release. @@ -146,26 +146,3 @@ def prepare_release(session: Session, python=False) -> None: "--body", '""', ) - - -@nox.session(name="release", python=False) -def release(session: Session, python=False) -> None: - """ - Creates a new release and publishing it to GitHub and pypi. - """ - session.error("Not implemented yet") - # Precondition(s): - # Convert ci-cd.yml workflow to cd.yml workflow - # Tests validation can be skipped. Branch protection together with - # PR and merge validation shoudl be sufficient - # ---------------------------------------------------------------------- - # 0. Check that version isn't released yet (tag does not exist (origin)) - # 0.1. update git information - # 0.2. check if origin does not have the tag yet - # 1. check if current branch is main/master - # 2. build wheel/package - # 3. create release tag - # 4. push release tag to origin - # 5. publish on gh - # 5. publish on pypi - # 6. output relase message/information diff --git a/exasol/toolbox/nox/_test.py b/exasol/toolbox/nox/_test.py index 309638af4..aad1b9209 100644 --- a/exasol/toolbox/nox/_test.py +++ b/exasol/toolbox/nox/_test.py @@ -72,14 +72,14 @@ def _coverage( session.run(*command) -@nox.session(name="unit-tests", python=False) +@nox.session(name="test:unit", python=False) def unit_tests(session: Session) -> None: """Runs all unit tests""" context = _context(session, coverage=False) _unit_tests(session, PROJECT_CONFIG, context) -@nox.session(name="integration-tests", python=False) +@nox.session(name="test:integration", python=False) def integration_tests(session: Session) -> None: """ Runs the all integration tests @@ -93,7 +93,7 @@ def integration_tests(session: Session) -> None: _integration_tests(session, PROJECT_CONFIG, context) -@nox.session(name="coverage", python=False) +@nox.session(name="test:coverage", python=False) def coverage(session: Session) -> None: """Runs all tests (unit + integration) and reports the code coverage""" context = _context(session, coverage=True) diff --git a/exasol/toolbox/nox/tasks.py b/exasol/toolbox/nox/tasks.py index d9cb27d1c..39e96d085 100644 --- a/exasol/toolbox/nox/tasks.py +++ b/exasol/toolbox/nox/tasks.py @@ -16,28 +16,50 @@ ] -import argparse - import nox from nox import Session -from exasol.toolbox.nox._documentation import ( - build_docs, - clean_docs, - open_docs, -) from exasol.toolbox.nox._format import ( _code_format, _pyupgrade, fix, ) + +# fmt: off +# isort: off +from noxconfig import PROJECT_CONFIG + + +@nox.session(name="project:check", python=False) +def check(session: Session) -> None: + """Runs all available checks on the project""" + context = _context(session, coverage=True) + py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] + _version(session, Mode.Check, PROJECT_CONFIG.version_file) + _pyupgrade(session, py_files) + _code_format(session, Mode.Check, py_files) + _pylint(session, py_files) + _type_check(session, py_files) + _coverage(session, PROJECT_CONFIG, context) + +from exasol.toolbox.nox._metrics import report +from exasol.toolbox.nox._test import ( + _coverage, + coverage, + integration_tests, + unit_tests, +) from exasol.toolbox.nox._lint import ( _pylint, _type_check, lint, type_check, ) -from exasol.toolbox.nox._metrics import report +from exasol.toolbox.nox._documentation import ( + build_docs, + clean_docs, + open_docs, +) from exasol.toolbox.nox._release import prepare_release from exasol.toolbox.nox._shared import ( Mode, @@ -45,23 +67,6 @@ _version, python_files, ) -from exasol.toolbox.nox._test import ( - _coverage, - coverage, - integration_tests, - unit_tests, -) -from noxconfig import PROJECT_CONFIG - -@nox.session(name="check", python=False) -def check(session: Session) -> None: - """Runs all available checks on the project""" - context = _context(session, coverage=True) - py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] - _version(session, Mode.Check, PROJECT_CONFIG.version_file) - _pyupgrade(session, py_files) - _code_format(session, Mode.Check, py_files) - _pylint(session, py_files) - _type_check(session, py_files) - _coverage(session, PROJECT_CONFIG, context) +# isort: on +# fmt: on diff --git a/exasol/toolbox/pre_commit_hooks/package_version.py b/exasol/toolbox/pre_commit_hooks/package_version.py index 3f6f68edf..9be9fc24b 100644 --- a/exasol/toolbox/pre_commit_hooks/package_version.py +++ b/exasol/toolbox/pre_commit_hooks/package_version.py @@ -24,7 +24,7 @@ _VERSION_MODULE_TEMPLATE = cleandoc(''' # ATTENTION: # This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using: - # * either "poetry run nox -s fix" + # * either "poetry run nox -s project:fix" # * or "poetry run version-check --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`. diff --git a/exasol/toolbox/sphinx/multiversion/main.py b/exasol/toolbox/sphinx/multiversion/main.py index 4d94c68ca..31e48ba41 100644 --- a/exasol/toolbox/sphinx/multiversion/main.py +++ b/exasol/toolbox/sphinx/multiversion/main.py @@ -575,7 +575,9 @@ def _main(args, argv): os.path.join(args.outputdir, "index.html"), "w", encoding="utf-8" ) as f: versions = [ - ref.name for ref in gitrefs if re.match(config.smv_tag_whitelist, ref.name) + ref.name + for ref in gitrefs + if re.match(config.smv_tag_whitelist, ref.name) ] versions = sorted( versions, key=lambda v: ExasolVersion.from_string(v), reverse=True diff --git a/exasol/toolbox/templates/github/workflows/checks.yml b/exasol/toolbox/templates/github/workflows/checks.yml index fea1ed128..4d0d88eb4 100644 --- a/exasol/toolbox/templates/github/workflows/checks.yml +++ b/exasol/toolbox/templates/github/workflows/checks.yml @@ -65,7 +65,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run lint - run: poetry run nox -s lint + run: poetry run nox -s lint:code - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -93,7 +93,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run type-check - run: poetry run nox -s type-check + run: poetry run nox -s lint:typing Security: name: Security Checks (Python-${{ matrix.python-version }}) @@ -114,7 +114,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run security linter - run: poetry run nox -s security + run: poetry run nox -s lint:security - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -145,7 +145,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run Tests and Compute Coverage - run: poetry run nox -s coverage -- -- --db-version ${{ matrix.exasol-version }} + run: poetry run nox -s test:coverage -- -- --db-version ${{ matrix.exasol-version }} - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 diff --git a/exasol/toolbox/templates/github/workflows/report.yml b/exasol/toolbox/templates/github/workflows/report.yml index 7ed496294..5a6787dcc 100644 --- a/exasol/toolbox/templates/github/workflows/report.yml +++ b/exasol/toolbox/templates/github/workflows/report.yml @@ -35,7 +35,7 @@ jobs: cp security-python3.9/.security.json ../ - name: Generate Report - run: poetry run nox -s report -- -- --format json | tee metrics.json + run: poetry run nox -s project:report -- -- --format json | tee metrics.json - name: Upload Artifacts uses: actions/upload-artifact@v4.4.0 @@ -46,7 +46,7 @@ jobs: - name: Generate GitHub Summary run: | echo -e "# Summary\n" >> $GITHUB_STEP_SUMMARY - poetry run nox -s report -- -- --format markdown >> $GITHUB_STEP_SUMMARY + poetry run nox -s project:report -- -- --format markdown >> $GITHUB_STEP_SUMMARY echo -e "\n\n# Coverage\n" >> $GITHUB_STEP_SUMMARY poetry run coverage report -- --format markdown >> $GITHUB_STEP_SUMMARY echo -e "\n\n# Static Code Analysis\n" >> $GITHUB_STEP_SUMMARY diff --git a/exasol/toolbox/templates/noxfile.py b/exasol/toolbox/templates/noxfile.py index 35b74f41c..176dbf97b 100644 --- a/exasol/toolbox/templates/noxfile.py +++ b/exasol/toolbox/templates/noxfile.py @@ -4,4 +4,4 @@ from exasol.toolbox.nox.tasks import * # default actions to be run if nothing is explicitly specified with the -s option -nox.options.sessions = ["fix"] +nox.options.sessions = ["project:fix"] diff --git a/exasol/toolbox/templates/pre-commit-config.yaml b/exasol/toolbox/templates/pre-commit-config.yaml index 017e6b828..3b9da5ac6 100644 --- a/exasol/toolbox/templates/pre-commit-config.yaml +++ b/exasol/toolbox/templates/pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: types: [ python ] pass_filenames: false language: system - entry: poetry run nox -s fix + entry: poetry run nox -s project:fix - repo: local hooks: @@ -17,7 +17,7 @@ repos: types: [ python ] pass_filenames: false language: system - entry: poetry run nox -s type-check + entry: poetry run nox -s lint:typing - repo: local hooks: @@ -26,7 +26,7 @@ repos: types: [ python ] pass_filenames: false language: system - entry: poetry run nox -s lint + entry: poetry run nox -s lint:code - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 diff --git a/exasol/toolbox/version.py b/exasol/toolbox/version.py index 56fcadef4..cda7f8a58 100644 --- a/exasol/toolbox/version.py +++ b/exasol/toolbox/version.py @@ -1,6 +1,6 @@ # ATTENTION: # This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using: -# * either "poetry run nox -s fix" +# * either "poetry run nox -s project:fix" # * or "poetry run version-check --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`. diff --git a/noxfile.py b/noxfile.py index fb579dbe4..b67ac16a7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -6,7 +6,7 @@ from exasol.toolbox.nox.tasks import * # pylint: disable=wildcard-import disable=unused-wildcard-import # default actions to be run if nothing is explicitly specified with the -s option -nox.options.sessions = ["fix"] +nox.options.sessions = ["project:fix"] # entry point for debugging diff --git a/project-template/{{cookiecutter.repo_name}}/exasol/{{cookiecutter.package_name}}/version.py b/project-template/{{cookiecutter.repo_name}}/exasol/{{cookiecutter.package_name}}/version.py index 9da996321..c98b7d063 100644 --- a/project-template/{{cookiecutter.repo_name}}/exasol/{{cookiecutter.package_name}}/version.py +++ b/project-template/{{cookiecutter.repo_name}}/exasol/{{cookiecutter.package_name}}/version.py @@ -1,6 +1,6 @@ # ATTENTION: # This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using: -# * either "poetry run nox -s fix" +# * either "poetry run nox -s project:fix" # * or "poetry run version-check --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`. diff --git a/project-template/{{cookiecutter.repo_name}}/noxfile.py b/project-template/{{cookiecutter.repo_name}}/noxfile.py index 35b74f41c..176dbf97b 100644 --- a/project-template/{{cookiecutter.repo_name}}/noxfile.py +++ b/project-template/{{cookiecutter.repo_name}}/noxfile.py @@ -4,4 +4,4 @@ from exasol.toolbox.nox.tasks import * # default actions to be run if nothing is explicitly specified with the -s option -nox.options.sessions = ["fix"] +nox.options.sessions = ["project:fix"]