Continuous Integration

Part 2, Chapter 3


Next, we'll add continuous integration (CI), via Travis CI, to our projects...


Do you usually use a different CI service or run Jenkins? It's encouraged to check your understanding by continuing to use the CI service that you're accustomed to. Convert the Travis configuration examples as necessary.

Follow steps 1 and 2 of the Getting Started guide to enable Travis in the project.

To trigger a build, add a .travis.yml file to the project root:

sudo: required

services:
  - docker

env:
  DOCKER_COMPOSE_VERSION: 1.23.2

before_install:
  - sudo rm /usr/local/bin/docker-compose
  - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
  - chmod +x docker-compose
  - sudo mv docker-compose /usr/local/bin

before_script:
  - docker-compose -f docker-compose-dev.yml up --build -d

script:
  - docker-compose -f docker-compose-dev.yml exec users python manage.py test
  - docker-compose -f docker-compose-dev.yml exec users flake8 project

after_script:
  - docker-compose -f docker-compose-dev.yml down

Commit your changes, and then push to GitHub. This should trigger a new build, which should pass. Once done, add a README.md file to the project root, adding the Travis status badge:

# Microservices with Docker, Flask, and React

[![Build Status](https://travis-ci.org/YOUR_GITHUB_USERNAME/testdriven-app.svg?branch=master)](https://travis-ci.org/YOUR_GITHUB_USERNAME/testdriven-app)

Be sure to replace YOUR_GITHUB_USERNAME with your actual GitHub username.

In terms of workflow, for now, while the project structure is still somewhat simple, we'll:

  1. Code a new feature locally
  2. Commit and push code
  3. Ensure tests pass on Travis



Mark as Completed