Skip to content

Instantly share code, notes, and snippets.

@marclove
Last active December 23, 2015 22:39
Show Gist options
  • Save marclove/6704878 to your computer and use it in GitHub Desktop.
Save marclove/6704878 to your computer and use it in GitHub Desktop.

#Setting up your project on CircleCI

CircleCI Docs

Configuring CircleCI with Circle.yml

CircleCI's Test Environment

Initial Setup

  • Step 1: Follow your GitHub project
  • Step 2: There is no step 2!

Gets you:

  • Automatic CI builds of all branches
  • Automatically infers:
    • Language/framework (Ruby/Rails, Python, Node.js, PHP)
      • Testing framework (RSpec, Cucumber, and Test::Unit)
      • RVM and NPM for dependencies
  • A large list of available databases & services (see docs)

Heroku Setup

  • Step 1: Follow your GitHub project
  • Step 2: Get your Heroku API key and add to CircleCI
  • Step 3: Setup an SSH key, add it to Heroku and associate it with your CircleCI account
  • Step 4: Create a circle.yml file to the root of your project
deployment:
  acceptance:
    branch: master
    heroku:
      appname: myapp-acceptance
  staging:
    branch: staging
    heroku:
      appname: myapp-staging
  • Step 5: Push

Customized Setup

Circle.yml

6 sections:

  • machine: adjusting the VM to your preferences and requirements
  • checkout: checking out and cloning your git repo
  • dependencies: setting up your project's language-specific dependencies
  • database: preparing the databases for your tests
  • test: running your tests
  • deployment: deploying your code to your web servers

machine

  • pre: List of commands to run before CircleCI's inferred commands
  • post: List of commands to run after CircleCI's inferred commands
  • environment: key/values of env variables globally available for all CI commands
  • timezone: timezone you want your CI build to run in
  • hosts: hostfile entries
  • ruby: specify ruby version (if not included in your Gemfile)
  • services: turn on services that are turned off by default

checkout

  • Inferred command usually sufficient
  • Customize with: pre/post or override

dependencies

  • Inferred command usually sufficient
  • Customize with: bundler, pre/post or override

database

  • Inferred command usually sufficient
  • Customize with: pre/post or override

test

  • Customize with: pre/post or override

deployment

  • Each key is arbitrary and represents a particular type of deploy
  • The key name only matters to you
  • The mapping that follows specifies how that deploy is configured
    • branch specifies the branch or branches that deploy applies to
    • heroku specifies the heroku app to deploy to
    • commands specifies a list of commands required to execute the deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment