mirror of
https://github.com/sqlfluff/sqlfluff
synced 2025-12-17 19:31:32 +00:00
233 lines
7.9 KiB
INI
233 lines
7.9 KiB
INI
[tox]
|
||
envlist = generate-fixture-yml, generate-rs, check-rs, build-rs, linting, doclinting, ruleslinting, docbuild, cov-init, doctests, py{39,310,311,312,313}, dbt{170,180,190,1100}, rust, cov-report, mypy, mypyc, winpy, dbt{180,190}-winpy, yamllint
|
||
min_version = 4.0 # Require 4.0+ for proper pyproject.toml support
|
||
|
||
[testenv]
|
||
passenv = CI, CIRCLECI, CIRCLE_*, HOME, SQLFLUFF_BENCHMARK_API_KEY
|
||
# Have option to explicitly 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
|
||
pip_pre = false
|
||
deps =
|
||
-r requirements_dev.txt
|
||
# Apply the constraints files _as requirements_ files here so that
|
||
# we force the right installation version up front in each environment.
|
||
# NOTE: This is a bit of a hack around tox, but it does achieve reasonably
|
||
# consistent results.
|
||
dbt{170,180,190,1100}: -r constraints/{envname}.txt
|
||
# 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 =
|
||
# Install the plugins as required.
|
||
# NOTE: We do them here, so that when version numbers update, we don't
|
||
# get install errors for version conflicts. The dbt templater has a version
|
||
# number pinned to the same version number of the main sqlfluff library
|
||
# so it _must_ be installed second in the context of a version which isn't
|
||
# yet released (and so not available on pypi).
|
||
dbt{170,180,190,1100}: python -m pip install "{toxinidir}/plugins/sqlfluff-templater-dbt"
|
||
# Add the example plugin.
|
||
# NOTE: The trailing comma is important because in the github test suite
|
||
# the python version is not specified and instead the "py" or "winpy"
|
||
# environment is invoked. Leaving the trailing comma ensures that this
|
||
# environment still installs the relevant plugins.
|
||
{py,winpy}{39,310,311,312,313,}: python -m pip install "{toxinidir}/plugins/sqlfluff-plugin-example"
|
||
rust: python -m pip install --force-reinstall --no-deps --no-index --find-links="{toxinidir}/dist" sqlfluffrs
|
||
# Clean up from previous tests
|
||
python "{toxinidir}/util.py" clean-tests
|
||
# Run tests
|
||
pytest -vv -rsfE --cov-report=lcov {posargs: "{toxinidir}/test"}
|
||
python test/patch_lcov.py
|
||
|
||
[testenv:cov-init]
|
||
setenv =
|
||
COVERAGE_FILE = .coverage
|
||
commands =
|
||
coverage erase
|
||
|
||
[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 "{toxinidir}/test/generate_parse_fixture_yml.py" {posargs}
|
||
|
||
[testenv:generate-rs]
|
||
commands =
|
||
pip install -e "{toxinidir}"
|
||
python "{toxinidir}/utils/rustify.py" "build"
|
||
|
||
[testenv:check-rs]
|
||
commands =
|
||
pip install -e "{toxinidir}"
|
||
python "{toxinidir}/utils/rustify.py" "check"
|
||
|
||
[testenv:build-rs]
|
||
skip_install = True
|
||
deps = maturin
|
||
commands =
|
||
maturin build --release --out dist --manifest-path sqlfluffrs/Cargo.toml {posargs}
|
||
|
||
[testenv:linting]
|
||
# NOTE: We do install sqlfluff to run linting. This is
|
||
# because lint-imports requires the module to be installed.
|
||
commands =
|
||
flake8 --version
|
||
black --version
|
||
ruff --version
|
||
# ruff is configured to check linting and imports.
|
||
# see: .ruff.toml and https://docs.astral.sh/ruff/rules/
|
||
ruff check .
|
||
# Ruff *should* catch everything that flake8 does. Until
|
||
# that has been confirmed, flake8 remains, but ruff runs first.
|
||
black --diff .
|
||
flake8
|
||
# Check import references.
|
||
lint-imports
|
||
|
||
[testenv:doctests]
|
||
commands = pytest -vv -rsfE --doctest-modules {posargs: "{toxinidir}/src"}
|
||
|
||
[testenv:yamllint]
|
||
skip_install = true
|
||
deps = yamllint
|
||
commands = yamllint -c .yamllint .
|
||
|
||
[testenv:doclinting]
|
||
deps =
|
||
-rdocs/requirements.txt
|
||
commands =
|
||
# Before linting, generate the rule & dialect docs.
|
||
# If we don't we get import errors.
|
||
python "{toxinidir}/docs/generate-auto-docs.py"
|
||
doc8 "{toxinidir}/docs/source" --file-encoding utf8
|
||
|
||
[testenv:docbuild]
|
||
deps =
|
||
-rdocs/requirements.txt
|
||
commands = make -C "{toxinidir}/docs" html
|
||
|
||
[testenv:mypy]
|
||
# NOTE: We do install sqlfluff to run mypy, this
|
||
# is so we can refer to the package as a package.
|
||
# It also appears to make --strict checking more
|
||
# stable.
|
||
commands =
|
||
# Standard MyPy on the main package
|
||
mypy -p sqlfluff
|
||
# Strict MyPy on the core package
|
||
mypy -p sqlfluff.core --strict
|
||
|
||
[testenv:mypyc]
|
||
skip_install = true
|
||
changedir = src
|
||
commands =
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.api
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.cli
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.config
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.dialects
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.helpers
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.linter
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.parser.grammar
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.core.plugin
|
||
mypyc --config-file ../pyproject.toml -p sqlfluff.utils.reflow
|
||
|
||
[testenv:build-dist]
|
||
skip_install = true
|
||
deps =
|
||
build
|
||
commands =
|
||
python -m build --sdist --wheel {posargs: "{toxinidir}"}
|
||
|
||
[testenv:check-dist]
|
||
skip_install = true
|
||
deps =
|
||
twine
|
||
commands =
|
||
twine check "{toxinidir}/dist/*"
|
||
|
||
[testenv:publish-dist]
|
||
skip_install = true
|
||
deps =
|
||
{[testenv:build-dist]deps}
|
||
twine
|
||
commands =
|
||
{[testenv:build-dist]commands}
|
||
twine upload --skip-existing "{toxinidir}/dist/*"
|
||
|
||
[testenv:pre-commit]
|
||
skip_install = true
|
||
deps = pre-commit
|
||
commands =
|
||
pre-commit {posargs:run --all-files}
|
||
|
||
[flake8]
|
||
# Ignore:
|
||
# W503: Line break before binary operator
|
||
# D105: Missing docstring in magic method
|
||
# D107: Missing docstring in __init__
|
||
# D418: Function/ Method decorated with @overload shouldn’t contain a docstring
|
||
# C812: Missing trailing comma
|
||
ignore = W503, D107, D105, D418, C812
|
||
exclude = .git,__pycache__,env,.tox,build,.venv,venv,.coverage.py,plugins/sqlfluff-templater-dbt/sqlfluff_templater_dbt/osmosis/*.py
|
||
max-line-length = 88
|
||
inline-quotes = double
|
||
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
|
||
|
||
[coverage:run]
|
||
source = src/sqlfluff
|
||
omit =
|
||
src/sqlfluff/__main__.py
|
||
plugins/sqlfluff-templater-dbt/sqlfluff_templater_dbt/osmosis/*.py
|
||
|
||
[coverage:report]
|
||
exclude_lines =
|
||
sys.version_info
|
||
pragma: no cover
|
||
# See: https://github.com/nedbat/coveragepy/issues/970
|
||
# NOTE: Prefer not including the ... instead
|
||
@overload
|
||
# See: https://github.com/pytest-dev/pytest-cov/issues/428
|
||
@abstractmethod
|
||
# NOTE: Prefer not including the ... instead
|
||
|
||
[coverage:paths]
|
||
source =
|
||
# Local path
|
||
src/
|
||
# These are the Github likely source paths
|
||
D:\a\sqlfluff\sqlfluff\src\
|
||
D:\a\sqlfluff\sqlfluff\.tox\winpy\Lib\site-packages\
|
||
# Github Actions are now using C:
|
||
C:\a\sqlfluff\sqlfluff\src\
|
||
C:\a\sqlfluff\sqlfluff\.tox\winpy\Lib\site-packages\
|
||
/home/runner/work/sqlfluff/sqlfluff/src/
|
||
/home/runner/work/sqlfluff/sqlfluff/.tox/*/lib/*/site-packages/
|
||
dbt_templater =
|
||
plugins/sqlfluff-templater-dbt/sqlfluff_templater_dbt/
|
||
.tox/*/lib/*/site-packages/sqlfluff_templater_dbt/
|