From f1b67deadf80db5c7c65d5a31737e57047fff533 Mon Sep 17 00:00:00 2001 From: Tim Hall Date: Tue, 26 May 2020 09:18:53 +0100 Subject: MLBEDSW-2063: Add contributions guidelines - Create new CONTRIBUTIONS.md - Rearrange README.md to reference new documentation Signed-off-by: Tim Hall Change-Id: I502b1606a3fe829a9e242a5de7391bf769203b8c --- TESTING.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 TESTING.md (limited to 'TESTING.md') diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..371ece1f --- /dev/null +++ b/TESTING.md @@ -0,0 +1,71 @@ +# Vela Testing + +## Sanity checks and tests + +The Python codebase is PEP8 compliant with the exception of a 120 character line +length. We run reorder-python-import, black and flake8 against the code base +excluding "ethosu/vela/tflite/" and "ethosu/vela/ethos\_u55\_regs" directories +because they are auto-generated by third party tools. Those tools are run using +[pre-commit framework](https://pre-commit.com/). The configuration file is +.pre-commit-config.yaml + +### Install tools + +To install pre-commit, run the following: + +```bash +pipenv install -e . --dev +``` + +After the installation, pre-commit is available in the virtual environment. +Besides pre-commit, we install also: + +* pytest: testing framework +* pytest-cov: code coverage plugin for pytest + +### Install the pre-commit hook + +To ease the development, we can run those sanity checks before committing the +code. To install the git hook, run: + +```bash +$ pre-commit install +pre-commit installed at .git/hooks/pre-commit +``` + +The checks will be run before the commit: if one of them fails, you need to fix +the code to make the checks pass. + +### Run the tests + +Tests and test coverage can be run using pre-commit framework. + +```bash +$ pre-commit run pytest +... +$ pre-commit run pytest-cov +``` + +### Run the sanity checks + +Those checks can be run manually. This can be achieved running the following + +```bash +$ pre-commit run reorder-python-imports --all-files +... +$ pre-commit run flake8 --all-files +... +$ pre-commit run black --all-files +``` + +If you don't specify anything after run, it will execute all the checks. + +```bash +$ pre-commit run --all-files +Reorder python imports...................................................Passed +black....................................................................Passed +flake8...................................................................Passed +pytest...................................................................Passed +... +... +``` -- cgit v1.2.1