Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.29 KiB
Newer Older
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:
Rajmund Hruška's avatar
Rajmund Hruška committed
  - test
  - check-warnings
  - build
  - deploy

Rajmund Hruška's avatar
Rajmund Hruška committed
unit-tests:
  stage: test
  script:
    - echo "unit test"
  artifacts:
    when: always
    paths:
      - errors.log

Rajmund Hruška's avatar
Rajmund Hruška committed
pylint:
  stage: test
  script:
    - echo "pylint"
Rajmund Hruška's avatar
Rajmund Hruška committed
pyflakes:
  stage: test
  script:
    - echo "pyflakes"
Rajmund Hruška's avatar
Rajmund Hruška committed
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 == "true"
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
    - printf "\"bdate\":\"$(date '+%Y-%m-%d %T')\"\n}\n" >> metadata.json
    - mv metadata.json doc/sphinx/.
  artifacts:
    paths:
      - doc/sphinx/metadata.json
  rules:
    - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "devel" || $CI_COMMIT_BRANCH == "release"
twine-job:
  stage: deploy
  script:
    - echo "twine"
  rules:
    - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "devel" || $CI_COMMIT_BRANCH == "release"
      changes:
        - lib/mentat/__init__.py
    - if: $FORCE_BUILD == "true"
.pages:
  stage: deploy
Rajmund Hruška's avatar
Rajmund Hruška committed
  variables:
    GIT_SUBMODULE_STRATEGY: recursive
    GIT_SUBMODULE_FORCE_HTTPS: "true"
  script:
    - make deps-python
    - make deps-python-dev
Rajmund Hruška's avatar
Rajmund Hruška committed
    - make docs # Build documentation
    - for branch in devel master release; do curl -L --header "JOB-TOKEN:$CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$branch/download?job=pages" -o $branch.zip; done # Download the documentation from devel, master and release branches
    - unzip -uo '*.zip' || true # Unzip downloaded documentation while ignoring not existing files
Rajmund Hruška's avatar
Rajmund Hruška committed
    - mkdir -p public/"$CI_COMMIT_BRANCH" # Create directory for docs for this branch if it doesn't exist
    - cp -rf doc/sphinx/_build/html public/"$CI_COMMIT_BRANCH" # Copy docs to shared folder used by GitLab to publish Pages
  artifacts:
    name: "$CI_COMMIT_BRANCH"
    paths:
      - public
  only:
    - master
    - devel
    - release

deb-job:
  stage: deploy
  script:
      - echo "deb job"
  rules:
    - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "devel" || $CI_COMMIT_BRANCH == "release"
      changes:
        - packaging/debian/changelog
    - if: $FORCE_BUILD == "true"