diff options
author | Diego Russo <diego.russo@arm.com> | 2020-04-14 18:41:58 +0100 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2020-06-18 17:53:52 +0100 |
commit | ea6111a36e55501bbfb9ea022aaf8305b4d80183 (patch) | |
tree | f6787f7d07ea56a502616a8d6f36bc9c7e6e4efe /README.md | |
parent | 2213e90570af328418d4f4a0d54269ed21dc40bc (diff) | |
download | ethos-u-vela-ea6111a36e55501bbfb9ea022aaf8305b4d80183.tar.gz |
Add pre-commit support for sanity checks
Use pre-commit framework [1] to run black and flake8 before the commit.
black and flake8 are managed by the pre-commit framework and they can be
run manually by the user using `pre-commit run` command.
Fix the code base with the help of black and flake8.
Fix import statements according to PEP8 guidelines [1]
Both tools have the following settings (specified in the pre-commit
configuration file):
* line length: 120 characters
* directory to exclude: ethosu/vela/tflite/ and ethosu/vela/ethos_u55_regs
Updated README.md on how to install pre-commit and how to run sanity checks.
Pipenv files have been updated including new dependencies for pre-commit.
[1]: https://www.python.org/dev/peps/pep-0008/#imports
[2]: https://github.com/pre-commit/pre-commit
Change-Id: I304d9fffdf019d390ffa396a529c8a7c2437f63d
Signed-off-by: Diego Russo <diego.russo@arm.com>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -110,3 +110,45 @@ Contributions are accepted under [Apache License 2.0](LICENSE.txt). Only submit ## License Vela is licensed under [Apache License 2.0](LICENSE.txt) +## Contributions and Pull Requests + +Contributions are accepted under Apache-2.0. Only submit contributions where you have authored all of the code. + +### Sanity checks + +The Python codebase is PEP8 compliant with the exception of 120 characters line length. +We run 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: + +``` +pipenv install -e . --dev +``` + +After the installation, pre-commit is available in the virtual environment. + +#### 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: + +``` +$ 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 sanity checks + +Those checks can be run manually. This can be achievied running the following +``` +$ 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. |