masschallenge/django-accelerator

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
sudo: required
dist: xenial
language: python
python:
  - "3.6"
cache: pip

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

services:
- mysql

install:
- make install
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- export DEFAULT_BRANCH=development
- echo $TRAVIS_BRANCH
- echo $TRAVIS_PULL_REQUEST_BRANCH
- echo $TRAVIS_PULL_REQUEST
- echo $BRANCH
- export CURRENT_HEAD=$(git rev-parse HEAD)
- git checkout -b $DEFAULT_BRANCH || git checkout $DEFAULT_BRANCH
- echo $DEFAULT_BRANCH 
- git config pull.rebase true
- git pull origin $DEFAULT_BRANCH --no-edit
- git checkout -b $BRANCH || git checkout $BRANCH
- git pull origin $BRANCH --no-edit
- git checkout $CURRENT_HEAD

script:
- make coverage
- make coverage-xml-report
- make code-check

after_success:
- >
  if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "development" ]; then
    gem install travis -v 1.8.10;
    travis login --org --github-token "$MC_DEV_ADMIN_GH_TOKEN";
    export TICKET_NUMBER=$(echo $TRAVIS_COMMIT_MESSAGE | grep -Eo AC-[0-9]+ | head -1);
    body='{
    "request": {
    "message": "Triggered by '$TICKET_NUMBER' in django-accelerator",
    "branch":"'$TRAVIS_BRANCH'",
    "config": {
      "script": "echo \"The tests dont need to run.\""
      }
    }}'
    curl -s -X POST \
      -H "Content-Type:application/json" \
      -H "Accept:application/json" \
      -H "Travis-API-Version:3" \
      -H "Authorization:token $(travis token --org)" \
      -d "$body" \
      https://api.travis-ci.org/repo/masschallenge%2Fimpact-api/requests;
  fi;

after_script:
- ./cc-test-reporter after-build -t coverage.py --exit-code $TRAVIS_TEST_RESULT