Skip to content

Commit

Permalink
Merge pull request #23 from laserprec/main
Browse files Browse the repository at this point in the history
Update tox.ini
  • Loading branch information
dciborow authored Apr 22, 2022
2 parents 29fc7e8 + 17e0a1c commit b19380f
Showing 1 changed file with 85 additions and 113 deletions.
198 changes: 85 additions & 113 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,130 +1,102 @@
[tox]
envlist = py37-{black,mypy,flake8,bandit,pylint,unit,integration}
# py will use whatever the basepython `python` maps to from PATH
# you can use py38, for example, to chosse a different version
# See https://tox.readthedocs.io/en/latest/config.html#tox-environments
envlist = py, cpu, gpu, spark, all


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

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

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

[testenv:py37-mypy]
skip_install = true
deps = mypy
commands =
mypy \
--config-file "tox.ini" \
"azureiai"
[testenv:spark]
# i.e: 'pip install <PAKCGE_NAME>-*.whl[dev,spark,examples]'
# with this dependency subset, we should be able to run the test markers:
# 1. "spark and not notebook and not spark" (test for spark utilities)
# 2. "spark and notebooks and not spark" (tests for notebook using spark)
extras = dev,spark,examples
# We will need to redefine the following envrionment var in tox
setenv =
PYSPARK_DRIVER_PYTHON = {envpython}
PYSPARK_PYTHON = {envpython}

[testenv:py37-flake8]
skip_install = true
deps = flake8
commands =
flake8 \
--config "tox.ini" \
"azureiai"
[testenv:all]
# i.e: 'pip install <PAKCGE_NAME>-*.whl[all]'
# with this, we should be able to run ANY tests
extras = all

[testenv:py37-bandit]
skip_install = true
deps = bandit
commands = bandit -r --ini "tox.ini"
[testenv:flake8]
deps = flake8
skip_install = True
commands = flake8 .

[testenv:py37-pylint]
deps =
pylint
pylint-junit
commands =
pylint \
--enable=locally-disabled \
--rcfile ".pylintrc" \
"azureiai"

[testenv:py37-safety]
skip_install = true
deps = safety
commands = safety check --full-report
# Configurations for running pytest
[pytest]
log_cli = False
log_format = %(asctime)s %(levelname)s %(message)s
junit_family = xunit2
# This enable custom marker as decorator "@pytest.mark.gpu"
markers =
# markers allow to us to run faster subset of the test:
# EX: pytest -m "not spark and not gpu"
# See https://docs.pytest.org/en/stable/example/markers.html#registering-markers
notebooks: mark a test as notebooks test
gpu: mark a test as gpu test
spark: mark a test as spark test
testpaths =
tests
addopts =
# reports all (except passed tests). See https://docs.pytest.org/en/latest/usage.html#detailed-summary-report
# TODO: please don't forget to replace <PACKAGE_NAME> with your python package name
-ra
--durations 10
--cov-append --cov=<PACKAGE_NAME> --cov-report=term --cov-report=xml --junitxml=junit/test-results.xml

[testenv:py37-unit]
deps =
pytest
coverage
pytest-cov
commands =
coverage erase
python3 -m pytest \
-c "tox.ini" \
-m "not integration and not gpu" \
--cov-append \
--cov-config ".coveragerc" \
--cov azureiai \
"tests"
coverage \
report \
--fail-under 80 \
--include "azureiai/*" \
--omit "azureiai/__init__.py"

[testenv:py37-integration]
deps =
pytest
pytest-parallel
commands =
python -m pytest \
-c "tox.ini" \
-m "integration" \
--workers "auto" \
--tests-per-worker "auto" \
"tests"
[coverage:report]
skip_empty = true
skip_covered = true

[bandit]
exclude = build,dist,tests,scripts
number: 4
recursive: True
skips = B110,B311,B314,B404,B405,B406
targets = azureiai

[flake8]
max-line-length = 120
select = F,E,W,B,B901,B902,B903
exclude =
.eggs,
.git,
.tox,
nssm,
obj,
out,
packages,
pywin32,
tests,
swagger_client
ignore = E722,B001,W503,E203

[pytest]
junit_family = xunit2
markers =
integration: marks as integration test
notebooks: marks as notebook test
gpu: marks as gpu test
smoke: marks as smoke test
spark: marks tests which need Spark
cdm: marks tests which need cdm
slow: marks tests as slow
unit: fast offline tests
ignore =
# Lint rules to ignore
# W503 # line break before binary operator
# E203 # whitespace before ':'

[mypy]
python_version = 3.7
ignore_missing_imports = True
strict_optional = False
follow_imports = silent
no_site_packages = True
# File-specific flake8 ignore rules
per-file-ignores =
# F403 'from X import *'
# F405 'X' may be undefined, or defined from star imports
# src/path/to/file/*.py:F403,F405

max-line-length = 180
exclude =
build, dist, docs, examples,
tests
.env*,.venv* # local virtual environments
.tox

0 comments on commit b19380f

Please sign in to comment.