git remote tool from NVBOTS

When you’re building software for a production environment there are several other environments the code-base must traverse before being fully released. This ‘one repository – multiple environments’ is a common pattern that resin supports really well. However- things can get complicated when you have several local branches and multiple remotes. It’s easy to get tangled…

When you’re building software for a production environment there are several other environments the code-base must traverse before being fully released.

This “one repository – multiple environments” is a common pattern that resin supports really well. However, things can get complicated when you have several local branches and multiple remotes. It’s easy to get tangled and push the wrong code to the wrong fleet of devices.

Luckily, Forrest Pieper from NVBOTS has built a little tool to vastly simplify this. I’ll let him explain:

I built the multiple remotes tool to help update our device application code on a variety of deployment environments and target architectures. At NVBOTS, we maintain development, staging, and production environments, and we support both the Raspberry Pi 1 and Raspberry Pi 2 architectures. We have a unique resin.io application for each deployment environment/architecture combination (a total of 6 apps). Pushing updates to the correct resin.io applications quickly became error-prone and inconvenient.

The deploy script allows us to manage and push various ‘targets’ that associate a branch of our git repository with one or more git remotes- in our case, resin application remotes. We only need a single command to launch a new feature on our development devices, push a release candidate to our staging devices, or roll out a new release to all of our customers. This tool makes it easier for us to update multiple resin.io applications simultaneously, which helps enforce our QA process by ensuring that all devices for a given deployment environment are updated together.

Forrest has put together a demo application for the tool for clearer explanation as well as the command reference you see below.

This tool allows users to associate a local branch with a list of git remotes (and branches on those remotes) and quickly push the local branch to all associated remotes. A target includes a single local branch plus one or more remote:remote_branch values. If the :remote_branch portion is omitted, the name of the local branch will be used. Targets are identified by the name of the local branch.

List targets

python deploy.py list

Add a new target

python deploy.py add <local_branch> <remote>:<remote-branch>

Example:

python deploy.py add testing resin-test:master

Delete target

python deploy.py delete <target>

Example:

python deploy.py delete testing

Push Target

python deploy.py push <target>

Example:

python deploy.py push testing

The push command pushes the target’s local branch to each of the associated remote:remote_branch values.
The list of targets is stored in a configuration file located at {target_conf}

During a push command, output from the git push call is directed to a file located at {base_dir}/<target>/<remote>.out
If a target includes multiple remotes, the push calls are run simultaneously in separate processes

Even simpler deployments, thanks Forrest! If you have any questions give us shout on gitter.


Posted

in

Tags: