Skip to content
Snippets Groups Projects
.gitlab-ci.yml 5.05 KiB
stages:
  - test
  - build
  - deploy

# GitLab provides a template to ensure pipelines run only for branches and tags, not for merge requests
# This prevents duplicate pipelines in merge requests.
# See https://docs.gitlab.com/ee/ci/troubleshooting.html#job-may-allow-multiple-pipelines-to-run-for-a-single-action
include:
  - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'

# For jobs that run backend scripts directly
.backend-setup:
  image: registry.gitlab.teklia.com/arkindex/backend/base:django-5.0.8

  cache:
    paths:
      - .cache/pip

  before_script:
    - "echo database: {host: postgres, port: 5432} > $CONFIG_PATH"
    - pip install -e .[test]

  # Those jobs require the base image; they might fail if the image is not up to date.
  # Allow them to fail when building a new base image, to prevent them from blocking a new base image build
  # Never run those jobs on scheduled pipelines
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^base-.*/'
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    - when: on_success

  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:
    - name: postgis/postgis:17-3.5
      alias: postgres

  artifacts:
    when: always
    reports:
      junit:
        - test-report.xml

  script:
    - arkindex test

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

  except:
    - schedules

  cache: