| Mark Beierl | 6db47d4 | 2023-03-23 13:51:15 -0400 | [diff] [blame] | 1 | # Copyright 2022 Canonical Ltd. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | [tox] |
| 16 | skipsdist=True |
| 17 | skip_missing_interpreters = True |
| 18 | envlist = lint, unit |
| 19 | |
| 20 | [vars] |
| 21 | src_path = {toxinidir}/src/ |
| 22 | tst_path = {toxinidir}/tests/ |
| 23 | ;lib_path = {toxinidir}/lib/charms/ |
| 24 | all_path = {[vars]src_path} {[vars]tst_path} |
| 25 | |
| 26 | [testenv] |
| 27 | basepython = python3 |
| 28 | setenv = |
| 29 | PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} |
| 30 | PYTHONBREAKPOINT=ipdb.set_trace |
| 31 | passenv = |
| 32 | PYTHONPATH |
| 33 | HOME |
| 34 | PATH |
| 35 | CHARM_BUILD_DIR |
| 36 | MODEL_SETTINGS |
| 37 | HTTP_PROXY |
| 38 | HTTPS_PROXY |
| 39 | NO_PROXY |
| 40 | |
| 41 | [testenv:fmt] |
| 42 | description = Apply coding style standards to code |
| 43 | deps = |
| 44 | black |
| 45 | isort |
| 46 | commands = |
| 47 | isort {[vars]all_path} |
| 48 | black {[vars]all_path} |
| 49 | |
| 50 | [testenv:lint] |
| 51 | description = Check code against coding style standards |
| 52 | deps = |
| 53 | black |
| 54 | flake8>= 4.0.0, < 5.0.0 |
| 55 | flake8-docstrings |
| 56 | flake8-copyright |
| 57 | flake8-builtins |
| 58 | # prospector[with_everything] |
| 59 | pylint |
| 60 | pyproject-flake8 |
| 61 | pep8-naming |
| 62 | isort |
| 63 | codespell |
| 64 | yamllint |
| 65 | -r{toxinidir}/requirements.txt |
| 66 | commands = |
| 67 | codespell {toxinidir}/*.yaml {toxinidir}/*.ini {toxinidir}/*.md \ |
| 68 | {toxinidir}/*.toml {toxinidir}/*.txt {toxinidir}/.github |
| 69 | # prospector -A -F -T |
| 70 | pylint -E {[vars]src_path} |
| 71 | yamllint -d '\{extends: default, ignore: "build\n.tox" \}' . |
| 72 | # pflake8 wrapper supports config from pyproject.toml |
| 73 | pflake8 {[vars]all_path} |
| 74 | isort --check-only --diff {[vars]all_path} |
| 75 | black --check --diff {[vars]all_path} |
| 76 | |
| 77 | [testenv:unit] |
| 78 | description = Run unit tests |
| 79 | deps = |
| 80 | pytest |
| 81 | pytest-mock |
| 82 | pytest-cov |
| 83 | coverage[toml] |
| 84 | -r{toxinidir}/requirements.txt |
| 85 | commands = |
| 86 | pytest --ignore={[vars]tst_path}integration --cov={[vars]src_path} --cov-report=xml |
| 87 | coverage report |
| 88 | |
| 89 | [testenv:security] |
| 90 | description = Run security tests |
| 91 | deps = |
| 92 | bandit |
| 93 | safety |
| 94 | commands = |
| 95 | bandit -r {[vars]src_path} |
| 96 | - safety check |
| 97 | |
| 98 | [testenv:integration] |
| 99 | description = Run integration tests |
| 100 | deps = |
| 101 | pytest |
| 102 | pytest-operator |
| 103 | commands = |
| 104 | pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} |