diff --git a/.agents/rules/github_actions_workflows.md b/.agents/rules/github_actions_workflows.md index f4c2892ac8..b85ee5c3b8 100644 --- a/.agents/rules/github_actions_workflows.md +++ b/.agents/rules/github_actions_workflows.md @@ -47,6 +47,12 @@ globs: ".github/workflows/**,.github/actions/**,.github/dependabot.yml" binary directly from `bazel-bin//` instead of `bazel run`, explicitly include `//:` in `bazel build` so its `.runfiles` tree is materialized. +* **Flat Staging for `actions/upload-artifact` Across Split Transitions**: + `actions/upload-artifact` strips only the longest common parent directory of + all matched `path` entries. When uploading files from multiple Bazel + configurations (`bazel-out//...`, `bazel-out//...`), stage them + into a single flat directory first (reading paths from the rule's `.txt` + manifest) so `/...` subdirectories are not preserved in the artifact. ## Workflow Scripts & Testing * **Separate Script Files (No Inline Scripts)**: Factor non-trivial scripts diff --git a/.agents/rules/shell.md b/.agents/rules/shell.md new file mode 100644 index 0000000000..015a0a2ecd --- /dev/null +++ b/.agents/rules/shell.md @@ -0,0 +1,13 @@ +--- +trigger: glob +description: Shell / Bash scripting style and portability rules +globs: "*.sh" +--- + +# Shell Scripting Rules + +* Use `elif` instead of nesting `if` inside an `else` block. +* When reading file paths from a manifest or list file, iterate line-by-line + with `while IFS= read -r file; do ...; done < "$manifest"`. Do not use + unquoted command substitution (`$(cat "$manifest")`) or suppress ShellCheck + `SC2046` assuming paths lack spaces. diff --git a/.agents/rules/starlark.md b/.agents/rules/starlark.md index 0f64a7d0c6..d08afd85e5 100644 --- a/.agents/rules/starlark.md +++ b/.agents/rules/starlark.md @@ -60,8 +60,16 @@ globs: "*.bzl,BUILD,BUILD.bazel,*.bazel" fields must be immutable when `depset()` is called (eager check before rule freeze). Use `tuple[T]` or `depset[T]` in providers placed into depsets; do not use mutable `list[T]`. +* **Dedicated Providers over Filtering `DefaultInfo.files`**: When a rule needs + a subset of a dependency's outputs (e.g., binaries without a sibling `.txt` + manifest), return a dedicated provider (e.g., `_ReleaseFilesInfo`) instead of + filtering `DefaultInfo.files` by filename or extension. ## Code Style & Conventions +* **Do Not Export `BUILD` Files Unnecessarily**: Do not add `BUILD` or + `BUILD.bazel` to `exports_files(...)` unless strictly required. +* **No Nested List Comprehensions**: Do not write nested list comprehensions + (`[x for y in ... for x in ...]`). Use explicit `for` loops instead. * **Direct Attribute Access**: Use normal attribute access (`x.field`) instead of `getattr(x, "field", default)` for fields defined on a provider or struct schema. When an object may be one of multiple provider/struct variants with