Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.26 KiB
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/${MENTAT_IMAGE}:latest

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

# https://pip.pypa.io/en/stable/topics/caching/
cache:
  paths:
    - .cache/pip

before_script:
  - python3 -m venv venv
  - source venv/bin/activate

stages:
  - test
  - check-warnings
  - build
  - deploy

unit-tests:
  stage: test
  script:
    - echo "unit test"
  artifacts:
    when: always
    paths:
      - errors.log

pylint:
  stage: test
  script:
    - echo "pylint"

pyflakes:
  stage: test
  script:
    - echo "pyflakes"

check-deprecation-warnings:
  before_script: []
  stage: check-warnings
  script:
    - "if [[ $(grep DeprecationWarning errors.log) ]]; then cat errors.log; exit 1; fi"
  allow_failure: true

build-job:
  stage: build
  script:
    - echo "build job"
  artifacts:
    paths:
      - dist
  rules:
    - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "devel" || $CI_COMMIT_BRANCH == "release"
      changes:
        - lib/mentat/__init__.py
    - if: $FORCE_BUILD

sphinx-metadata-job:
  stage: build
  before_script: []
  script:
    - printf "{\n\"codename\":\"$CI_COMMIT_BRANCH\",\n" > metadata.json
    - printf "\"suite\":$(if [ "$CI_COMMIT_BRANCH" == "master" ]; then echo \"stable\"; else echo \"unstable\"; fi),\n" >> metadata.json
    - printf "\"bversion\":\"$(make show-version)\",\n" >> metadata.json
    - printf "\"revision\":\"$CI_COMMIT_SHA\",\n" >> metadata.json
    - printf "\"bnumber\":\"$CI_PIPELINE_ID\",\n" >> metadata.json