image: python:latest

services:
  - postgres:latest

variables:
  POSTGRES_DB: database_name

cache:
  key: '$CI_JOB_NAME-$CI_COMMIT_REF_SLUG'
  paths:
    - .cache/pip
    - venv/

before_script:
  - python -V
  - python3 -m venv venv
  - source venv/bin/activate
  - pip install -r requirements/production.txt

stages:
  - Build

Flake8:
  stage: Build
  script:
    - flake8 --max-line-length=125 --exclude=src/kszkepzes,migrations,venv,env

Test:
  stage: Build
  variables:
    DATABASE_URL: 'postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB'
    SECRET_KEY: 'secret'
    AUTHSCH_KEY: 'secret'
    AUTHSCH_SECRET: 'secret'
  script:
    - python src/manage.py test
