Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.27 KiB
Newer Older
Eva Bardou's avatar
Eva Bardou committed
stages:
  - test
  - build
  - release

# 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'

variables:
  VERSION: commit-$CI_COMMIT_SHORT_SHA
  DEBIAN_FRONTEND: non-interactive

test:
ml bonhomme's avatar
ml bonhomme committed
  image: python:3.11
Eva Bardou's avatar
Eva Bardou committed

  stage: test
  cache:
    paths:
      - .cache/pip

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    ARKINDEX_API_SCHEMA_URL: schema.yml

  before_script:
    - pip install tox

ml bonhomme's avatar
ml bonhomme committed
    # Add pdftoppm
    - apt-get update
    - apt-get install -y --no-install-recommends poppler-utils

Eva Bardou's avatar
Eva Bardou committed
    # Install curl
    - apt-get update -q -y && apt-get install -q -y --no-install-recommends curl

    # Download OpenAPI schema from last backend build
    - curl https://assets.teklia.com/arkindex/openapi.yml > schema.yml

  except:
    - schedules

  script:
    - tox -- --junitxml=test-report.xml --durations=50

lint:
ml bonhomme's avatar
ml bonhomme committed
  image: python:3.11
Eva Bardou's avatar
Eva Bardou committed

  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

    # Install git
    - apt-get update -q -y && apt-get install -q -y --no-install-recommends git

  except:
    - schedules

  script:
    - pre-commit run -a

docker-build:
  stage: build
  image: docker:24.0.6
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2375/

  rules:
    # Never run on scheduled pipelines
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    # Use commit tag when running on tagged commit
    - if: $CI_COMMIT_TAG
      variables:
        VERSION: $CI_COMMIT_TAG
    - when: on_success

  script:
    - ci/build.sh

release-notes:
  stage: release
  image: registry.gitlab.teklia.com/infra/devops:latest

  # Only run on tags
  only:
    - tags

  script:
    - devops release-notes

bump-python-deps:
  stage: release
  image: registry.gitlab.teklia.com/infra/devops:latest

  only:
    - schedules

  script:
    - devops python-deps pyproject.toml