diff --git a/BUILD b/BUILD index b2d06d15f9..a56fcf6b6f 100644 --- a/BUILD +++ b/BUILD @@ -27,6 +27,36 @@ python_requirements( "st2auth/st2auth/backends/constants.py", ] ), + # make sure anything that uses st2-rbac-backend gets its deps + "st2-rbac-backend": dict( + dependencies=[ + # alphabetical order + "st2common/st2common/config.py", + "st2common/st2common/constants/keyvalue.py", + "st2common/st2common/constants/triggers.py", + "st2common/st2common/content/loader.py", + "st2common/st2common/exceptions/db.py", + "st2common/st2common/exceptions/rbac.py", + "st2common/st2common/log.py", + "st2common/st2common/models/api/rbac.py", + "st2common/st2common/models/db/action.py", + "st2common/st2common/models/db/auth.py", + "st2common/st2common/models/db/pack.py", + "st2common/st2common/models/db/rbac.py", + "st2common/st2common/models/db/webhook.py", + "st2common/st2common/models/system/common.py", + "st2common/st2common/persistence/auth.py", + "st2common/st2common/persistence/execution.py", + "st2common/st2common/persistence/rbac.py", + "st2common/st2common/rbac/backends/__init__.py", + "st2common/st2common/rbac/backends/base.py", + "st2common/st2common/rbac/types.py", + "st2common/st2common/script_setup.py", + "st2common/st2common/util/action_db.py", + "st2common/st2common/util/misc.py", + "st2common/st2common/util/uid.py", + ] + ), }, ) @@ -38,6 +68,13 @@ target( ], ) +target( + name="rbac_backends", + dependencies=[ + "//:reqs#st2-rbac-backend", + ], +) + python_test_utils( name="test_utils", skip_pylint=True, diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2b9ece24ad..b8174a7b48 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -64,7 +64,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. - #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253 + #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253 #6254 Contributed by @cognifloyd * Build of ST2 EL9 packages #6153 Contributed by @amanda11 diff --git a/contrib/chatops/actions/BUILD b/contrib/chatops/actions/BUILD index db46e8d6c9..4a1bef88f4 100644 --- a/contrib/chatops/actions/BUILD +++ b/contrib/chatops/actions/BUILD @@ -1 +1,7 @@ -python_sources() +python_sources( + overrides={ + "format_execution_result.py": dict( + dependencies=["./templates"], + ), + }, +) diff --git a/contrib/chatops/actions/templates/BUILD b/contrib/chatops/actions/templates/BUILD new file mode 100644 index 0000000000..96d5a456eb --- /dev/null +++ b/contrib/chatops/actions/templates/BUILD @@ -0,0 +1,3 @@ +resources( + sources=["*.j2"], +) diff --git a/contrib/chatops/tests/BUILD b/contrib/chatops/tests/BUILD index 0c6d9cabdb..ead8561daa 100644 --- a/contrib/chatops/tests/BUILD +++ b/contrib/chatops/tests/BUILD @@ -13,6 +13,9 @@ files( python_tests( name="tests", - dependencies=[":fixtures"], + dependencies=[ + ":fixtures", + "contrib/chatops:metadata", + ], skip_pylint=True, ) diff --git a/contrib/core/tests/BUILD b/contrib/core/tests/BUILD index c7c3ee5dea..1a4583beb6 100644 --- a/contrib/core/tests/BUILD +++ b/contrib/core/tests/BUILD @@ -16,6 +16,7 @@ python_tests( # Use contrib/core as the canonical copy. "contrib/core:reqs#mail-parser", ], + uses=["mongo"], ), }, ) diff --git a/contrib/packs/tests/BUILD b/contrib/packs/tests/BUILD index 25a2e7cc4b..c8265214ca 100644 --- a/contrib/packs/tests/BUILD +++ b/contrib/packs/tests/BUILD @@ -8,4 +8,22 @@ __defaults__( python_tests( skip_pylint=True, + overrides={ + "test_action_aliases.py": dict( + dependencies=[ + # test needs the pack and aliases metadata + "contrib/packs:metadata", + ], + ), + "test_action_unload.py": dict( + stevedore_namespaces=[ + "st2common.metrics.driver", + ], + entry_point_dependencies={ + "contrib/runners/http_runner": ["st2common.runners.runner"], + "contrib/runners/local_runner": ["st2common.runners.runner"], + "contrib/runners/python_runner": ["st2common.runners.runner"], + }, + ), + }, ) diff --git a/contrib/runners/action_chain_runner/tests/BUILD b/contrib/runners/action_chain_runner/tests/BUILD index 3280583e0c..d19247d547 100644 --- a/contrib/runners/action_chain_runner/tests/BUILD +++ b/contrib/runners/action_chain_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/action_chain_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/action_chain_runner/tests/unit/BUILD b/contrib/runners/action_chain_runner/tests/unit/BUILD index 9a24dba70a..47c65e48d3 100644 --- a/contrib/runners/action_chain_runner/tests/unit/BUILD +++ b/contrib/runners/action_chain_runner/tests/unit/BUILD @@ -5,4 +5,11 @@ __defaults__( python_tests( name="tests", + stevedore_namespaces=[ + "st2common.rbac.backend", + "st2common.metrics.driver", + # the core pack uses all runners. + "st2common.runners.runner", + ], + uses=["mongo"], ) diff --git a/contrib/runners/announcement_runner/tests/BUILD b/contrib/runners/announcement_runner/tests/BUILD index 3280583e0c..850b4aa71a 100644 --- a/contrib/runners/announcement_runner/tests/BUILD +++ b/contrib/runners/announcement_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/announcement_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/http_runner/tests/BUILD b/contrib/runners/http_runner/tests/BUILD index 3280583e0c..eccc29b3ee 100644 --- a/contrib/runners/http_runner/tests/BUILD +++ b/contrib/runners/http_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/http_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/inquirer_runner/tests/BUILD b/contrib/runners/inquirer_runner/tests/BUILD index 3280583e0c..36b90b1e2a 100644 --- a/contrib/runners/inquirer_runner/tests/BUILD +++ b/contrib/runners/inquirer_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/inquirer_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/local_runner/tests/BUILD b/contrib/runners/local_runner/tests/BUILD index 3280583e0c..d692891e08 100644 --- a/contrib/runners/local_runner/tests/BUILD +++ b/contrib/runners/local_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/local_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/noop_runner/tests/BUILD b/contrib/runners/noop_runner/tests/BUILD index 3280583e0c..208d20406f 100644 --- a/contrib/runners/noop_runner/tests/BUILD +++ b/contrib/runners/noop_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/noop_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/orquesta_runner/tests/BUILD b/contrib/runners/orquesta_runner/tests/BUILD index 3280583e0c..ea19a75243 100644 --- a/contrib/runners/orquesta_runner/tests/BUILD +++ b/contrib/runners/orquesta_runner/tests/BUILD @@ -1,6 +1,12 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/orquesta_runner": [ + "st2common.runners.runner", + "orquesta.expressions.functions", + ], + }, ) ) diff --git a/contrib/runners/orquesta_runner/tests/unit/BUILD b/contrib/runners/orquesta_runner/tests/unit/BUILD index 5b3cb7900c..51f3f0fc30 100644 --- a/contrib/runners/orquesta_runner/tests/unit/BUILD +++ b/contrib/runners/orquesta_runner/tests/unit/BUILD @@ -5,6 +5,13 @@ __defaults__( python_tests( name="tests", + stevedore_namespaces=[ + "st2common.metrics.driver", + "st2common.rbac.backend", + # the core pack uses all runners. + "st2common.runners.runner", + "orquesta.expressions.functions", + ], overrides={ ( "test_basic.py", @@ -16,6 +23,9 @@ python_tests( ): dict( uses=["system_user"], ), + "test_policies.py": dict( + dependencies=["st2actions/st2actions/policies/retry.py"] + ), }, ) diff --git a/contrib/runners/python_runner/tests/BUILD b/contrib/runners/python_runner/tests/BUILD index 3280583e0c..dfaf857926 100644 --- a/contrib/runners/python_runner/tests/BUILD +++ b/contrib/runners/python_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/python_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/python_runner/tests/integration/BUILD b/contrib/runners/python_runner/tests/integration/BUILD index 2d782aaea0..5fdf71eed3 100644 --- a/contrib/runners/python_runner/tests/integration/BUILD +++ b/contrib/runners/python_runner/tests/integration/BUILD @@ -5,4 +5,9 @@ __defaults__( python_tests( name="tests", + overrides={ + "test_python_action_process_wrapper.py": dict( + dependencies=["contrib/examples/actions/noop.py"] + ) + }, ) diff --git a/contrib/runners/python_runner/tests/unit/BUILD b/contrib/runners/python_runner/tests/unit/BUILD index 9a24dba70a..39ad860aa4 100644 --- a/contrib/runners/python_runner/tests/unit/BUILD +++ b/contrib/runners/python_runner/tests/unit/BUILD @@ -5,4 +5,20 @@ __defaults__( python_tests( name="tests", + overrides={ + "test_output_schema.py": dict( + dependencies=[ + "st2tests/st2tests/resources/packs/pythonactions/actions/pascal_row.py", + ], + ), + "test_pythonrunner.py": dict( + dependencies=[ + "st2tests/st2tests/resources/packs/pythonactions/actions", + ], + stevedore_namespaces=[ + "st2common.metrics.driver", + "st2common.rbac.backend", + ], + ), + }, ) diff --git a/contrib/runners/remote_runner/tests/BUILD b/contrib/runners/remote_runner/tests/BUILD index 3280583e0c..3391ed1f72 100644 --- a/contrib/runners/remote_runner/tests/BUILD +++ b/contrib/runners/remote_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/remote_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/contrib/runners/winrm_runner/tests/BUILD b/contrib/runners/winrm_runner/tests/BUILD index 3280583e0c..9c9ad37ef4 100644 --- a/contrib/runners/winrm_runner/tests/BUILD +++ b/contrib/runners/winrm_runner/tests/BUILD @@ -1,6 +1,9 @@ __defaults__( all=dict( skip_pylint=True, + entry_point_dependencies={ + "contrib/runners/winrm_runner": ["st2common.runners.runner"], + }, ) ) diff --git a/st2actions/tests/unit/BUILD b/st2actions/tests/unit/BUILD index 4e577b340a..e8c10aa3c7 100644 --- a/st2actions/tests/unit/BUILD +++ b/st2actions/tests/unit/BUILD @@ -5,13 +5,30 @@ __defaults__( python_tests( name="tests", + uses=["mongo"], overrides={ ( "test_execution_cancellation.py", "test_runner_container.py", "test_worker.py", ): dict( - uses=["system_user"], + uses=["mongo", "system_user"], + ), + ( + "test_execution*.py", + "test_notifier.py", + "test_output_schema.py", + "test_policies.py", + "test_queue_consumers.py", + "test_runner_container.py", + "test_scheduler*.py", + "test_worker.py", + "test_workflow_engine.py", + ): dict( + stevedore_namespaces=[ + "st2common.runners.runner", + "st2common.metrics.driver", + ], ), }, ) diff --git a/st2actions/tests/unit/policies/BUILD b/st2actions/tests/unit/policies/BUILD index 57341b1358..66a22040d1 100644 --- a/st2actions/tests/unit/policies/BUILD +++ b/st2actions/tests/unit/policies/BUILD @@ -1,3 +1,8 @@ python_tests( name="tests", + stevedore_namespaces=[ + "st2common.runners.runner", + "st2common.metrics.driver", + ], + uses=["mongo"], ) diff --git a/st2api/tests/unit/BUILD b/st2api/tests/unit/BUILD index 9a24dba70a..d649809607 100644 --- a/st2api/tests/unit/BUILD +++ b/st2api/tests/unit/BUILD @@ -5,4 +5,9 @@ __defaults__( python_tests( name="tests", + dependencies=["//:rbac_backends"], + stevedore_namespaces=[ + "st2common.rbac.backend", + ], + uses=["mongo"], ) diff --git a/st2api/tests/unit/controllers/BUILD b/st2api/tests/unit/controllers/BUILD index 57341b1358..e32c67ef43 100644 --- a/st2api/tests/unit/controllers/BUILD +++ b/st2api/tests/unit/controllers/BUILD @@ -1,3 +1,7 @@ python_tests( name="tests", + stevedore_namespaces=[ + "st2common.metrics.driver", + ], + uses=["mongo"], ) diff --git a/st2api/tests/unit/controllers/v1/BUILD b/st2api/tests/unit/controllers/v1/BUILD index 99064bb94c..5ef4f983f2 100644 --- a/st2api/tests/unit/controllers/v1/BUILD +++ b/st2api/tests/unit/controllers/v1/BUILD @@ -1,5 +1,11 @@ python_tests( name="tests", + stevedore_namespaces=[ + "st2common.runners.runner", + "st2common.rbac.backend", + "st2common.metrics.driver", + ], + uses=["mongo"], overrides={ ( "test_alias_execution.py", @@ -8,7 +14,12 @@ python_tests( "test_executions.py", "test_inquiries.py", ): dict( - uses=["system_user"], + uses=["mongo", "system_user"], + ), + "test_webhooks.py": dict( + dependencies=[ + "st2common/st2common/models/api/webhook.py", + ], ), }, ) diff --git a/st2auth/tests/unit/BUILD b/st2auth/tests/unit/BUILD index 9a24dba70a..c128c7b4af 100644 --- a/st2auth/tests/unit/BUILD +++ b/st2auth/tests/unit/BUILD @@ -5,4 +5,6 @@ __defaults__( python_tests( name="tests", + dependencies=["//:auth_backends"], + uses=["mongo"], ) diff --git a/st2auth/tests/unit/controllers/v1/BUILD b/st2auth/tests/unit/controllers/v1/BUILD index 57341b1358..66f5d44271 100644 --- a/st2auth/tests/unit/controllers/v1/BUILD +++ b/st2auth/tests/unit/controllers/v1/BUILD @@ -1,3 +1,8 @@ python_tests( name="tests", + stevedore_namespaces=[ + "st2auth.sso.backends", + "st2common.metrics.driver", + ], + uses=["mongo"], ) diff --git a/st2common/tests/fixtures/local_runner/BUILD b/st2common/tests/fixtures/local_runner/BUILD index db46e8d6c9..25c5073d83 100644 --- a/st2common/tests/fixtures/local_runner/BUILD +++ b/st2common/tests/fixtures/local_runner/BUILD @@ -1 +1,8 @@ -python_sources() +resources( + name="command_strings", + sources=["escaping_test_command_*.txt"], +) + +python_sources( + dependencies=[":command_strings"], +) diff --git a/st2common/tests/unit/BUILD b/st2common/tests/unit/BUILD index d8c6fe4709..fadc33869d 100644 --- a/st2common/tests/unit/BUILD +++ b/st2common/tests/unit/BUILD @@ -13,7 +13,7 @@ python_tests( ], uses=["mongo", "rabbitmq"], overrides={ - "test_util_file_system.py": dict( + ("test_util_file_system.py", "test_policies_registrar.py",): dict( dependencies=[ "st2tests/st2tests/policies", "st2tests/st2tests/policies/meta", diff --git a/st2common/tests/unit/services/BUILD b/st2common/tests/unit/services/BUILD index a30ca92a77..ae93633567 100644 --- a/st2common/tests/unit/services/BUILD +++ b/st2common/tests/unit/services/BUILD @@ -7,4 +7,12 @@ python_tests( "st2common.metrics.driver", ], uses=["mongo", "rabbitmq"], + overrides={ + "test_packs.py": dict( + # use the fixture to resolve ambiguous import (ambiguous due to symlink of core pack) + dependencies=[ + "st2tests/st2tests/fixtures/packs/core/actions/inject_trigger.py" + ], + ), + }, ) diff --git a/st2reactor/tests/unit/BUILD b/st2reactor/tests/unit/BUILD index 9a24dba70a..abd3115705 100644 --- a/st2reactor/tests/unit/BUILD +++ b/st2reactor/tests/unit/BUILD @@ -5,4 +5,20 @@ __defaults__( python_tests( name="tests", + uses=["mongo"], + overrides={ + "test_enforce.py": dict( + stevedore_namespaces=[ + "st2common.rbac.backend", + "st2common.runners.runner", + "st2common.metrics.driver", + ], + ), + "test_rule_engine.py": dict( + stevedore_namespaces=[ + "st2common.runners.runner", + "st2common.metrics.driver", + ], + ), + }, ) diff --git a/st2stream/tests/unit/controllers/v1/BUILD b/st2stream/tests/unit/controllers/v1/BUILD index a1ca2f641e..982e61ec88 100644 --- a/st2stream/tests/unit/controllers/v1/BUILD +++ b/st2stream/tests/unit/controllers/v1/BUILD @@ -1,5 +1,11 @@ python_tests( name="tests", + stevedore_namespaces=[ + "st2common.rbac.backend", + "st2common.runners.runner", + "st2common.metrics.driver", + ], + uses=["mongo"], ) python_test_utils( diff --git a/st2tests/st2tests/fixtures/generic/BUILD b/st2tests/st2tests/fixtures/generic/BUILD index 48fcf06310..5658638e23 100644 --- a/st2tests/st2tests/fixtures/generic/BUILD +++ b/st2tests/st2tests/fixtures/generic/BUILD @@ -3,6 +3,12 @@ pack_metadata( dependencies=[ "./actions:shell", "./actions:shell_resources", + # policytypes/fake_policy_type_1.py needs: + "//st2tests/st2tests/policies/concurrency.py", + # policytypes/fake_policy_type_2.py needs: + "//st2tests/st2tests/policies/mock_exception.py", + # policytypes/fake_policy_type_3.py needs: + "//st2actions/st2actions/policies/concurrency_by_attr.py", ], )