https://github.com/gregl83/bazel-paq
🟩△ Bazel aspect for computing output hashes to enable build delta tracking.
https://github.com/gregl83/bazel-paq
bazel bazel-hash bazel-rules caching continuous-deployment monorepo paq release-automation
Last synced: about 1 month ago
JSON representation
🟩△ Bazel aspect for computing output hashes to enable build delta tracking.
- Host: GitHub
- URL: https://github.com/gregl83/bazel-paq
- Owner: gregl83
- License: mit
- Created: 2023-06-01T03:00:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-30T20:18:24.000Z (7 months ago)
- Last Synced: 2026-04-04T00:18:43.192Z (4 months ago)
- Topics: bazel, bazel-hash, bazel-rules, caching, continuous-deployment, monorepo, paq, release-automation
- Language: Starlark
- Homepage:
- Size: 451 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/gregl83/bazel-paq/blob/master/LICENSE)
# bazel-paq
[Bazel aspect](https://bazel.build/extending/aspects) for computing target output hashes.
Easily track build deltas by comparing output hashes with deployed artifacts or previous builds.
## Usage
### Workspace Configuration
#### 1. Add Module Dependency
Add the following to the dependency section the workspace `MODULE.bazel`:
```text
bazel_dep(name = "bazel_paq", version = "1.4.1")
```
#### 2. Add Load Definition
Add the following to the workspace `defs.bzl`:
```text
load("@bazel_paq//:defs.bzl", "paq_aspect")
```
### Executing Builds
#### Short Command
Add the following to the workspace `.bazelrc` configuration file:
```text
build:paq --aspects=@bazel_paq//:defs.bzl%paq_aspect
build:paq --output_groups=+paq_files
```
Execute build:
```bash
bazel build --config=paq //...
```
#### Long Command
```bash
bazel build //... --aspects=@bazel_paq//:defs.bzl%paq_aspect --output_groups=+paq_files
```
### Executing Tests
```bash
bazel test tests:all --test_output=all
```
## Aspect Output
Executing `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.
## Hashing Algorithm
The [paq](https://github.com/gregl83/paq) executable used in `bazel-paq` is powered by the `blake3` hashing algorithm.
#### Output Hash Validation
1. **Install:** Make the [paq](https://github.com/gregl83/paq) executable available on validation system.
2. **Compute:** Hash a build target output using `paq`.
3. **Compare:** Open respective `.paq` build output and validate it equals computed hash from Step 2.
## Example Workspace
The [example](example) directory contains a complete Bazel module workspace demonstrating `bazel-paq` usage.
### Output Structure
Target output hash files use `.paq` extension.
```text
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
```
## License
[MIT](LICENSE)