blob: f3c914402935c294258be732eb4d3ff14242ea02 [file] [log] [blame]
David Garcia49379ce2021-02-24 13:48:22 +01001# Copyright 2021 Canonical Ltd.
sousaedu1dd4c0d2020-11-04 17:43:47 +00002#
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# For those usages not covered by the Apache License, Version 2.0 please
16# contact: legal@canonical.com
17#
18# To get in touch with the maintainers, please contact:
19# osm-charmers@lists.launchpad.net
20##
David Garcia49379ce2021-02-24 13:48:22 +010021#######################################################################################
sousaedu1dd4c0d2020-11-04 17:43:47 +000022
23[tox]
David Garciac753dc52021-03-17 15:28:47 +010024envlist = black, cover, flake8, pylint, yamllint, safety
25skipsdist = true
26
27[tox:jenkins]
28toxworkdir = /tmp/.tox
sousaedu1dd4c0d2020-11-04 17:43:47 +000029
30[testenv]
David Garcia95ba7e12021-02-03 11:10:28 +010031basepython = python3.8
David Garcia4a0db7c2022-02-21 11:48:11 +010032setenv =
33 VIRTUAL_ENV={envdir}
34 PYTHONPATH = {toxinidir}:{toxinidir}/lib:{toxinidir}/src
35 PYTHONDONTWRITEBYTECODE = 1
David Garcia49379ce2021-02-24 13:48:22 +010036deps = -r{toxinidir}/requirements.txt
sousaedu1dd4c0d2020-11-04 17:43:47 +000037
David Garciac753dc52021-03-17 15:28:47 +010038
39#######################################################################################
40[testenv:black]
41deps = black
42commands =
43 black --check --diff src/ tests/
44
45
David Garcia49379ce2021-02-24 13:48:22 +010046#######################################################################################
47[testenv:cover]
48deps = {[testenv]deps}
49 -r{toxinidir}/requirements-test.txt
David Garciac753dc52021-03-17 15:28:47 +010050 coverage
51 nose2
David Garcia49379ce2021-02-24 13:48:22 +010052commands =
53 sh -c 'rm -f nosetests.xml'
54 coverage erase
55 nose2 -C --coverage src
56 coverage report --omit='*tests*'
57 coverage html -d ./cover --omit='*tests*'
58 coverage xml -o coverage.xml --omit=*tests*
59whitelist_externals = sh
60
David Garcia49379ce2021-02-24 13:48:22 +010061
62#######################################################################################
63[testenv:flake8]
David Garciac753dc52021-03-17 15:28:47 +010064deps = flake8
65 flake8-import-order
David Garcia49379ce2021-02-24 13:48:22 +010066commands =
67 flake8 src/ tests/
68
David Garciac753dc52021-03-17 15:28:47 +010069
David Garcia49379ce2021-02-24 13:48:22 +010070#######################################################################################
71[testenv:pylint]
72deps = {[testenv]deps}
73 -r{toxinidir}/requirements-test.txt
David Garciaca7d1b92021-09-30 10:35:54 +020074 pylint==2.10.2
David Garcia49379ce2021-02-24 13:48:22 +010075commands =
David Garciac753dc52021-03-17 15:28:47 +010076 pylint -E src/ tests/
77
David Garcia49379ce2021-02-24 13:48:22 +010078
79#######################################################################################
David Garciac753dc52021-03-17 15:28:47 +010080[testenv:safety]
81setenv =
82 LC_ALL=C.UTF-8
83 LANG=C.UTF-8
David Garcia49379ce2021-02-24 13:48:22 +010084deps = {[testenv]deps}
David Garciac753dc52021-03-17 15:28:47 +010085 safety
86commands =
87 - safety check --full-report
88
David Garcia49379ce2021-02-24 13:48:22 +010089
90#######################################################################################
91[testenv:yamllint]
92deps = {[testenv]deps}
93 -r{toxinidir}/requirements-test.txt
94 yamllint
95commands = yamllint .
96
97#######################################################################################
sousaedu1dd4c0d2020-11-04 17:43:47 +000098[testenv:build]
99passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
100whitelist_externals =
101 charmcraft
David Garciad680be42021-08-17 11:03:55 +0200102 sh
sousaedu1dd4c0d2020-11-04 17:43:47 +0000103commands =
David Garcia4a0db7c2022-02-21 11:48:11 +0100104 charmcraft pack
David Garciad680be42021-08-17 11:03:55 +0200105 sh -c 'ubuntu_version=20.04; \
106 architectures="amd64-aarch64-arm64"; \
107 charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
108 mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
sousaedu1dd4c0d2020-11-04 17:43:47 +0000109
David Garcia49379ce2021-02-24 13:48:22 +0100110#######################################################################################
111[flake8]
112ignore =
113 W291,
114 W293,
sousaedu996a5602021-05-03 00:22:43 +0200115 W503,
David Garcia49379ce2021-02-24 13:48:22 +0100116 E123,
117 E125,
118 E226,
119 E241,
120exclude =
121 .git,
122 __pycache__,
123 .tox,
124max-line-length = 120
125show-source = True
126builtins = _
David Garciac753dc52021-03-17 15:28:47 +0100127max-complexity = 10
128import-order-style = google