blob: 4c7970df159dc1fd78e2c05a18c44cd66d310f52 [file] [log] [blame]
sousaedu2459af62021-01-15 16:50:26 +00001# Copyright 2021 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# 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#######################################################################################
sousaedu2459af62021-01-15 16:50:26 +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
sousaedu2459af62021-01-15 16:50:26 +000029
30[testenv]
David Garcia95ba7e12021-02-03 11:10:28 +010031basepython = python3.8
David Garciac753dc52021-03-17 15:28:47 +010032setenv = VIRTUAL_ENV={envdir}
33 PYTHONDONTWRITEBYTECODE = 1
David Garcia49379ce2021-02-24 13:48:22 +010034deps = -r{toxinidir}/requirements.txt
sousaedu2459af62021-01-15 16:50:26 +000035
David Garciac753dc52021-03-17 15:28:47 +010036
37#######################################################################################
38[testenv:black]
39deps = black
40commands =
41 black --check --diff src/ tests/
42
43
David Garcia49379ce2021-02-24 13:48:22 +010044#######################################################################################
45[testenv:cover]
46deps = {[testenv]deps}
47 -r{toxinidir}/requirements-test.txt
David Garciac753dc52021-03-17 15:28:47 +010048 coverage
49 nose2
David Garcia49379ce2021-02-24 13:48:22 +010050commands =
51 sh -c 'rm -f nosetests.xml'
52 coverage erase
53 nose2 -C --coverage src
54 coverage report --omit='*tests*'
55 coverage html -d ./cover --omit='*tests*'
56 coverage xml -o coverage.xml --omit=*tests*
57whitelist_externals = sh
58
David Garcia49379ce2021-02-24 13:48:22 +010059
60#######################################################################################
61[testenv:flake8]
David Garciac753dc52021-03-17 15:28:47 +010062deps = flake8
63 flake8-import-order
David Garcia49379ce2021-02-24 13:48:22 +010064commands =
65 flake8 src/ tests/
66
David Garciac753dc52021-03-17 15:28:47 +010067
David Garcia49379ce2021-02-24 13:48:22 +010068#######################################################################################
69[testenv:pylint]
70deps = {[testenv]deps}
71 -r{toxinidir}/requirements-test.txt
David Garciaca7d1b92021-09-30 10:35:54 +020072 pylint==2.10.2
David Garcia49379ce2021-02-24 13:48:22 +010073commands =
David Garciac753dc52021-03-17 15:28:47 +010074 pylint -E src/ tests/
75
David Garcia49379ce2021-02-24 13:48:22 +010076
77#######################################################################################
David Garciac753dc52021-03-17 15:28:47 +010078[testenv:safety]
79setenv =
80 LC_ALL=C.UTF-8
81 LANG=C.UTF-8
David Garcia49379ce2021-02-24 13:48:22 +010082deps = {[testenv]deps}
David Garciac753dc52021-03-17 15:28:47 +010083 safety
84commands =
85 - safety check --full-report
86
David Garcia49379ce2021-02-24 13:48:22 +010087
88#######################################################################################
89[testenv:yamllint]
90deps = {[testenv]deps}
91 -r{toxinidir}/requirements-test.txt
92 yamllint
93commands = yamllint .
94
95#######################################################################################
sousaedu2459af62021-01-15 16:50:26 +000096[testenv:build]
97passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
98whitelist_externals =
99 charmcraft
David Garciad680be42021-08-17 11:03:55 +0200100 sh
sousaedu2459af62021-01-15 16:50:26 +0000101commands =
David Garcia4a0db7c2022-02-21 11:48:11 +0100102 charmcraft pack
David Garciad680be42021-08-17 11:03:55 +0200103 sh -c 'ubuntu_version=20.04; \
104 architectures="amd64-aarch64-arm64"; \
105 charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
106 mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
sousaedu2459af62021-01-15 16:50:26 +0000107
David Garcia49379ce2021-02-24 13:48:22 +0100108#######################################################################################
109[flake8]
110ignore =
111 W291,
112 W293,
David Garciad680be42021-08-17 11:03:55 +0200113 W503,
David Garcia49379ce2021-02-24 13:48:22 +0100114 E123,
115 E125,
116 E226,
117 E241,
118exclude =
119 .git,
120 __pycache__,
121 .tox,
122max-line-length = 120
123show-source = True
124builtins = _
David Garciac753dc52021-03-17 15:28:47 +0100125max-complexity = 10
126import-order-style = google