Bazel aspect for computing target output hashes.
Easily track build deltas by comparing output hashes with deployed artifacts or previous builds.
Add the following to the dependency section the workspace MODULE.bazel:
bazel_dep(name = "bazel_paq", version = "1.4.1")
Add the following to the workspace defs.bzl:
load("@bazel_paq//:defs.bzl", "paq_aspect")
Add the following to the workspace .bazelrc configuration file:
build:paq --aspects=@bazel_paq//:defs.bzl%paq_aspect
build:paq --output_groups=+paq_files
Execute build:
bazel build --config=paq //...bazel build //... --aspects=@bazel_paq//:defs.bzl%paq_aspect --output_groups=+paq_filesbazel test tests:all --test_output=allExecuting bazel build with the bazel-paq aspect configured will compute unique hashes for every build target output.
Output hash filenames are target_output_filename.ext.paq for files and .paq for directories.
Files are valid JSON and contain a single blake3 hash in double quotes.
The paq executable used in bazel-paq is powered by the blake3 hashing algorithm.
- Install: Make the paq executable available on validation system.
- Compute: Hash a build target output using
paq. - Compare: Open respective
.paqbuild output and validate it equals computed hash from Step 2.
The example directory contains a complete Bazel module workspace demonstrating bazel-paq usage.
Target output hash files use .paq extension.
bazel-bin
|-- configuration
| |-- config.out.json
| `-- config.out.json.paq
|-- infrastructure
| |-- templates.manifest
| |-- templates.tar
| `-- templates.tar.paq
|-- python-service
| |-- app
| |-- app.paq
| |-- app.repo_mapping
| `-- app.runfiles_manifest
`-- rust-command
|-- command
|-- command.paq
|-- command.repo_mapping
`-- command.runfiles_manifest