Skip to content

gregl83/bazel-paq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release MIT licensed

bazel-paq

Bazel aspect 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:

bazel_dep(name = "bazel_paq", version = "1.4.1")

2. Add Load Definition

Add the following to the workspace defs.bzl:

load("@bazel_paq//:defs.bzl", "paq_aspect")

Executing Builds

Short Command

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 //...

Long Command

bazel build //... --aspects=@bazel_paq//:defs.bzl%paq_aspect --output_groups=+paq_files

Executing Tests

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 executable used in bazel-paq is powered by the blake3 hashing algorithm.

Output Hash Validation

  1. Install: Make the 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 directory contains a complete Bazel module workspace demonstrating bazel-paq usage.

Output Structure

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

License

MIT

About

🟩△ Bazel Aspect for Computing Output Hashes to Enable Delta Tracking

Topics

Resources

License

Stars

Watchers

Forks

Contributors