Skip to content

Commit

Permalink
Configure pantsbuild source roots (#5724)
Browse files Browse the repository at this point in the history
Configure pants source roots

https://www.pantsbuild.org/docs/initial-configuration\#configure-source-roots

based on a lot of work in a PoC pants branch.
  • Loading branch information
cognifloyd authored Sep 8, 2022
1 parent 675b1e6 commit dc00da8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Added

* Begin introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724
Contributed by @cognifloyd

Changed
Expand Down
44 changes: 44 additions & 0 deletions pants.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
[GLOBAL]
pants_version = "2.13.0rc2"

[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",
# odd import in examples.isprime
"/contrib/examples/lib",
# lint plugins
"/pylint_plugins",
# misc
"/scripts",
"/tools",
# benchmarks
"/st2common/benchmarks/micro",
]

0 comments on commit dc00da8

Please sign in to comment.