We built a sample project on Github to show how we integrate with various CI tools, including Circle CI.
Our project is configured to provide a continuous delivery flow by default. Here's how it works!
Every time code is pushed to the 'develop' branch, Circle CI will:
- Run the automated tests
- Deploy the 'develop' branch to a staging server
- Run the rainforest tests using the rainforest-cli against the staging server
- Once the rainforest tests are successful, push the 'develop' branch to the 'master' branch
- Step 4 triggers another CI build, which pushes the code to production
If any of the above steps fail, the whole build fails, preventing the deployment of broken code to your users.
Getting Started With Circle CI
We'll cover some important items next, but for the full picture we encourage you to consult the excellent Circle CI getting started documentation.
The circle.yml file
The main way to configure the Circle CI tool is through a file that you store in your git repository. You can see the sample configuration for our project here.
You'll notice that instead of entering the Rainforest API key directly in the circle.yml file, we're using an environment variable. We do this for security reasons. We don't want to expose that variable to any reader of that file. This especially true if the repository is publicly accessible.
To configure environment variables, you can do so in the project's settings. You can find your Rainforest API token by navigating to your Integrations settings.*
You can then create a RAINFOREST_TOKEN variable in Circle CI and you're done.
More details about environment variables and Circle CI here.
Testing your setup
You can test your setup by committing a change to your develop branch and pushing it your git repository. Circle CI should pick up on the change and deploy your code.
With a new continuous delivery flow and QA process to match, you can finally move fast and not break things while you're at it!
*Note: If you don't see your API token as it's displayed above, we recommend that you click the "Rotate API Token" button to get a new token.