|
1 | 1 | # License: MIT |
2 | 2 | # Copyright © 2022 Frequenz Energy-as-a-Service GmbH |
3 | 3 |
|
4 | | -"""Project's noxfile. |
| 4 | +"""Automation for code quality checks and unit tests for the Frequenz SDK. |
5 | 5 |
|
6 | | -For more information please see nox documentation: |
7 | | -https://nox.thea.codes/en/stable/ |
| 6 | +This file specified all the checks that can be run from command line invocations |
| 7 | +of `nox`. |
| 8 | +
|
| 9 | +The following checks are performed: |
| 10 | +
|
| 11 | +1. `formatting` :: checks that the code is formatted with `black` and the imports |
| 12 | + are sorted with `isort`. |
| 13 | +2. `mypy` :: type checks all source files with `mypy --strict`. |
| 14 | +3. `pylint` :: lints all source files with `pylint`. |
| 15 | +4. `docstrings` :: checks that all public functions have docstrings with |
| 16 | + 1. a one-line imperative description at the top, followed by additional |
| 17 | + description, using `pydocstyle`. |
| 18 | + 2. function parameters, return values, and raised exceptions are documented |
| 19 | + following the google style guide for these items: |
| 20 | + https://google.github.io/styleguide/pyguide.html#doc-function-args, using |
| 21 | + `darglint`. |
| 22 | +5. `pytest_min` :: run all unittests using `pytest`, with the oldest supported |
| 23 | + versions of all dependencies installed. |
| 24 | +6. `pytest_max` :: run all unittests using `pytest`, with the latest supported |
| 25 | + versions of all dependencies installed. |
| 26 | +
|
| 27 | +Usage: |
| 28 | +
|
| 29 | +1. Run all checks in a *new* venv. |
| 30 | +
|
| 31 | + nox |
| 32 | +
|
| 33 | +2. Run all checks in an *exising* venv. This would be much faster if venv for |
| 34 | + all tests exist already. If they don't exist, new venvs will be created. |
| 35 | +
|
| 36 | + nox -R |
| 37 | +
|
| 38 | +3. Run a subset of available checks: |
| 39 | +
|
| 40 | + nox -e mypy pylint # create new venvs for specified checks. |
| 41 | + nox -R -e mypy pylint # reuse venvs for specified checks if available. |
| 42 | +
|
| 43 | +4. The `pytest_min` and `pytest_max` checks run `pytest` on all available tests, |
| 44 | + including test coverage generation. But this can be slow for fast local |
| 45 | + test-devlop cycles, and so `pytest` can also be invoked with optional custom |
| 46 | + arguments, in which case, only the specified arguments are passed to |
| 47 | + `pytest`. This can be done as follows: |
| 48 | +
|
| 49 | + nox -R -e pytest_min [-- <args for pytest>] |
| 50 | + nox -R -e pytest_min -- -s -x tests/timeseries/test_logical_meter.py |
8 | 51 | """ |
9 | 52 |
|
10 | 53 | from typing import List |
|
0 commit comments