Skip to content

Commit

Permalink
Deprecates experimental_run_shell_command in favour of `run_shell_c…
Browse files Browse the repository at this point in the history
…ommand` (pantsbuild#18266)

Also addresses various code review issues noticed post-merge in pantsbuild#18255
  • Loading branch information
Christopher Neugebauer authored and seve-martinez committed Feb 20, 2023
1 parent aa49103 commit a441b6b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/markdown/Helm/helm-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ data:
type: Opaque
```
```python src/deploy/BUILD
experimental_run_shell_command(
run_shell_command(
name="vals",
command="vals eval -f -",
)
Expand All @@ -290,7 +290,7 @@ helm_deployment(
)
```

In the previous example we define a `shell_command` target that will invoke the `vals eval` command (`vals` needs to be installed in the local machine) as part of the Helm post-rendering machinery, which will result on the `ref+vault` reference being replaced by the actual value stored in Vault at the given path.
In the previous example we define a `run_shell_command` target that will invoke the `vals eval` command (`vals` needs to be installed in the local machine) as part of the Helm post-rendering machinery, which will result on the `ref+vault` reference being replaced by the actual value stored in Vault at the given path.

> 📘 Using multiple post-renderers
>
Expand Down
4 changes: 2 additions & 2 deletions docs/markdown/Shell/run-shell-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ In case there are resulting files that should be captured and passed to any cons
>
> We are gathering feedback on this target before we promote it from its experimental status. Please reach out to us on [Slack](doc:getting-help) or [GitHub](https://github.com/pantsbuild/pants) with your ideas or issues.
The `experimental_run_shell_command` target
The `run_shell_command` target
-------------------------------------------

Unlike `shell_command`, the [`experimental_run_shell_command` target](doc:reference-experimental_run_shell_command) runs directly in your workspace, without sandboxing.
Unlike `shell_command`, the [`run_shell_command` target](doc:reference-run_shell_command) runs directly in your workspace, without sandboxing.

This target type allows you to formalize the Pants dependencies of shell scripts, and track when their impact on your workspace might have changed. But since its outputs cannot be captured, it must be a root target in your build graph (i.e.: it may not be consumed by other targets).
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_use_simple_extra_post_renderer(rule_runner: RuleRunner) -> None:
"""\
shell_sources(name="scripts")
experimental_run_shell_command(
run_shell_command(
name="custom_post_renderer",
command="src/shell/my-script.sh",
execution_dependencies=[":scripts"]
Expand Down
8 changes: 5 additions & 3 deletions src/python/pants/backend/shell/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ class ShellCommandTarget(Target):


class ShellCommandRunTarget(Target):
alias = "experimental_run_shell_command"
alias = "run_shell_command"
deprecated_alias = "run_shell_command"
deprecated_alias_removal_version = "2.18.0.dev0"
core_fields = (
*COMMON_TARGET_FIELDS,
ShellCommandExecutionDependenciesField,
Expand All @@ -421,7 +423,7 @@ class ShellCommandRunTarget(Target):
Example BUILD file:
experimental_run_shell_command(
run_shell_command(
command="./scripts/my-script.sh --data-files-dir={chroot}",
execution_dependencies=["src/project/files:data"],
)
Expand Down Expand Up @@ -468,7 +470,7 @@ class ShellCommandTestTarget(Target):
The `command` may use either `{chroot}` on the command line, or the `$CHROOT`
environment variable to get the root directory for where any dependencies are located.
In contrast to the `experimental_run_shell_command`, this target is intended to run shell commands as tests
In contrast to the `run_shell_command`, this target is intended to run shell commands as tests
and will only run them via the `test` goal.
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_passthrough_args() -> None:
sources = {
"src/BUILD": dedent(
"""\
experimental_run_shell_command(
run_shell_command(
name="args-test",
command='echo "cmd name (arg 0)=$0, args:$@"',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@ def test_run_shell_command_request(rule_runner: RuleRunner) -> None:
{
"src/BUILD": dedent(
"""\
experimental_run_shell_command(
run_shell_command(
name="test",
command="some cmd string",
)
experimental_run_shell_command(
run_shell_command(
name="cd-test",
command="some cmd string",
workdir="src/with space'n quote",
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/core/util_rules/adhoc_process_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def resolve_execution_environment(
execution_dependencies = Addresses()
warn_or_error(
"2.17.0.dev0",
("Using `dependencies` to specify execution-time dependencies for `shell_command` "),
"Using `dependencies` to specify execution-time dependencies for `shell_command` ",
(
"To clear this warning, use the `output_dependencies` and `execution_dependencies`"
"fields. Set `execution_dependencies=()` if you have no execution-time "
Expand Down
2 changes: 1 addition & 1 deletion testprojects/src/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ files(name="print_env_directory", sources=["print_env/**/*"])

files(name="sources_directory", sources=["sources/**/*"])

experimental_run_shell_command(
run_shell_command(
name="cmd",
command='{ find {chroot} -type f; echo "in: $CHROOT"; } | tee output.log',
execution_dependencies=[":hello_directory"],
Expand Down

0 comments on commit a441b6b

Please sign in to comment.