forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
153 lines (133 loc) · 4.54 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
[tox]
envlist = generate-fixture-yml, linting, doclinting, ruleslinting, 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
dbt020: dbt-core==0.20.2
dbt021: dbt-core==0.21.0
dbt100: dbt-core==1.0.0
# Define dbt-postgres versions
dbt020: dbt-postgres==0.20.2
dbt021: dbt-postgres==0.21.0
dbt100: dbt-postgres==1.0.0
# Install the plugins as required
dbt{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 {toxinidir}/plugins/sqlfluff-templater-dbt/test/generate_packages_yml.py {toxinidir}/plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project
dbt{020,021,100}: 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 -rs --cov=sqlfluff --cov-report=xml {posargs: {toxinidir}/test} -m "not integration_test"
[testenv:cov-init]
setenv =
COVERAGE_FILE = .coverage
commands =
coverage erase
[testenv:bench]
commands =
python {toxinidir}/util.py benchmark -f {toxinidir}/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 {toxinidir}/test/generate_parse_fixture_yml.py
[testenv:linting]
skip_install = true
commands = flake8
[testenv:ruleslinting]
commands = pytest -vv -rs --cov=sqlfluff --cov-report=xml {posargs: {toxinidir}/test} -m "integration_test"
[testenv:yamllint]
skip_install = true
deps = yamllint
commands = yamllint -c .yamllint .
[testenv:doclinting]
skip_install = true
commands = doc8 {toxinidir}/docs/source --file-encoding utf8
[testenv:docbuild]
deps =
# -U keeps all requirements up-to-date
-Urdocs/requirements.txt
commands = make -C {toxinidir}/docs html
[testenv:mypy]
skip_install = true
commands = mypy {toxinidir}/src/sqlfluff
[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 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 = 88
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