< Blog
Stop Wasting Time When Doing Reviews and Branch Switches
Published at 5/31/2023, 12:52 PM

How to Speed Up Your Development Process

Switching between branches during development can often be time-consuming, especially when you not only need to review your colleague's code but also test it. Building the project, running it, and performing tests can take a significant amount of time, particularly if you have to repeat these steps multiple times a day. In this blog post, I will introduce you to bob, a valuable tool that can save you a substantial amount of time during branch switches and reviews. Bob is a command-line tool designed to simplify project building and manage build dependencies.

The Challenge

Let's consider a scenario where you are collaborating with a colleague on a project. While you are working on a feature branch, your colleague is simultaneously working on a different feature branch. When you want to review your colleague's work, you need to switch to their branch, build the project, run it, and conduct tests. The build process can be time-consuming, and the tests may take even longer. To make matters worse, after completing the review, you have to switch back to your own branch and rebuild it, which can be a significant time drain, especially if you need to repeat this process multiple times a day.

The Solution: Artifact caching with bob

Fortunately, bob offers a straightforward and user-friendly solution. Bob is not just a build tool—it also comes with the powerful feature of caching build artifacts. This means that once you build your project, switching to a different branch will leverage the cached build artifacts, minimizing the build time to only what has changed in the branch you're switching to. Consequently, bob significantly reduces the time required for branch switches. Moreover, when you switch back to your own branch, bob intelligently utilizes the cached build artifacts, eliminating the need to rebuild your branch from scratch.

How to use bob

To get started with bob, you can easily install it by following the instructions on the bob installation page. Once installed, you can create your first build script by writing a bob.yaml file. Let's examine an example bob.yaml file:

nixpkgs: https://github.com/NixOS/nixpkgs/archive/nixos-22.11.tar.gz

dependencies:
  - go_1_20

build:
  example:
    cmd: go build -o example main.go
    target: example
    dependsOn:
      - echo
  echo:
    cmd: echo "Hello world!"

In this example, the first line nixpkgs:... specifies the location of the nixpkgs repository, which is necessary for building the dependencies. One of the advantages of using bob is that it creates a sandboxed build environment using nix, eliminating the need to install dependencies directly on your system.

The subsequent line dependencies:... lists the dependencies to be built. In this case, we are building with Go version 1.20.

The final part build:... describes how to build your project. In this example, we are building a Go project with two targets: example and echo. The echo target executes a simple echo command, while the example target runs a Go build command. The dependsOn section indicates that the example target relies on the successful completion of the echo target, ensuring that bob builds the targets in the correct order.

Once you have a bob.yaml file, you can build your project by running bob build example. Bob will first build the echo target and then proceed to build the example target. When you execute bob build example again, bob will utilize the cached build artifacts for the echo target, resulting in a faster build process, as the echo target remains unchanged. This is how bob optimizes your development process.

Enhance Speed with Remote Caching

To further enhance your development process, bob offers the capability to cache build artifacts in a remote cache. This allows you to share your build artifacts with your colleagues, which is particularly valuable when working on large projects with numerous dependencies. Building a large project can be time-consuming, but by sharing your build artifacts, your colleagues can simply download them from the remote cache, eliminating the need for them to build the project themselves. This significantly saves time and speeds up collaboration.

In the above example, Alice pushes her build artifacts to the remote cache when opening a pull request. After Carl switches to the feature branch, he no longer needs to build the artifacts from scratch; instead, he can simply pull the build artifacts from the remote cache and proceed with his work.
You can find more information about remote caching in the bob documentation.

Conclusion

Bob is an invaluable tool for speeding up your development process. With its simplicity and ease of use, bob can save you a significant amount of time. Particularly in large projects with numerous dependencies, bob's caching mechanism enables the sharing of build artifacts, eliminating the need for individual builds and further reducing development time.
Don't waste any more time during reviews and branch switches – try bob and experience the efficiency it brings to your development workflow.

Do you need Kubernetes or Go Experts?

We are a Software Agency from Stuttgart, Germany and can support you on your journey to deliver outstanding user experiences and resilient infrastructure. Reach out to us.