forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
142 lines (125 loc) · 3.9 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
[tox]
envlist = generate-fixture-yml, linting, doclinting, docbuild, cov-init, py{36,37,38,39,310}, dbt0{17,18,19,20,21}-py{37,38,39,310}, cov-report, bench, mypy, winpy, dbt0{17,18,19,20,21}-winpy
[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
# 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
# Install the plugins as required
dbt0{17,18,19,20,21}: 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.
dbt0{17,18,19,20,21}: dbt deps --project-dir plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project
# 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: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
[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/*
[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