Files
sqlfluff/tox.ini
Barry Pollard 3c56e20cbb Add yamllint to project (#2162)
* Add yamllint checks

* Update to ture/false instead of True/False

* Reinstate all rules

* Extend default

* Add ignore direcotries
2021-12-21 20:00:41 +00:00

157 lines
4.4 KiB
INI

[tox]
envlist = generate-fixture-yml, linting, doclinting, docbuild, cov-init, py{37,38,39,310}, dbt{017,018,019,020,021,100}-py{37,38,39,310}, cov-report, bench, mypy, winpy, dbt{017,018,019,020,021,100}-winpy, yamllint
[testenv]
passenv = CI CIRCLECI CIRCLE_* HOME SQLFLUFF_BENCHMARK_API_KEY
# Have option to explictly set TMPDIR for python as on GitHub Action Windows
# machines it doesn't read this from env and resets to system default, which
# is often on different drive (C) from working dir (D), which causes problems.
setenv =
SQLFLUFF_TESTENV = 1
COVERAGE_FILE = .coverage.{envname}
winpy: TMPDIR = temp_pytest
allowlist_externals =
make
deps =
# -U keeps dev requirements up-to-date
-Urrequirements_dev.txt
# Add the example plugin
plugins/sqlfluff-plugin-example
# Define dbt versions
dbt017: dbt-core==0.17.2
dbt018: dbt-core==0.18.2
dbt019: dbt-core==0.19.2
dbt020: dbt-core==0.20.2
dbt021: dbt-core==0.21.0
dbt100: dbt-core==1.0.0
# Define dbt-postgres versions
dbt017: dbt-postgres==0.17.2
dbt018: dbt-postgres==0.18.2
dbt019: dbt-postgres==0.19.2
dbt020: dbt-postgres==0.20.2
dbt021: dbt-postgres==0.21.0
dbt100: dbt-postgres==1.0.0
# Install the plugins as required
dbt{017,018,019,020,021,100}: plugins/sqlfluff-templater-dbt
# Include any other steps necessary for testing below.
# {posargs} is there to allow us to specify specific tests, which
# can then be invoked from tox by calling e.g.
# tox -e py35 -- project/tests/test_file.py::TestClassName::test_method
commands =
# For the dbt test cases install dependencies.
python plugins/sqlfluff-templater-dbt/test/generate_packages_yml.py plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project
dbt{017,018,019,020,021,100}: dbt deps --project-dir plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project --profiles-dir plugins/sqlfluff-templater-dbt/test/fixtures/dbt
# Clean up from previous tests
python util.py clean-tests
# Run tests
pytest -vv -rs --cov=sqlfluff --cov-report=xml {posargs: test}
[testenv:cov-init]
setenv =
COVERAGE_FILE = .coverage
commands =
coverage erase
[testenv:bench]
commands =
python util.py benchmark -f benchmarks/benchmarks.yml
[testenv:cov-report]
setenv =
COVERAGE_FILE = .coverage
commands =
coverage combine
# Exclude dbt templater by default as those tests do not run without dbt
coverage report --fail-under=100 --show-missing --omit "*templaters/dbt.py,*/dbt_templater/*"
# Have copy of above for full coverage - including dbt - for those that want it
[testenv:cov-report-dbt]
setenv =
COVERAGE_FILE = .coverage
commands =
coverage combine
coverage report --fail-under=100 --show-missing
[testenv:generate-fixture-yml]
commands = python test/generate_parse_fixture_yml.py
[testenv:linting]
skip_install = true
commands = flake8
[testenv:yamllint]
skip_install = true
deps = yamllint
commands = yamllint -c .yamllint .
[testenv:doclinting]
skip_install = true
commands = doc8 docs/source --file-encoding utf8
[testenv:docbuild]
deps =
# -U keeps all requirements up-to-date
-Urdocs/requirements.txt
commands = make -C docs html
[testenv:mypy]
skip_install = true
commands = mypy src/sqlfluff
[testenv:build-dist]
skip_install = true
deps =
build
commands =
python -m build --sdist --wheel {posargs: .}
[testenv:check-dist]
skip_install = true
deps =
twine
commands =
twine check dist/*
[testenv:publish-dist]
skip_install = true
deps =
{[testenv:build-dist]deps}
twine
commands =
{[testenv:build-dist]commands}
twine upload --skip-existing dist/*
[testenv:pre-commit]
skip_install = true
deps = pre-commit
commands =
pre-commit {posargs:run --all-files}
[flake8]
# Ignore:
# W503: Line breaks before binary operators
# D107: Don't require docstrings on __init__
# D105: Don't require docstrings on magic methods
ignore = W503, D107, D105, D418
exclude = .git,__pycache__,env,.tox,build,.venv,venv
max-line-length = 127
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
# sqlfluff uses flake8-docstrings https://pypi.org/project/flake8-docstrings/
# this is to assist with the sphinx based autodoc
docstring-convention = google
[pytest]
python_files = *_test.py
testpaths = test
[coverage:run]
source = src/sqlfluff
omit = src/sqlfluff/__main__.py
[coverage:report]
exclude_lines =
sys.version_info
pragma: no cover