Skip to content
Snippets Groups Projects
.gitlab-ci.yml 4.41 KiB
image: registry.gitlab.com/arkindex/backend/base:latest
stages:
  - test
  - build
  - deploy

# For jobs that run backend scripts directly
.backend-setup:
  cache:
    paths:
      - .cache/pip

  before_script:
    - apk --update add build-base
    # Custom line to install our own deps from Git using GitLab CI credentials
    - "pip install -e git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/arkindex/common#egg=arkindex-common"
    - "pip install -e git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/arkindex/ponos#egg=ponos-server"
    - "pip install -e git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/arkindex/transkribus#egg=transkribus-client"
    - pip install -r tests-requirements.txt codecov
    - "echo 'database: {host: postgres, port: 5432}' > $CONFIG_PATH"

  variables:
    # For the postgres image
    POSTGRES_DB: arkindex_dev
    POSTGRES_USER: devuser
    POSTGRES_PASSWORD: devdata

    # For the backend
    CONFIG_PATH: "$CI_PROJECT_DIR/config.yml"

    # Pip cache
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

backend-tests:
  extends: .backend-setup
  stage: test

  services:
    - postgres:12.0

  script:
    - python setup.py test
    - codecov

backend-lint:
  image: python:3
  stage: test

  cache:
    paths:
      - .cache/pip
      - .cache/pre-commit

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"

  before_script:
    - pip install pre-commit

  script:
    - pre-commit run -a

backend-migrations:
  extends: .backend-setup
  stage: test

  services:
    - postgres:12.0