🚦 Getting Started¶
Preparing the Project¶
1. Add the toolbox as dependency¶
poetry add --group dev exasol-toolbox
2. Fine tune the .gitignore file¶
Add the standard documentation output folder (.html-documentation) to the .gitignore.
echo ".html-documentation" >> .gitignore && git add .gitignore && git commit -m "Add documentation build folder to .gitignore"
3. Provide a project configuration¶
Make sure you provide the required configuration. Configuration for the exasol-toolbox gets provided by creating a noxconfig.py file in the workspace root. This file should contain at least a single module constant with the name PROJECT_CONFIG pointing to an object, which is required to to provide the following attributes:
Alternatively you can use the noxconfig.py file bellow and adjust the value of the attributes if needed:
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import (
Any,
Iterable,
MutableMapping,
)
from nox import Session
@dataclass(frozen=True)
class Config:
root: Path = Path(__file__).parent
doc: Path = Path(__file__).parent / "doc"
version_file: Path = Path(__file__).parent / "exasol" / "toolbox" / "version.py"
path_filters: Iterable[str] = ("dist", ".eggs", "venv")
@staticmethod
def pre_integration_tests_hook(
_session: Session, _config: Config, _context: MutableMapping[str, Any]
) -> bool:
"""Implement if project specific behaviour is required"""
return True
@staticmethod
def post_integration_tests_hook(
_session: Session, _config: Config, _context: MutableMapping[str, Any]
) -> bool:
"""Implement if project specific behaviour is required"""
return True
PROJECT_CONFIG = Config()
4. Configure the tooling¶
In order to make all standard task work properly you need add the configuration settings bellow to your pyproject.toml, and adjust the following settings to your project needs:
- coverage
source
fail_under
- pylint
fail-under
- mypy (overrides)
module
[tool.coverage.run]
source = [
"exasol",
]
[tool.coverage.report]
fail_under = 15
[tool.black]
line-length = 88
verbose = false
include = "\\.pyi?$"
[tool.isort]
profile = "black"
force_grid_wrap = 2
[tool.pylint.master]
fail-under = 7.8
[tool.pylint.format]
max-line-length = 88
max-module-lines = 800
[[tool.mypy.overrides]]
module = [
"exasol.toolbox.sphinx.multiversion.*",
"test.unit.*",
"test.integration.*",
]
ignore_errors = true
[tool.scriv]
new_fragment_template = "file: templates/fragment-template.rst"
output_file = "doc/changelog.${config:format}"
version = "literal: pyproject.toml: tool.poetry.version"
5. Make the toolbox task available¶
In order to use the standard toolbox task via nox, just import them in your noxfile.py. If you only need the standard tasks provided by the toolbox your noxfile.py is straight forward and you just can use the example noxfile.py bellow.
import nox
# imports all nox task provided by the toolbox
from exasol.toolbox.nox.tasks import *
# default actions to be run if nothing is explicitly specified with the -s option
nox.options.sessions = ["fix"]
6. Setup the pre-commit hooks¶
Add the following .pre-commit-config.yaml to your project root
default_stages: [ commit ] repos: - repo: local hooks: - id: code-format name: code-format types: [ python ] files: "pyproject.toml" pass_filenames: false language: system entry: poetry run nox -s fix - repo: local hooks: - id: type-check name: type-check types: [ python ] pass_filenames: false language: system entry: poetry run nox -s type-check - repo: local hooks: - id: lint name: lint types: [ python ] pass_filenames: false language: system entry: poetry run nox -s lint - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace
Enable pre commit hooks for your workspace
poetry run pre-commit install
7. Go 🥜¶
You are ready to use the toolbox. With nox -l you can list all available tasks.
$ nox -l
Sessions defined in <PATH_TO_YOUR_PROJECT>/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
- build-docs -> Builds the project documentation
- open-docs -> Opens the built project documentation
- clean-docs -> Removes the documentations build folder
sessions marked with * are selected, sessions marked with - are skipped.
Enjoy!