Shorten Onboarding and Increase Productivity with Bazel Queries

Dylan Martin
2 min readAug 26, 2020

--

Why waste time whiteboarding? Instead, automate graphing directly from your codebase using Basel queries. You’ll speed up onboarding and reduce the time sink of drawing out complex graphs. Make it easy for both new hires and experienced engineers to get the same information about their projects’ dependencies so your team can work more efficiently, iterate more quickly, and deploy more often.

Here is the Basel generated dependency graph for the spinnaker spin tool. How much time would be wasted manually drawing, checking, and proposing changes to this graph? Instead it was generated directly from source code quickly and accurately, providing a consistent and up to date view no matter who pulls it. As a bonus, it also allows teams to track how dependencies change over time.

Dependency graph for the spinnaker spin tool.

Bazel supports three types of queries, each providing specialized insights into your project. When run separately they are each valuable for different reasons. When reviewed together they provide a complimentary and comprehensive project analysis.

Query:

  • Provides all of the dependency information about a target and allows you to visualize it
  • Runs during Bazel’s loading phase, making it fast but lower on specifics
  • Traverse dependencies forward, backward and between specific targets
  • Specify types of dependencies to include, tailoring the resulting graph to your needs

Cquery:

  • Evaluates build options and shows dependencies specific to those options
  • Runs during Bazel’s analysis phase taking longer to run than query
  • Very useful for large projects where build options can have a large impact on dependencies

Aquery:

  • Shows the relationship between actions and it’s associated inputs/outputs and mnemonics in your project
  • Runs on the post-analysis configured target graph
  • Makes it easy to track inputs and outputs through your project

Basel queries quickly and accurately provide your team consistent on-demand understanding of both current state, and implications of proposed future programming changes, while also adding to your debugging toolkit.

--

--

Dylan Martin
Dylan Martin

No responses yet