Skip to content

Instantly share code, notes, and snippets.

@juliandunn
Created February 24, 2015 15:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliandunn/4a607c8d016380721a2e to your computer and use it in GitHub Desktop.
Save juliandunn/4a607c8d016380721a2e to your computer and use it in GitHub Desktop.
Doing integration testing on Travis CI with Test Kitchen and DigitalOcean

Setting up Travis-CI Test Harness

These notes were cribbed from the work that Sean O'Meara did for the Yum cookbook.

  • Ensure Travis integration is on in GitHub.
  • Set up Gemfile, Rakefile like the ones here
  • Set up .kitchen.cloud.yml
  • Set up a .travis.yml without all the encrypted secrets but with the tasks, matrix, etc. This .travis.yml needs to have env vars like DIGITAL_OCEAN_SSH_KEY_PATH set up unencrypted in the env->global section.
  • Install the Travis gem on your workstation. Encrypt the secrets you will use. This is the trickiest part: ** Environment variables shorter than 90 characters are easy; just do travis encrypt FOO=bar --add. For DigitalOcean you need at least:
travis encrypt DIGITAL_OCEAN_CLIENT_ID=whatevs
travis encrypt DIGITAL_OCEAN_ACCESS_TOKEN=whatevs
travis encrypt DIGITAL_OCEAN_SSH_KEY_IDS=123456  # read kitchen-digitalocean's README to find out how to get this

** Environment variables longer than 90 characters require some incantation, e.g. for your SSH private key, do something like:

base64 ~/.ssh/travisci_cook_digitalocean.pem | \
    awk '{
      j=0;
      for( i=1; i<length; i=i+90 ) {
        system("travis encrypt DO_KEY_CHUNK_" j "=" substr($0, i, 90) " --add");
j++;
      }
    }'
  • Push changes to a branch and hopefully Travis will pick it up and build your project and do integration testing with Kitchen!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment