From adf89a2d0bb5eb970a9e1c39d8122f7262172ba3 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 10 Apr 2021 15:41:24 -0400 Subject: [PATCH 1/2] pants: disambiguate test file dependencies We do large sets of files because maintaining manual per-file mapping of dependencies would be a lot of pointless work. Hopefully a future version of pants will have features that make disambiguation more precise, integrating better with dependency inferrence. When that happens we can revert this commit in favor of telling pants how to infer the ambiguous deps instead of hard-coding the deps for a large set of files that might not need the dep. --- contrib/core/tests/BUILD | 13 ++++++++++++- contrib/packs/tests/BUILD | 11 ++++++++++- contrib/runners/orquesta_runner/tests/unit/BUILD | 4 ++++ st2auth/tests/unit/BUILD | 4 ++++ st2auth/tests/unit/controllers/v1/BUILD | 4 ++++ st2client/tests/unit/BUILD | 4 ++++ st2common/tests/unit/BUILD | 4 ++++ 7 files changed, 42 insertions(+), 2 deletions(-) diff --git a/contrib/core/tests/BUILD b/contrib/core/tests/BUILD index dabf212d7e..b679ff82cf 100644 --- a/contrib/core/tests/BUILD +++ b/contrib/core/tests/BUILD @@ -1 +1,12 @@ -python_tests() +python_tests( + overrides={ + "test_action_sendmail.py": { + "dependencies": [ + # contrib/core is symlinked to st2tests/st2tests/fixtures/packs/core + # so pants thinks "mail-parser" is defined twice, making it ambiguous. + # Use contrib/core as the canonical copy. + "contrib/core:reqs#mail-parser", + ], + } + }, +) diff --git a/contrib/packs/tests/BUILD b/contrib/packs/tests/BUILD index dabf212d7e..3a89bff937 100644 --- a/contrib/packs/tests/BUILD +++ b/contrib/packs/tests/BUILD @@ -1 +1,10 @@ -python_tests() +python_tests( + overrides={ + "test_action_download.py": { + "dependencies": [ + # imports tests.fixtures which is ambiguous. Tell pants which one to use. + "contrib/packs/tests/fixtures", + ], + } + }, +) diff --git a/contrib/runners/orquesta_runner/tests/unit/BUILD b/contrib/runners/orquesta_runner/tests/unit/BUILD index 00e59b3017..5934dd9b24 100644 --- a/contrib/runners/orquesta_runner/tests/unit/BUILD +++ b/contrib/runners/orquesta_runner/tests/unit/BUILD @@ -1,5 +1,9 @@ python_tests( name="tests", + dependencies=[ + # most files import tests.unit.base which is ambiguous. Tell pants which one to use. + "contrib/runners/orquesta_runner/tests/unit/base.py", + ], ) python_sources() diff --git a/st2auth/tests/unit/BUILD b/st2auth/tests/unit/BUILD index 57341b1358..bd52dfb436 100644 --- a/st2auth/tests/unit/BUILD +++ b/st2auth/tests/unit/BUILD @@ -1,3 +1,7 @@ python_tests( name="tests", + dependencies=[ + # most files import tests.base which is ambiguous. Tell pants which one to use. + "st2auth/tests/base.py", + ], ) diff --git a/st2auth/tests/unit/controllers/v1/BUILD b/st2auth/tests/unit/controllers/v1/BUILD index 57341b1358..bd52dfb436 100644 --- a/st2auth/tests/unit/controllers/v1/BUILD +++ b/st2auth/tests/unit/controllers/v1/BUILD @@ -1,3 +1,7 @@ python_tests( name="tests", + dependencies=[ + # most files import tests.base which is ambiguous. Tell pants which one to use. + "st2auth/tests/base.py", + ], ) diff --git a/st2client/tests/unit/BUILD b/st2client/tests/unit/BUILD index 57341b1358..9aaca5d249 100644 --- a/st2client/tests/unit/BUILD +++ b/st2client/tests/unit/BUILD @@ -1,3 +1,7 @@ python_tests( name="tests", + dependencies=[ + # most files import tests.base which is ambiguous. Tell pants which one to use. + "st2client/tests/base.py", + ], ) diff --git a/st2common/tests/unit/BUILD b/st2common/tests/unit/BUILD index 00e59b3017..34cacadb2b 100644 --- a/st2common/tests/unit/BUILD +++ b/st2common/tests/unit/BUILD @@ -1,5 +1,9 @@ python_tests( name="tests", + dependencies=[ + # several files import tests.unit.base which is ambiguous. Tell pants which one to use. + "st2common/tests/unit/base.py", + ], ) python_sources() From 1256d7378ee1152bed92e3a1bad7eba72895f47d Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 3 Dec 2022 12:25:22 -0600 Subject: [PATCH 2/2] update changelog entry --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 50fd4634ae..a572fc87b9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,7 +10,7 @@ Added * Continue introducing `pants `_ 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. - #5778 #5789 #5817 #5795 #5830 + #5778 #5789 #5817 #5795 #5830 #5833 Contributed by @cognifloyd