forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
200 lines (179 loc) · 6.65 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
[tox]
envlist = generate-fixture-yml, linting, doclinting, ruleslinting, docbuild, cov-init, doctests, py{37,38,39,310,311,312}, dbt{110,120,130,140,150,160}, cov-report, mypy, winpy, dbt{130,150}-winpy, yamllint
[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 contraints 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{110,120,130,140,150,160,}: -r {toxinidir}/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{110,120,130,140,150,160,}: 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" environment
# is invoked. Leaving the trailing comma ensures that this environment
# still installs the relevant plugins.
{py,winpy}{37,38,39,310,311,312,}: python -m pip install {toxinidir}/plugins/sqlfluff-plugin-example
# For the dbt test cases install dependencies.
dbt{110,120,130,140,150,160,}: dbt deps --project-dir {toxinidir}/plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project --profiles-dir {toxinidir}/plugins/sqlfluff-templater-dbt/test/fixtures/dbt
# 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:linting]
# NOTE: We do install sqlfluff to run linting. This is
# because lint-imports requires the module to be installed.
commands =
# 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.
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 docs.
# If we don't we get import errors.
python {toxinidir}/docs/generate-rule-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 parser
mypy -p sqlfluff.core.parser --strict
[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
[pytest]
python_files = *_test.py
testpaths = test
[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\
/home/runner/work/sqlfluff/sqlfluff/src/
/home/runner/work/sqlfluff/sqlfluff/.tox/*/lib/*/site-packages/
[doc8]
# Ignore auto-generated docs
ignore-path=docs/source/partials/