-
Notifications
You must be signed in to change notification settings - Fork 10
readme.md #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
readme.md #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,57 @@ | ||
| # rules_shell | ||
| # Bazel `rules_shell` | ||
|
|
||
| This repository contains the Bazel ruleset for shell scripts. | ||
| [`rules_shell`](https://github.com/bazelbuild/rules_shell) is an experimental Bazel ruleset maintained by the Bazel team that enables modern, hermetic support for writing Bazel targets using shell scripts. | ||
|
|
||
| --- | ||
|
|
||
| ## Purpose | ||
|
|
||
| The goal of `rules_shell` is to make working with shell scripts in Bazel more robust and reproducible, similar to how Bazel handles other languages like Go (`rules_go`) or Python (`rules_python`). | ||
|
|
||
| --- | ||
|
|
||
| ## Key Features | ||
|
|
||
| - **Hermetic `sh_binary` and `sh_test` rules** | ||
| - Declare and manage script dependencies explicitly | ||
| - Scripts only access files and tools declared as inputs | ||
|
|
||
| - **Shell toolchain support** | ||
| - Customizable shell interpreter (e.g., specific `bash` version) | ||
| - Cross-platform support via toolchain configuration | ||
|
|
||
| - **Reproducibility and sandboxing** | ||
| - Ensures scripts only access declared inputs | ||
| - Improves remote caching and build determinism | ||
|
|
||
| --- | ||
|
|
||
| ## Example | ||
|
|
||
| Here’s a simple example of a shell binary using `rules_shell`: | ||
|
|
||
| ```python | ||
| load("@rules_shell//shell:defs.bzl", "sh_binary") | ||
|
|
||
| sh_binary( | ||
| name = "hello", | ||
| srcs = ["hello.sh"], | ||
| data = [":greeting.txt"], | ||
| deps = ["@bash//:bin/bash"], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this could be realized as the script needs some shebang that would run first. If we want it to be truly hermetic, we would need to involve a launcher binary, a simple dep wouldn't help. |
||
| ) | ||
| ``` | ||
|
|
||
| ## Dependancies | ||
|
|
||
| Please note that rules_shell depends on bash outside of the Bazel sandbox | ||
|
|
||
| ``` | ||
| _DEFAULT_SHELL_PATHS = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should mention that these are the default paths, but that you can register your own toolchains and/or set |
||
| "windows": "c:/msys64/usr/bin/bash.exe", | ||
| "linux": "/bin/bash", | ||
| "osx": "/bin/bash", | ||
| "freebsd": "/usr/local/bin/bash", | ||
| "openbsd": "/usr/local/bin/bash", | ||
| } | ||
| ``` | ||
| [sh_config.bzl](https://github.com/bazelbuild/rules_shell/blob/main/shell/private/repositories/sh_config.bzl#L18) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a stab at this, but I fear that we don't really live up to this promise just yet. This ruleset is more or less a faithful port of the formerly native shell rules, it's not (yet) more robust or reproducible.
There is an active proposal for integrating
ctx.actions.run_shellwith rules_shell as well as providing a PATH of hermetic shell tools. I would like to wait for that to be implemented before we claim this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any README.md that you'd be able to add to give some indication to how rules_shell is supposed to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filmil
Thanks for your response
Sorry I'm not sure who you are asking
In general, this merge request was mostly intended to highlight that rules_shell isn't well documented. In particular, it is unclear [at least to a fool like me] what rules_shell is intending to achieve.
I strongly suspect that that team who wrote rules_shell did have a clear intent and do understand what rules_shell all about. - It would really help others to document this even minimally. It might even help the experts who do understand to stay on track :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question was for @fmeum . It would be nice if a maintainer would bootstrap a README.md with main points to know about the rule set.