TabbycatDebate/tabbycat

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
language: python
dist: xenial
sudo: required
group: edge
env:
  global:
    - CC_TEST_REPORTER_ID=c18003eb2d4d191e9ebd68d9c3cf8082ba690eccac12df6660a098a78fc8713b
    - PGPORT=5433
addons:
  postgresql: "11"
  apt:
    packages:
      - postgresql-11
      - postgresql-client-11
  # chrome: stable # Re-enable for functional tests if/when they work on Travis
services:
  - postgresql

branches:
  except:
  - l10n_develop

matrix:
  include:

    # Python 3.7
    # This job also runs style guide checkers (flake8 and lint).
    - os: linux
      python: 3.7
      before_install:
        - node --version
        - npm --version
      install:
        - pip install -r ./config/requirements_development.txt
        - npm install
      before_script:
        - sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
        - sudo systemctl restart postgresql@11-main
        - pg_lsclusters
        - createdb travisci -U postgres
      script:
        - flake8 tabbycat
        - npm run lint
        - python tabbycat/manage.py test -v 2 --exclude-tag=selenium

    # Python 3.6
    # This job also runs the code coverage tool.
    - os: linux
      python: 3.6
      before_install:
        - node --version
        - npm --version
      install:
        - pip install -r ./config/requirements_development.txt
        - pip install coverage
        - npm install
      before_script:
        - sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
        - sudo systemctl restart postgresql@11-main
        - pg_lsclusters
        - createdb travisci -U postgres
        - 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
      script:
        - coverage run tabbycat/manage.py test -v 2 --exclude-tag=selenium
      after_script:
        - coverage xml
        - if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi

    # Docker
    - os: linux
      language: generic
      services:
        - docker
      script:
        - docker-compose build
        # TODO: get working later; currently lacks a database connection
        # - docker-compose run web python tabbycat/manage.py test -v 2 --exclude-tag=selenium

    # - os: osx
    #   osx_image: xcode9.1 # macOS 10.12
    #   language: generic # Override global
    #   before_install: # Need to bootstrap dependencies on macOS
    #     - brew update # Need to update first
    #     - brew upgrade python # Install latest Python3
    #     - export PATH="/usr/local/opt/python/libexec/bin:$PATH" # Alias 'python' to latest Python3
    #     - virtualenv env -p python
    #     - source env/bin/activate
    #     - python --version
    #   before_script:
    #     - brew services start postgresql
    #     # We are testing, in effect, the local install so use local settings:
    #     - cp settings/local.example settings/local.py
    #   script:
    #     - npm run build
    #     - python tabbycat/manage.py collectstatic
    #     # TODO: get working later; currently lacks a database connection
    #     #- python tabbycat/manage.py test -v 2 --exclude-tag=selenium

# The below is used to enable selenium testing as per:
# https://docs.travis-ci.com/user/gui-and-headless-browsers/
# Currently it runs and loads the view; but doesn't seem to resolve the asserts
# Either the Chrome instance isn't running; or the static files aren't serving
# To rule out the former maybe disable tabbycat.standings.tests.test_ui.CoreStandingsTests
# And just let it test the login page (that should work without staticfiles)
# before_install:
#   # Run google chrome in headless mode
#   - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
# before_script:
#   # GUI for real browsers.
#   - export DISPLAY=:99.0
#   - sh -e /etc/init.d/xvfb start
#   - sleep 3 # give xvfb some time to start
#   - dj collectstatic