Skip to content

Commit b19380f

Browse files
authored
Merge pull request #23 from laserprec/main
Update tox.ini
2 parents 29fc7e8 + 17e0a1c commit b19380f

File tree

1 file changed

+85
-113
lines changed

1 file changed

+85
-113
lines changed

tox.ini

Lines changed: 85 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,102 @@
11
[tox]
2-
envlist = py37-{black,mypy,flake8,bandit,pylint,unit,integration}
2+
# py will use whatever the basepython `python` maps to from PATH
3+
# you can use py38, for example, to chosse a different version
4+
# See https://tox.readthedocs.io/en/latest/config.html#tox-environments
5+
envlist = py, cpu, gpu, spark, all
36

7+
8+
# Default env settings
49
[testenv]
5-
deps =
6-
-r{toxinidir}/scripts/build/requirements/piptools.in
7-
-r{toxinidir}/scripts/build/requirements/test.in
8-
-rrequirements.txt
10+
# similar to 'pip install <PAKCGE_NAME>-*.whl[all]'
11+
extras = all
12+
commands =
13+
# {posargs} will be substituded by arguments after the `--` when running.
14+
# This will allow running subset of the test suite via tox.
15+
#
16+
# EX: tox -- -m "not spark and not gpu"
17+
# will pass {-m "not spark and not gpu"} to `pytest`
18+
# See https://tox.readthedocs.io/en/latest/example/general.html for more details
19+
pytest {posargs}
920

10-
depends =
11-
py37-{mypy,flake8,bandit,pylint,unit,integration}: py37-black
21+
[testenv:cpu]
22+
# i.e: 'pip install <PAKCGE_NAME>-*.whl[dev,examples]'
23+
# with this dependency subset, we should be able to run the test markers:
24+
# 1. "not notebooks and not spark and not gpu" (tests for general sdk utilities)
25+
# 2. "notebooks and not spark and not gpu" (tests for notebook example without extra dependencies)
26+
extras = dev,examples
1227

13-
[testenv:py37-black]
14-
skip_install = true
15-
deps = black
16-
commands = black \
17-
--config "black.toml" \
18-
"azureiai" \
19-
"tests"
28+
[testenv:gpu]
29+
# i.e: 'pip install <PAKCGE_NAME>-*.whl[dev,gpu,examples]'
30+
# with this dependency subset, we should be able to run the test markers:
31+
# 1. "gpu and not notebook and not spark" (tests for gpu utilities)
32+
# 2. "gpu and notebooks and not spark" (tests for notebooks needing gpu resources)
33+
extras = dev,gpu,examples
2034

21-
[testenv:py37-mypy]
22-
skip_install = true
23-
deps = mypy
24-
commands =
25-
mypy \
26-
--config-file "tox.ini" \
27-
"azureiai"
35+
[testenv:spark]
36+
# i.e: 'pip install <PAKCGE_NAME>-*.whl[dev,spark,examples]'
37+
# with this dependency subset, we should be able to run the test markers:
38+
# 1. "spark and not notebook and not spark" (test for spark utilities)
39+
# 2. "spark and notebooks and not spark" (tests for notebook using spark)
40+
extras = dev,spark,examples
41+
# We will need to redefine the following envrionment var in tox
42+
setenv =
43+
PYSPARK_DRIVER_PYTHON = {envpython}
44+
PYSPARK_PYTHON = {envpython}
2845

29-
[testenv:py37-flake8]
30-
skip_install = true
31-
deps = flake8
32-
commands =
33-
flake8 \
34-
--config "tox.ini" \
35-
"azureiai"
46+
[testenv:all]
47+
# i.e: 'pip install <PAKCGE_NAME>-*.whl[all]'
48+
# with this, we should be able to run ANY tests
49+
extras = all
3650

37-
[testenv:py37-bandit]
38-
skip_install = true
39-
deps = bandit
40-
commands = bandit -r --ini "tox.ini"
51+
[testenv:flake8]
52+
deps = flake8
53+
skip_install = True
54+
commands = flake8 .
4155

