Expand `ActionExecutionMetadata.getKey()` method to accept an ArtifactExpander.

Computing a key which uniquely identifies whether 2 actions are equal is
generally impossible without the ability to expand tree artifacts. The source of
the problem happens for Starlark-defined actions which use `Args.add_all` with
a custom `map_each` function and `expand_directories` option enabled. For such
functions, we cannot know the real output of the execution until we can expand
the directory arguments.

Please consider an example:

```
def f(file):
  if file.is_directory():
    return file.path
  return file.path + '_suffix'

directory = ... # input directory
args = ctx.actions.args()
args.add_all([directory], map_each=f, expand_directories=True)
ctx.actions.run(..., inputs=[directory], arguments=args)
```

If we make a change to `f`, which only affects the behavior for files, we
cannot detect that without actually expanding the directory:

```
def f(file):
  if file.is_directory():
    return file.path
  return file.path + '_different_suffix'
```

Technically, we could have a digest identifying Starlark code and base the key
on that, but that is a feature which would limit the ability to expand Starlark
in the future and it does not fit the overall design of it. Additionally to
that, we could theoretically change the function in a way which does not affect
the output for the contents of a given directory, which would lead to
false-positive changes to the key. Due to those concerns, the solution to this
problem is to provide the artifact expander so that we can actually run the
Starlark function with the same parameters as if we were to construct the
command line.

This is a pure refactoring change in preparation to provide a fix for the bug.
We are adding an optional `ArtifactExpander` parameter which will only be used
in the future and, until then, is always null.

PiperOrigin-RevId: 320025538
64 files changed
tree: e6b94cec5db868416f5f2ad316a5825f9feff8bf
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .bazelrc
  9. .gitattributes
  10. .gitignore
  11. AUTHORS
  12. BUILD
  13. CHANGELOG.md
  14. CODEOWNERS
  15. combine_distfiles.py
  16. combine_distfiles_to_tar.sh
  17. compile.sh
  18. CONTRIBUTING.md
  19. CONTRIBUTORS
  20. distdir.bzl
  21. ISSUE_TEMPLATE.md
  22. LICENSE
  23. README.md
  24. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status