Practical Bazel
In 2020, I led the redesign and re-implementation of the object storage system behind RelativityOne.
As part of this project we reengineered the continuous delivery pipeline of the service to embrace the philosophy of a service-wide monorepo with a Bazel-based build system. We chose Bazel because we wanted a build system that could support many different languages (the service has code written in C, C#, Python, Go, Terraform, Packer, and other languages…) while remaining fast and correct.
During this project we wrote seven new Bazel rulesets and a huge amount of Bazel-based build code.
This post series is about the many tips and tricks that we learned along the way as we wrote hundreds of thousands of lines of code in multiple languages to support this storage service.
1 - General Tips and Tricks
- Practical Bazel: Start with Genrules
- Practical Bazel: Excluding Part of Tree
- Practical Bazel: Wrapping Run Targets to Provide Additional Context
- Practical Bazel: A Simpler Way to Wrap Run Targets
- Practical Bazel: Use Awesome Bazel to find rules
- Practical Bazel: Using Bazel's Bash Runfiles Library
- Practical Bazel: Comparing Collections for Equivalence in sh_test()
- Practical Bazel: local_archive() Workspace Rule
- Practical Bazel: Custom Bazel Make Variables
- Practical Bazel: Using Clang 12 C++ Toolchain on Ubuntu 20.04
- Practical Bazel: Use multirun for parallel execution
2 - Best Practices
- Practical Bazel: Use a Specific Version of Bazel
- Practical Bazel: Enable Bash Strict Mode
- Practical Bazel: Use ctx.actions.args() to Form Arguments Lists
- Practical Bazel: A Successful Build is a Quiet Build
- Practical Bazel: Depending on a System-Provided C/C++ Library
- Practical Bazel: Use a Single .bazelrc With Multiple Configurations
- Practical Bazel: Using Bazel's Bash Unittest Framework
3 - Developer Experience
4 - Writing Custom Rules and Rulesets
- Practical Bazel: path or short_path?
- Practical Bazel: Prefix All Generated Files
- Practical Bazel: Changing Behavior on Windows
- Practical Bazel: Writing a Rule That Supports Both Build and Run
- Practical Bazel: Isolating Ruleset's Public Interface
- Practical Bazel: Implementing compilation_mode in Rules
- Practical Bazel: Start with Official Rules Template
- Practical Bazel: Retrieving Secrets from Netrc in Custom Rules
- Practical Bazel: Supporting Trinary Stamp Attributes
- Practical Bazel: Testing Rulesets with Docker Compose-Based Buildfarm