Note: Currently supporting the latest Bazel version as at mid June 2021, 4.1.0
Example Bazel-ified monorepo, supporting Golang, Java, Python, Scala, and Typescript.
Cloud Infrastructure-as-Code is done using Terraform.
I use this project to explore how Bazel works with different languages and developer tools, and keep a record of best-practices I've learnt. So it is a work in progress. Others can use it to check out the Bazel way of doing things and use parts as a reference implementation.
Rather than the typical To-Do list, this project's code uses the contrived scenario of a book shop and reading catalogue website called Antilibrary. ππππ
4.x.x
)yarn
or npm
for the NodeJS and Typescript codeBazel aims to be 'build anything, anywhere' system, so building and testing should be as simple as bazel test //...
. If it's not, please create an issue.
The following few articles together provide a good overview of the motivations behind maintaining a Monorepo. For heaps more information, korfuri/awesome-monorepo is a good place to go.
There's Golang code in /cli
. It implements a simple CLI for the common 'Blind Date With a π' product.
Third-party dependencies are managed in 3rdparty/go_workspace.bzl
.
There's a Spring Boot (with PostGres) application in /store-api
and some other Java code in /store/layoutsolver
.
Its third-party dependencies are managed by rules_jvm_external
in the WORKSPACE
(See the # JAVA SUPPORT
section).
There's Scala code contained in scala-book-sorting
.
Its third-party dependencies are managed
by johnynek/bazel-deps
. The usage of that tool is wrapped up in a script
as tools/update_jvm_dependencies.sh
.
To use it, you update tools/dependencies/jvm_dependencies.yaml
and then run the script.
There's Python code in the /book_sorting
and /scraping
.
bazelbuild/rules_python
is used for the core py_*
rules.
In order to add new third-party packages for Python, add them to 3rdparty/requirements.in
and run bazel run //3rdparty:requirements.update
.
thundergolfer/bazel-mypy-integration is used to check any type annotations at bazel build
time.
The infrastructure/
top-level folder contains Terraform defining various AWS resources and their configuration.
bazel build //...
bazel test //...
This repository's CI is managed by Buildkite, the CI platform used by Pinterest and Canva to manage Bazel monorepos, as well as being used by the Bazel open-source project itself.
Deployable artifacts are pushed to S3 under commit-hash-versioned keys.
Currently only the store-api
deploy/fat JAR is deployable.
graknlabs/bazel-distribution
is used to publish Python packages to PyPi.
This project is using Buildbuddy.IO. Every build run locally or in CI get its own https://app.buildbuddy.io/invocation/xyz123...
URL which analyses and records the build's information.
thundergolfer/bazel-linting-system is used. ./tools/linting/lint.sh
will lint all source-code in the repo and ./tools/linting/lint_bzl_files.sh
will lint all Bazel files.