Bazel Training
Aspect's Bazel Training offers a healthy mix of lecture, discussion, and hands-on Bazel use in our example code - or in your own project. Our example code spans multiple languages, including C++, Java, Python, Go, Swift, and JavaScript, matching the typical Bazel use on scaled multi-language projects and sometimes letting you pick which language you'd like to see for an example.
Our training courses are available for Aspect Pro and Enterprise customers.
If you don't have a login, you can register for Aspect Pro. Email hello@aspect.dev to learn more.
To sign up for a live training, see https://www.aspect.dev/services#training.
Bazel 101 for Product Engineers
This training course is intended for product engineers. You care about developing product features on-schedule. The build system is a necessary evil, which you rely on for quick iteration time, primarily maintained by designated build experts for your project.
Our Bazel 101 training course provides an essential Bazel foundation for product engineers to keep their build and test loops fast, without getting bogged down in every Build Systems detail.
Course Syllabus
- Intro
- What is Bazel
- Essential properties and mental model.
- Rationale for choosing Bazel for a project.
- Installing the
bazel
CLI, optionally alsoaspect
CLI
- Introduction to the Codelab.
- Walk-through of the languages used.
- Demo videos of the various services running.
- Bazel Workspace
- Concept of Workspace
- Command-line flags and
rc
files - Bazel
info
keys
- The phases of Bazel's evaluation model
- Discussion of each phase: configure, fetch, load, analyse, execution.
- Typical commands to trigger each phase in Bazel.
- Configuring Bazel via
BUILD
files- Concepts: Package and Label.
- Writing
BUILD
files for several languages. - Finding existing rules.
- Using
run_binary
to adapt a runnable tool to a build step. - Dealing with tools that don't seem to work with Bazel.
- Rules vs. Macros
- Using simple Macros to compose rules.
- What is a macro, intro to syntax.
- Several example macros.
- Testing
- Common flags to
bazel test
. - Common
tags
to influence test behavior. - Intro to the Test Encyclopedia.
- Test outputs.
- Testing services.
- Flakiness.
- Common flags to
Aspect customers: access the training materials at https://pro.aspect.build/category/101-product-engineers
Bazel 201 for DevInfra Engineers
This training course is intended for "Developer Infrastructure" or "Engineering Productivity" engineers, designated as the creators and maintainers of the build system in your project or across projects.
Unlike product engineers, your job responsibility requires a deep knowledge of how Bazel works, how you can configure it to maximize your developers productivity and avoid common "foot-guns".
Many DevInfra engineers prefer to start out with the 101 course before proceeding to the 201 course, both to pick up on any introductory aspects missed, and to provide more time and context for discussion with Aspect experts. We assume in the 201 course that everyone is familiar with the 101 topics as a pre-requisite.
Course Syllabus
- Codelab/examples revisited, for setting up Bazel from scratch.
- Structuring a project or monorepo with Bazel packages.
- Building - the Dependency graph and Action graph.
- BUILD file generation.
- Using
buildozer
. bazel query
and the Dependency graph.bazel aquery
and how rule implementations lower the Dependency graph to the Action graph.
- Deep dive into how Bazel manages dependencies.
- Concepts of fetching.
- How Bazel interacts with Package Managers.
- Pinning third-party dependencies.
- Configuring the downloader and avoiding "eager fetches".
- Rules and custom rules.
- Why to use Macros instead.
- Intro to the rules-template.
- Common patterns for writing a rule.
- Running Bazel on a CI/CD platform.
- Shared Green.
- Versioning.
- Stamping.
- Selective Delivery.
- How to approach a Bazel Migration.
- Incubate "Net Promoters".
- Keep workflows intact.
- Change one thing at a time.
- Ratchet mechanism and Gradient Ascent.
- Close the loop
- Leave the code alone, leave few fingerprints.
- Technique for patching rather than forking.
- Monitoring and Operating a Bazel repository.
- Philosophy of a DevInfra team.
- Performant builds
- Spawn strategies
- Keeping cache hit rates high.
- Tuning actions with execution requirements.
- Checking in generated code.
- Watch mode.
- Profiling builds.
- Preventing "weeds".
- Wrap-up and open discussion
Aspect customers: access the training materials at https://pro.aspect.build/category/201-devinfra-engineers