-
-
Notifications
You must be signed in to change notification settings - Fork 745
/
pants.toml
275 lines (248 loc) · 10.5 KB
/
pants.toml
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
[anonymous-telemetry]
# This is opt-in by default, but we explicitly disable here as well.
enabled = false
# repo_id here allows individuals to opt-in on their machine
# To opt-in, use ~/.pants.rc or envrc to set [anonymous-telemetry].enabled=true
repo_id = "de0dea7a-9f6a-4c6e-aa20-6ba5ad969b8a"
[GLOBAL]
pants_version = "2.23.0a0"
pythonpath = ["%(buildroot)s/pants-plugins"]
build_file_prelude_globs = ["pants-plugins/macros.py"]
backend_packages = [
# https://www.pantsbuild.org/stable/docs/using-pants/validating-dependencies
"pants.backend.experimental.visibility",
# python
"pants.backend.python",
"pants.backend.experimental.python", # activates twine `publish` support
"pants.backend.experimental.python.framework.stevedore",
"pants.backend.python.mixed_interpreter_constraints",
"pants.backend.python.lint.bandit",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.pylint",
# shell
"pants.backend.shell",
"pants.backend.shell.lint.shellcheck",
# internal plugins in pants-plugins/
"pants.backend.plugin_development",
"api_spec",
"pack_metadata",
"release",
"sample_conf",
"schemas",
"uses_services",
]
# pants ignores files in .gitignore, .*/ directories, /dist/ directory, and __pycache__.
pants_ignore.add = [
# TODO: remove these once we start building wheels with pants.
"dist_utils.py",
"test_dist_utils.py",
"setup.py",
# keep tailor from using legacy requirements files (not for pants)
"contrib/examples/requirements.txt",
"contrib/hello_st2/requirements.txt",
"contrib/runners/*/in-requirements.txt",
"contrib/runners/*/requirements.txt",
"st2*/in-requirements.txt",
"st2*/requirements.txt",
"st2common/tests/fixtures/requirements-used-for-tests.txt",
"/fixed-requirements.txt",
"/test-requirements.txt",
# ignore requirements.txt for now, preferring interim files that are decoupled from
# legacy requirements files generation: requirements-pants.txt & lockfiles/st2-constraints.txt
"/requirements.txt",
]
[source]
# recording each pack individually under root patterns is not great, but resolves these issues:
# - Using a /contrib/* or other glob in root_patterns is dodgy as runners & schemas are in the same dir.
# In particular, with /contrib/* in root_patterns, *_runner imports become ambiguous
# (eg `import noop_runner` should use runners/noop_runner/noop_runner not runners/noop_runner).
# - Using pack.yaml in marker_filenames prevents pants from inferring which fixture packs are
# used by which tests. We import a PACK_NAME and PACK_PATH from fixture.py in each of these
# fixture packs to enable this dependency inferrence. Having fine grained inferrence in-turn
# reduces the number of tests that need to be re-run when we change a fixture.
# - Using another marker_file, like PACK_ROOT, is also problematic because of the core pack.
# /contrib/core is symlinked to /st2tests/st2tests/fixtures/packs/core for use as a fixture.
# It is used in quite a few tests, so it needs to continue living in both places.
# But, overlapping source roots (for st2tests and the pack) make importing from the fixture
# as we do with the other fixtures impossible.
# Thus, we really do need to register each pack in contrib (but never under st2tests) separately.
# We might also need to register packs in st2tests/testpacks.
root_patterns = [
# root conftest.py
"/",
# core libs
"/st2*",
# runners
"/contrib/runners/*_runner",
# packs (list /contrib/* packs individually; see note above)
"/contrib/chatops",
"/contrib/core", # WARNING: also symlinked to st2tests/st2tests/fixtures/packs/core
"/contrib/default",
"/contrib/examples",
"/contrib/hello_st2",
"/contrib/linux",
"/contrib/packs",
"/st2tests/testpacks/checks",
"/st2tests/testpacks/errorcheck",
# other special-cased pack directories
"/contrib/examples/actions/ubuntu_pkg_info", # python script runs via shell expecting cwd in PYTHONPATH
# lint plugins
"/pylint_plugins",
# pants plugins
"/pants-plugins",
# misc
"/scripts",
"/tools",
# benchmarks
"/st2common/benchmarks/micro",
]
# DEFAULT has values that we can reuse/interpolate below
[DEFAULT]
# This is the range of python versions that we support.
st2_interpreter_constraints = "CPython>=3.8,<3.10"
# This should match the pants interpreter_constraints:
# https://github.com/pantsbuild/pants/blob/2.22.x/pants.toml#L148
# See: https://www.pantsbuild.org/stable/docs/getting-started/prerequisites
pants_plugins_interpreter_constraints = "CPython==3.9.*"
# For tools, we have to include python versions for BOTH st2 and pants-plugins
tool_interpreter_constraints = "CPython>=3.8,<3.10"
flake8_interpreter_constraints = "CPython>=3.8.1,<3.10"
[python]
# resolver_version is always "pip-2020-resolver". legacy is not supported.
enable_resolves = true
default_resolve = "st2"
# python_distributions needs a single constraint (vs one line per python version).
interpreter_constraints = ["%(st2_interpreter_constraints)s"]
[python.resolves]
# st2 is the primary resolve
st2 = "lockfiles/st2.lock"
# tool and misc other resolves (for most, see //BUILD.tools)
bandit = "lockfiles/bandit.lock"
black = "lockfiles/black.lock"
flake8 = "lockfiles/flake8.lock"
pants-plugins = "lockfiles/pants-plugins.lock" # see //pants-plugins/BUILD
pylint = "lockfiles/pylint.lock" # see //pylint_plugins/BUILD
twine = "lockfiles/twine.lock"
[python.resolves_to_interpreter_constraints]
bandit = ["%(tool_interpreter_constraints)s"]
black = ["%(tool_interpreter_constraints)s"]
flake8 = ["%(flake8_interpreter_constraints)s"]
pants-plugins = ["%(pants_plugins_interpreter_constraints)s"]
pylint = ["%(tool_interpreter_constraints)s"]
twine = ["%(tool_interpreter_constraints)s"]
[python.resolves_to_constraints_file]
# Our direct requirements are in requirements-pants.txt;
# put indirect/transitive version constraints here:
st2 = "lockfiles/st2-constraints.txt"
[export]
# When exporting the virtualenv, include editable installs of our sources
# so that the entry_points metadata is available for stevedore's use.
py_editable_in_resolve = ["st2"]
# We need mutable venvs to use the editable installs of our sources.
py_resolve_format = "mutable_virtualenv"
# By default, pex modifies script shebangs to add '-sE'.
# This breaks nosetest and anything that needs PYTHONPATH.
py_non_hermetic_scripts_in_resolve = ["st2"]
# If any targets generate sources/files, include them in the exported venv.
py_generated_sources_in_resolve = ["st2"]
[python-infer]
# https://www.pantsbuild.org/stable/reference/subsystems/python-infer#string_imports
# https://www.pantsbuild.org/stable/reference/subsystems/python-infer#string_imports_min_dots
# Infer a target's dependencies based on strings that look like dynamic deps with >=1 dots.
# To debug the imports and see if a string is used in dep inference or if it is ignored, use:
# pants python-dump-source-analysis --analysis-flavor=raw_dependency_inference <path(s) to file(s)> | jq '.[].resolved'
string_imports = true
string_imports_min_dots = 1
# https://www.pantsbuild.org/stable/reference/subsystems/python-infer#unowned_dependency_behavior
# The default changed from "ignore" to "warning" in pants 2.14.
# The ambiguity_resolution setting/feature (below) added in 2.16 resolves most of
# our ambiguous dependency inference issues, which allowed us to remove the explicit
# deps in various BUILD files. But, there is not a good way to tell pants about our
# custom PYTHONPATH for packs, so actions that import other actions are still showing
# up as unowned. Maybe we can extend pants-plugins/pack_metadata so we can use "warn".
unowned_dependency_behavior = "ignore"
# https://www.pantsbuild.org/stable/reference/subsystems/python-infer#ambiguity_resolution
# When resolving ambiguous deps prefer one that is in the same source root as the
# file that uses it. So, without manually disambiguating the dep in the BUILD file,
# importing tests.unit.base in st2common/tests/unit will get a dep on st2common/tests/unit/base.py
ambiguity_resolution = "by_source_root"
[setup-py-generation]
# when building the package (with `pants package ::`), pants will,
# by default, generate a setup.py file for use with setuptools.
generate_setup_default = true # true by default
[bandit]
args = [
"-lll", # only HIGH severity level
"--exclude",
"build,dist",
"--quiet", # only show output in the case of an error
]
install_from_resolve = "bandit"
[black]
install_from_resolve = "black"
[flake8]
install_from_resolve = "flake8"
config = "lint-configs/python/.flake8"
[generate-lockfiles]
diff = true
[pylint]
install_from_resolve = "pylint"
config = "lint-configs/python/.pylintrc"
source_plugins = [
# the /pylint_plugins directory
"pylint_plugins",
]
args = [
# match the current Makefile usage with -E (TODO: drop this)
"--errors-only",
# needed in st2* components, runners, packs
"--load-plugins=api_models",
# needed in st2* components, runners
"--load-plugins=db_models",
]
[pytest]
install_from_resolve = "st2"
args = [
"--no-header", # don't print pytest version for every tested file
]
execution_slot_var = "ST2TESTS_PARALLEL_SLOT"
[regex-lint]
config = "@lint-configs/regex-lint.yaml"
[setuptools]
install_from_resolve = "st2"
[test]
extra_env_vars = [
# Use this so that the test system does not require the stanley user.
# For example: export ST2TESTS_SYSTEM_USER=${USER}
"ST2TESTS_SYSTEM_USER",
"ST2_SYSTEM_USER__USER",
# Use these to override MongoDB connection details
# "ST2_DATABASE__HOST", # Tests override this with "127.0.0.1"
"ST2_DATABASE__PORT",
# "ST2_DATABASE__DB_NAME", # Tests override this with: "st2-test{ST2TESTS_PARALLEL_SLOT}"
"ST2_DATABASE__CONNECTION_TIMEOUT",
"ST2_DATABASE__USERNAME",
"ST2_DATABASE__PASSWORD",
# Use these to override RabbitMQ connection details
"ST2_MESSAGING__URL",
"ST2_MESSAGING__PREFIX", # Tests will modify this to be "{prefix}{ST2TESTS_PARALLEL_SLOT}"
# Use these to override Redis connection details
"ST2TESTS_REDIS_HOST",
"ST2TESTS_REDIS_PORT",
# "ST2_COORDINATION__URL", # Tests will override this with one of:
# "redis://{ST2TESTS_REDIS_HOST}:{ST2TESTS_REDIS_PORT}?namespace=_st2_test{ST2TESTS_PARALLEL_SLOT}
# "zake://"
# CI-specific vars
"ST2_CI",
"ST2_CI_RUN_ORQUESTA_PAUSE_RESUME_TESTS",
]
# 10 min should be more than enough even for integration tests.
timeout_default = 600 # seconds
[twine]
install_from_resolve = "twine"
[environments-preview.names]
# https://www.pantsbuild.org/stable/docs/using-pants/environments
in_repo_workspace = "//:in_repo_workspace"
[cli.alias]
--all-changed = "--changed-since=HEAD --changed-dependents=transitive"