Travis CI

From XennisWiki
Jump to: navigation, search

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

Setup

GitHub

Setup Travis

  • First create the GitHub repository
  • Next go to https://travis-ci.org, login with your GitHub account and add the repository

Setup to trigger Travis on each commit

  • Settings > Integrations & services
  • Add service and add Travis CI

Example .travis.yml files

Ansible

language: python
python:
  - "2.7"
install:
  - pip --quiet install ansible
before_script:
  - ansible-playbook --version
script:
  - ansible-playbook --syntax-check example-playbook.yml

Django application with PostGis database

language: python

python:
  - 2.7
  - 3.6
  
services: postgresql

env:
  global:
    - DJANGO_SETTINGS_MODULE="apps.server.settings.development"
    - PYTHONPATH="${HOME}/builds/<github-name>/<github-repo>"
    - DEFAULT_DATABASE_NAME="travisdb"
    - DEFAULT_DATABASE_PASSWORD=""
  
install:
  - pip install -r requirements.txt
  
before_script:
  - psql -U postgres -c "CREATE DATABASE ${DEFAULT_DATABASE_NAME}"
  - psql -U postgres -c "CREATE EXTENSION postgis"
  
script:
  - python manage.py migrate

Go

language: go
go:
  - "1.10"

Gradle

language: groovy

Hugo

dist: xenial
language: minimal
addons:
  snaps:
  - hugo
before_script:
  - hugo version
script: hugo

npm

language: node_js
node_js:
  - '8'
install:
  - npm install
script:
  - ./node_modules/grunt/bin/grunt build

PHP with Composer and PHPUnit

language: php
php:
  - '7.1'

install:
  - composer install

script: ./vendor/bin/phpunit --bootstrap vendor/autoload.php src/test/php/

PHP and npm

matrix:
    include:
    - language: php
      php:
        - '7.1'
      install:
        - composer install
      script: ./vendor/bin/phpunit --bootstrap vendor/autoload.php src/test/php/
    - language: node_js
      node_js:
        - '8'
      install:
        - npm install
      script:
        - ./node_modules/less/bin/lessc src/less/back-end/back-end.less dist/back-end.css

Python

language: python
python:
  - "3.6"
install:
  - pip install -r requirements.txt
script:
  - pytest
  - pylint *.py

Errors and problems

GitHub organization is not listed on Travis CI

Go to your applications on GitHub and select Travis CI. Next grand the missing organization the access (in the "Organization access" section).

See also

External links