As of the writing of this post, I am working on creating a Chef cookbook that will manage Ghost, the blogging software I use for my personal website. One of the features of this cookbook is the ability to install a theme from a git repository.
I was working on tweaking the theme for my site in a Test Kitchen environment when I found myself doing something horrific. I pushed over 20 commits to a public Github repository in the span of 10 minutes because I playing with CSS values and I needed my local Test Kitchen instance to download them using the `git` resource.
This is obviously not efficient, desired or a best practice. In this post I am going to show how you can have Test Kitchen pull code from a local git repository instead of a public repository.
Step One: Make Test Kitchen aware of my local repository
The first string value is the fully-qualified path to the git repository on your local machine. The second value is the fully-qualified path of the folder you wish to sync your git repository to on the Test Kitchen.
Step Two: Add support to cookbook
If you haven't already, make sure that your git resource uses an attribute for its repository value.
Make sure to set a default value for node['ghost']['theme']['git_repo'] in your attributes/default.rb`file.
Step Three: Overwrite node attribute with local URI
Back in your .kitchen.yml file, override the node['ghost']['theme']['git_repo'] attribute so that it points to the path on the Test Kitchen instance where your git repo has been synced.
Please note that you prefix the path with file:// and remove the .git suffix.
And thats it! Now Test Kitchen will reference your local git repository instead of a remote one like Github. Useful for testing minor tweaks, on a plane or if Github is down.