Skip to content

Instantly share code, notes, and snippets.

@wael34218
Last active December 29, 2018 09:37
Show Gist options
  • Save wael34218/b237aec2333ab7b46b86c82d11ad9ea9 to your computer and use it in GitHub Desktop.
Save wael34218/b237aec2333ab7b46b86c82d11ad9ea9 to your computer and use it in GitHub Desktop.

Travis CI

Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub.

Installation

Create .travis.yml and put it in the root directory of the Github project.

Configurations

  • sudo: true
  • setuid
  • setgid
  • os: linux, osx
  • dist: precise, trusty or xenial
  • env: To set environment variables
  • services: To set up database such as mysql. mongo and postgres
  • language: Programming language to test
  • python: 3.5 ... etc.

The complete job lifecycle, including three optional deployment phases and after checking out the git repository and changing to the repository directory, is:

  • OPTIONAL Install apt addons

  • OPTIONAL Install cache components

  • before_install

  • install

  • before_script

  • script

  • OPTIONAL before_cache (for cleaning up cache)

  • after_success or after_failure

  • OPTIONAL before_deploy

  • OPTIONAL deploy

  • OPTIONAL after_deploy

  • after_script

  • notifications

Example:

dist: trusty
language: python
python:
    - "3.5"
    
addons:
  snaps:
    - name: aws-cli
      classic: true
      channel: latest/edge
    
services:
    - riak
    - rabbitmq
    - memcached
    - mysql
  
before_install:
    - sudo apt-get -qq update
    - sudo apt-get -y install build-essential
    - mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
install:
    - pip install -r requirements.txt
    - pip install nose
    
script:
    - nosetests unit-tests/*.py --nologcapture --with-coverage
    
deploy:
  provider: elasticbeanstalk
  access_key_id: 
    secure: "Encrypted <access-key-id>="
  secret_access_key:
    secure: "Encypted <secret-access-key>="
  region: "us-east-1"  
  app: "example-app-name"
  env: "example-app-environment"
  bucket_name: "the-target-S3-bucket"
    
notifications:
  email:
    recipients:
      - [email protected]
      - [email protected]
    on_success: never # default: change
    on_failure: always # default: always
  slack:
    on_success: always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment