Initial CircleCI experiments

Travis CI has long been my hosted continuous integration service of choice for my open source repos but there have been some recent changes and departures that inspired me to look around and see what else the modern world has to offer. I run a local Jenkins for my own personal use but it’s not hardened to a degree where I’d trust it to run random pull requests from the wild internet so a hosted, free, solution would be an ideal place to start from. CircleCI, having recently employed a few ex-coworkers, friends and internet acquaintances looked like a very promising candidate.

I picked one of my older repositories, that I intended to archive, as my guinea pig and logged into CircleCI. After clicking on “Add projects” and selecting my expendable repository I created a new branch and raised a pull request to add CircleCI builds.

The code itself is contained in .circleci/config.yml and was pretty self explanatory.

version: 2.1
jobs:
  build:
    docker: 
      - image: circleci/ruby:2.5.0
    steps:
      - checkout
      - run:
          name: "Install the dependencies"
          command: bundle install --jobs=4 --retry=3
      - run: 
          name: "Run the specs"
          command: bundle exec rake spec

I’m not reproducing all the features I use in TravisCI, such as a multiple ruby and gem version combination build matrix, but as a starting point CircleCI does let you get up and iterating quickly. You can see an example of what the job outputs look like on the puppet-liquidtemplates job dashboard.

WebUI showing multiple PR runs

The initial failing builds are a good reminder not to add a new project to CircleCI before adding the actual CircleCI configuration to the repository, otherwise it’ll fail due to not knowing what to actually build.

WebUI showing meta information about the job, such as run time and allocated resources

After a few git push && wait-for-build cycles I dug a little deeper into the provided tooling and installed the CircleCI command line tool in a virtual machine that has docker installed. This allows you to validate and process (expand to see the implicit values) your configuration to help debug issues before they leave your local machine.

# Installing the command line tool and configuring auth
$ sudo curl -fLSs https://circle.ci/cli | bash

circleci setup
CircleCI API Token: --------------------------
API token has been set.
CircleCI Host: https://circleci.com
CircleCI host has been set.
Setup complete.

# Check your configuration is valid and well formed.
$ circleci config validate
Config file at .circleci/config.yml is valid.

# Show your config with all the values expanded
circleci config process .circleci/config.yml

If you have docker installed and configured you can even run the build locally using the same configuration:

$ circleci local execute
====>> Spin up Environment
...snip...
Using build environment variables
  CIRCLECI=true
  CIRCLE_BRANCH=master
  CIRCLE_BUILD_NUM=
  CIRCLE_JOB=build
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_REPOSITORY_URL=git@github.com:deanwilson/puppet-liquidtemplates.git
...snip...
Success!

I had some issues running the command line tool against config specifying version: 2.1 but I don’t think I’m using any features that require that exact version so changing it locally to version: 2 allows me to test locally.

I’m not in a massive rush to move my existing projects off Travis CI, which has continued to provide me with all the features I’ve become accustomed to, but it’s always a good idea to see where the industry has moved to and know what your options are. CircleCI is a solid contender for my newer projects and if I ever do need to move it’d looks like a good home.