With the June update of Spot, we announced a new feature that allows you to create Spots directly from pull requests on GitHub.

In this post, we give a motivation, provide a tutorial and go into detail on how to make best use of this feature.

Motivation

Many times, reviewing code in a pull request is not enough; to truly understand the impact of a change, you'd prefer to run a build generated from that PR.

So what is stopping you? How about some of these... having to switch branches on your local machine and stash your current uncommitted changes; being forced to install dependencies you'd rather not have; having to load up that project you forgot how to build.

With Spot: Create from PR, these frustrations are no more.

Video


Tutorial

Repository Prerequisites

There are currently two simple prerequisites to use this feature with a GitHub repository:

  • The repository must be public
  • The repository must contain a Dockerfile or Dockerfile.spot

Note that you do not have to be an owner of the repository and there are no webhooks or other special requirements.

Create a Spot from the PR

  • Open the VS Code Command Palette
  • Type Spot: Create from PR
  • Enter a name for this Spot
  • Enter the PR URL e.g. https://github.com/derekbekoe/hello-world-node/pull/3
  • Accept the confirmation to start the build and creation of the Spot

Here is an illustration of this in action:
Spot - Create from PR

If this is the first time you're using this feature, a confirmation message like the following will be shown to allow Spot to provision a container registry.
ACR Create Confirmation

Terminate the Spot

Once done with the Spot, terminate it with Spot: Terminate.

Good to know

Dockerfile.spot

Spot: Create from PR builds a Docker image in the cloud and deploys a Spot that you can then interact with. During the build, we look for Dockerfile.spot at the root of the GitHub repository. If that does not exist, we fall back to Dockerfile.

This behavior is useful for example for when the Spots should use a debug configuration instead of release configuration or when they should be based on a different base image.

Team Collaboration & Azure Subscriptions

When you point Spot to a pull request, we first check to see if that specific commit has already been built into an image in the container registry. If it is found, we use that; if not, we build the image.

To help make best use of the above behavior, set your subscription in VS Code to a subscription that members of your team share. This will allow you to make use of other pre-built images that your peers may have created during their own use of Spot with pull requests.

Use Azure: Select Subscriptions to set the subscription that should be used.

Explorer Directory

By default, the file explorer shown when you're connected to a Spot points to the directory /root. If you want to change this or you find that no files are showing, you can change the spot.fileWatcherWatchPath setting to point to the appropriate directory and then recreate the Spot.

For example, the following sets the path to /src in the running container.

"spot.fileWatcherWatchPath": "/src"

See User and Workspace Settings on how to set this configuration value in VS Code.

Clean Up

By default, Spot uses a resource group named vscode-spot.
If you need to clean up any Azure resources, delete them from this resource group.

Start using Spot today from the VS Code Marketplace