42-
[testenv:py37-pylint]
43-
deps =
44-
pylint
45-
pylint-junit
46-
commands =
47-
pylint \
48-
--enable=locally-disabled \
49-
--rcfile ".pylintrc" \
50-
"azureiai"
5156

52-
[testenv:py37-safety]
53-
skip_install = true
54-
deps = safety
55-
commands = safety check --full-report
57+
# Configurations for running pytest
58+
[pytest]
59+
log_cli = False
60+
log_format = %(asctime)s %(levelname)s %(message)s
61+
junit_family = xunit2
62+
# This enable custom marker as decorator "@pytest.mark.gpu"
63+
markers =
64+
# markers allow to us to run faster subset of the test:
65+
# EX: pytest -m "not spark and not gpu"
66+
# See https://docs.pytest.org/en/stable/example/markers.html#registering-markers
67+
notebooks: mark a test as notebooks test
68+
gpu: mark a test as gpu test
69+
spark: mark a test as spark test
70+
testpaths =
71+
tests
72+
addopts =
73+
# reports all (except passed tests). See https://docs.pytest.org/en/latest/usage.html#detailed-summary-report
74+
# TODO: please don't forget to replace <PACKAGE_NAME> with your python package name
75+
-ra
76+
--durations 10
77+
--cov-append --cov=<PACKAGE_NAME> --cov-report=term --cov-report=xml --junitxml=junit/test-results.xml
5678

57-
[testenv:py37-unit]
58-
deps =
59-
pytest
60-
coverage
61-
pytest-cov
62-
commands =
63-
coverage erase
64-
python3 -m pytest \
65-
-c "tox.ini" \
66-
-m "not integration and not gpu" \
67-
--cov-append \
68-
--cov-config ".coveragerc" \
69-
--cov azureiai \
70-
"tests"
71-
coverage \
72-
report \
73-
--fail-under 80 \
74-
--include "azureiai/*" \
75-
--omit "azureiai/__init__.py"
7679

77-
[testenv:py37-integration]
78-
deps =
79-
pytest
80-
pytest-parallel
81-
commands =
82-
python -m pytest \
83-
-c "tox.ini" \
84-
-m "integration" \
85-
--workers "auto" \
86-
--tests-per-worker "auto" \
87-
"tests"
80+
[coverage:report]
81+
skip_empty = true
82+
skip_covered = true
8883

89-
[bandit]
90-
exclude = build,dist,tests,scripts
91-
number: 4
92-
recursive: True
93-
skips = B110,B311,B314,B404,B405,B406
94-
targets = azureiai
9584

9685
[flake8]
97-
max-line-length = 120
98-
select = F,E,W,B,B901,B902,B903
99-
exclude =
100-
.eggs,
101-
.git,
102-
.tox,
103-
nssm,
104-
obj,
105-
out,
106-
packages,
107-
pywin32,
108-
tests,
109-
swagger_client
110-
ignore = E722,B001,W503,E203
111-
112-
[pytest]
113-
junit_family = xunit2
114-
markers =
115-
integration: marks as integration test
116-
notebooks: marks as notebook test
117-
gpu: marks as gpu test
118-
smoke: marks as smoke test
119-
spark: marks tests which need Spark
120-
cdm: marks tests which need cdm
121-
slow: marks tests as slow
122-
unit: fast offline tests
86+
ignore =
87+
# Lint rules to ignore
88+
# W503 # line break before binary operator
89+
# E203 # whitespace before ':'
12390

124-
[mypy]
125-
python_version = 3.7
126-
ignore_missing_imports = True
127-
strict_optional = False
128-
follow_imports = silent
129-
no_site_packages = True
91+
# File-specific flake8 ignore rules
92+
per-file-ignores =
93+
# F403 'from X import *'
94+
# F405 'X' may be undefined, or defined from star imports
95+
# src/path/to/file/*.py:F403,F405
13096

97+
max-line-length = 180
98+
exclude =
99+
build, dist, docs, examples,
100+
tests
101+
.env*,.venv* # local virtual environments
102+
.tox

0 commit comments

Comments
 (0)