blob: 13682f8fbdea9f08992e82a42fc2886f9b22d7ee [file] [log] [blame]
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +02001# tox (https://tox.readthedocs.io/) is a tool for running tests
2# in multiple virtualenvs. This configuration file will run the
3# test suite on all supported python versions. To use it, "pip install tox"
4# and then run "tox" from this directory.
5
6[tox]
Mitja Nikolausa054b832018-08-21 10:42:19 +02007envlist = py36
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +02008# There is no proper way to install the app for now (i.e. setup.py)
9skipsdist = True
10
11[testenv]
12deps =
13 -rrequirements.txt
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020014commands =
Franz-Xaver Geiger2a0de3d2018-09-19 10:27:04 +020015 python manage.py test {posargs}
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020016
Mitja Nikolaus940c0352018-08-29 12:31:57 +020017# Test coverage
18[testenv:coverage]
19deps =
20 {[testenv]deps}
21 coverage
22commands =
23 coverage run manage.py test
24 coverage report
25
26# Test coverage with html report
27[testenv:coverage-html]
28deps =
29 {[testenv:coverage]deps}
30commands =
31 {[testenv:coverage]commands}
32 coverage html
33
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020034# Linters
Franz-Xaver Geiger2a0de3d2018-09-19 10:27:04 +020035[linters]
36include_dirs = crashreports crashreport_stats hiccup
37
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020038[testenv:flake8]
39deps =
40 -rrequirements-dev-flake8.txt
41commands =
Franz-Xaver Geiger2a0de3d2018-09-19 10:27:04 +020042 flake8 {posargs: {[linters]include_dirs}}
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020043
44[testenv:pylint]
45deps =
46 -rrequirements.txt
47 -rrequirements-dev-pylint.txt
48commands =
Franz-Xaver Geiger2a0de3d2018-09-19 10:27:04 +020049 pylint {posargs: {[linters]include_dirs}}
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020050
51[testenv:linters]
52deps =
53 {[testenv:flake8]deps}
54 {[testenv:pylint]deps}
55commands =
56 {[testenv:flake8]commands}
57 {[testenv:pylint]commands}
58
Mitja Nikolausa054b832018-08-21 10:42:19 +020059# Git pre-commit hooks: Run formatter and linters
60[testenv:pre-commit-hooks]
61deps =
Mitja Nikolausbef34b92018-08-21 14:12:01 +020062 -rrequirements.txt
Mitja Nikolausa054b832018-08-21 10:42:19 +020063 -rrequirements-dev.txt
64passenv = GIT_INDEX_FILE
65commands =
66 {toxinidir}/tools/hooks/pre-commit.d/pre-commit-black.sh
67 python {toxinidir}/tools/hooks/pre-commit.d/pre-commit-flake8.py
Mitja Nikolausbef34b92018-08-21 14:12:01 +020068 {toxinidir}/tools/hooks/pre-commit.d/pre-commit-pylint.sh
Mitja Nikolausa054b832018-08-21 10:42:19 +020069
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020070# Flake8 configuration
71[flake8]
72format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
Borjan Tchakaloff7a70e552018-08-02 16:26:34 +020073max-complexity = 10
Mitja Nikolaus959e2d62018-08-21 17:51:09 +020074max-line-length = 80
Mitja Nikolausd1995062018-07-30 14:10:27 +020075
76# Documentation
77# Shared commands for both docs options
78[docs]
79swagger_version = 1.3.3
80commands =
81 python manage.py generate_swagger --overwrite documentation/hiccup-api.json
82 wget -nc https://jcenter.bintray.com/io/github/swagger2markup/swagger2markup-cli/{[docs]swagger_version}/swagger2markup-cli-{[docs]swagger_version}.jar
83whitelist_externals=
84 java
85 wget
86
87# Create markdown docs
88[testenv:docs]
89deps = {[testenv]deps}
90commands =
91 {[docs]commands}
92 java -jar swagger2markup-cli-{[docs]swagger_version}.jar convert \
93 -f documentation/api-endpoints \
94 -i documentation/hiccup-api.json \
95 -c documentation/swagger.properties
96whitelist_externals = {[docs]whitelist_externals}
97
98# Create HTML docs
99[testenv:docs-html]
100deps = {[testenv]deps}
101commands =
102 {[docs]commands}
103 java -jar swagger2markup-cli-{[docs]swagger_version}.jar convert \
104 -f documentation/api-endpoints \
105 -i documentation/hiccup-api.json \
106 -c documentation/swagger-asciidoc.properties
107 asciidoctor documentation/api-endpoints.adoc
108whitelist_externals =
109 {[docs]whitelist_externals}
110 asciidoctor