Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub.
Create .travis.yml
and put it in the root directory of the Github project.
sudo: true
setuid
setgid
os
:linux
,osx
dist
:precise
,trusty
orxenial
env
: To set environment variablesservices
: To set up database such as mysql. mongo and postgreslanguage
: Programming language to testpython
: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
orafter_failure
-
OPTIONAL
before_deploy
-
OPTIONAL
deploy
-
OPTIONAL
after_deploy
-
after_script
-
notifications
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