---

stages:
  - checks
  - style
  - test

image: python:2

services:
  - mysql:5.7

variables:
  MYSQL_DATABASE: internewshid
  MYSQL_ROOT_PASSWORD: passw0rd
  DJANGO_SECRET_KEY: 'nde2wr2r)#a*%n$!(zl8#3v_o!sp=hd9vbv%*e6atgr0dp=b(7'
  DJANGO_SETTINGS_MODULE: settings

before_script:
  - pip install -U pipenv setuptools 'pip<=18.0' # https://github.com/pypa/pipenv/issues/2924
  - ln -srf internewshid/local_settings.py.gitlab internewshid/local_settings.py
  - |
    echo "SECRET_KEY = '$DJANGO_SECRET_KEY'" >> internewshid/private_settings.py
    echo "DB_PASSWORD = '$MYSQL_ROOT_PASSWORD'" >> internewshid/private_settings.py
  - pipenv sync --dev
  - apt update && apt install -y node-less

checks:
  stage: checks
  script:
    - pipenv run python manage.py check
    - pipenv run python manage.py makemigrations --check

style:
  stage: style
  allow_failure: true
  script:
    - pipenv run pylava internewshid
    - |
      pipenv run isort internewshid \
      --recursive \
      --check-only \
      --diff \
      --settings-path=setup.cfg

test:
  stage: test
  script:
    - pipenv run pytest -v --cov