GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

.gitlab-ci.yml 3.39 KB
Newer Older
Stuart Fisher's avatar
Stuart Fisher committed
1 2 3 4 5 6 7
# Mostly stolen from gitlab.esrf.fr/bliss/bliss
default:
  before_script:
    # set pip cache to the Docker volume
    - echo ${CI_PROJECT_DIR}
    - export PIP_CACHE_DIR="/opt/cache/pip"
    - /opt/conda/bin/conda init && source /root/.bashrc
Stuart Fisher's avatar
Stuart Fisher committed
8 9 10
    - conda config --prepend channels tango-controls
    - conda config --prepend channels esrf-bcu
    - conda config --prepend channels conda-forge
Stuart Fisher's avatar
Stuart Fisher committed
11 12

stages:
Stuart Fisher's avatar
Stuart Fisher committed
13
  - style
Stu Fisher's avatar
Stu Fisher committed
14
  - tests
Stuart Fisher's avatar
Stuart Fisher committed
15
  - build
Stuart Fisher's avatar
Stuart Fisher committed
16
  - build-doc
Stuart Fisher's avatar
Stuart Fisher committed
17 18
  - deploy

Stuart Fisher's avatar
Stuart Fisher committed
19 20 21 22 23 24 25 26 27
services:
  - mariadb:latest

variables:
  MYSQL_USER: test
  MYSQL_PASSWORD: test
  MYSQL_DATABASE: test
  MYSQL_ROOT_PASSWORD: password

Stuart Fisher's avatar
Stuart Fisher committed
28 29 30 31
check_style:
  stage: style
  image: continuumio/miniconda3:latest
  script:
Stuart Fisher's avatar
Stuart Fisher committed
32
    - conda install black==19.10b0
Stuart Fisher's avatar
Stuart Fisher committed
33 34 35 36 37 38 39 40 41 42
    - LC_ALL=C.UTF-8 black --check --safe .

check_lint:
  stage: style
  image: continuumio/miniconda3:latest
  script:
    - pip install flake8
    - git diff -U0 origin/master...$CI_COMMIT_SHA | flake8 --diff
  allow_failure: true

43 44 45 46 47 48 49 50
check_security:
  stage: style
  image: continuumio/miniconda3:latest
  script:
    - pip install bandit
    - bandit -r daiquiri/
  allow_failure: true  

Stu Fisher's avatar
Stu Fisher committed
51 52 53 54 55
.template_test:
  stage: tests
  image: continuumio/miniconda3:latest
  script:
    # install opengl libraries (needed to avoid problem with pyopengl dependency)
Stuart Fisher's avatar
Stuart Fisher committed
56
    - apt-get update && apt-get -y install libgl1-mesa-glx mariadb-client
Stu Fisher's avatar
Stu Fisher committed
57 58 59 60
    - conda create -q --yes --name apienv
    - source activate apienv
    - git clone https://gitlab.esrf.fr/bliss/bliss
    - cd bliss
Stuart Fisher's avatar
Stuart Fisher committed
61
    - conda install --file requirements.txt --file ../requirements-test-conda.txt
Stu Fisher's avatar
Stu Fisher committed
62 63
    - pip install . --no-deps
    - cd ..
Stuart Fisher's avatar
Stuart Fisher committed
64
    - conda install --file requirements-conda.txt
Stu Fisher's avatar
Stu Fisher committed
65
    - pip install -r requirements-pip.txt
Stuart Fisher's avatar
Stuart Fisher committed
66 67
    - pip install -e .
    - CI=1 pytest --ignore=bliss $PYTEST_ARGS
Stu Fisher's avatar
Stu Fisher committed
68 69 70 71 72 73 74 75 76 77 78

test:
  extends: .template_test
  except:
    - master

test_cov:
  extends: .template_test
  only:
    - master
  artifacts:
Stuart Fisher's avatar
Stuart Fisher committed
79
    when: always
Stu Fisher's avatar
Stu Fisher committed
80
    paths:
Stuart Fisher's avatar
Stuart Fisher committed
81
      - htmlcov
Stu Fisher's avatar
Stu Fisher committed
82 83
    expire_in: 7 days
  variables:
Stu Fisher's avatar
Stu Fisher committed
84
    PYTEST_ARGS: '--cov daiquiri --cov-report html:htmlcov'
Stu Fisher's avatar
Stu Fisher committed
85

Stuart Fisher's avatar
Stuart Fisher committed
86
create_user_doc:
Stuart Fisher's avatar
Stuart Fisher committed
87
  stage: build-doc
Stuart Fisher's avatar
Stuart Fisher committed
88 89 90 91
  image: continuumio/miniconda3:latest
  script:
    - conda create -q --yes --name mkdocsenv --file requirements-conda.txt --file requirements-doc-conda.txt
    - source activate mkdocsenv
Stuart Fisher's avatar
Stuart Fisher committed
92 93 94 95
    # install bliss
    - apt-get update && apt-get -y install libgl1-mesa-glx
    - git clone https://gitlab.esrf.fr/bliss/bliss
    - cd bliss
Stuart Fisher's avatar
Stuart Fisher committed
96
    - conda install --file requirements.txt
Stuart Fisher's avatar
Stuart Fisher committed
97 98 99
    - pip install . --no-deps
    - cd ..

Stuart Fisher's avatar
Stuart Fisher committed
100 101
    - pip install -r requirements-pip.txt
    - pip install -r requirements-doc.txt
Stuart Fisher's avatar
Stuart Fisher committed
102
    - pip install . --no-deps
Stuart Fisher's avatar
Stuart Fisher committed
103 104 105 106 107
    - cd doc && mkdocs build
  artifacts:
    paths:
      - doc/site
    expire_in: 7 days
Stu Fisher's avatar
Stu Fisher committed
108 109 110
  only:
    - tags
    - master
Stuart Fisher's avatar
Stuart Fisher committed
111

Stuart Fisher's avatar
Stuart Fisher committed
112
create_api_spec:
Stu Fisher's avatar
Stu Fisher committed
113
  extends: .template_test
Stuart Fisher's avatar
Stuart Fisher committed
114
  stage: build
Stu Fisher's avatar
Stu Fisher committed
115
  variables:
Stuart Fisher's avatar
Stuart Fisher committed
116
    PYTEST_ARGS: '--apispec tests/api/test_write_spec.py'
Stuart Fisher's avatar
Stuart Fisher committed
117 118 119 120
  artifacts:
    paths:
      - doc/api
    expire_in: 7 days
Stu Fisher's avatar
Stu Fisher committed
121 122 123
  only:
    - tags
    - master
Stuart Fisher's avatar
Stuart Fisher committed
124

Stuart Fisher's avatar
Stuart Fisher committed
125 126
create_api_doc:
  stage: build-doc
Stu Fisher's avatar
Stu Fisher committed
127
  image: node:14.15.0
Stuart Fisher's avatar
Stuart Fisher committed
128 129
  before_script:
    - ''
Stuart Fisher's avatar
Stuart Fisher committed
130 131 132 133 134 135 136
  script:
    - npm install -g redoc-cli
    - redoc-cli bundle -o doc/api/index.html doc/api/spec.json
  artifacts:
    paths:
      - doc/api
    expire_in: 7 days
Stu Fisher's avatar
Stu Fisher committed
137 138 139
  only:
    - tags
    - master
Stuart Fisher's avatar
Stuart Fisher committed
140

Stuart Fisher's avatar
Stuart Fisher committed
141 142
pages:
  stage: deploy
Stuart Fisher's avatar
Stuart Fisher committed
143 144
  before_script:
    - ''
Stuart Fisher's avatar
Stuart Fisher committed
145 146
  script:
    - mv doc/site public/
Stuart Fisher's avatar
Stuart Fisher committed
147
    - mv doc/api public/api/spec
Stu Fisher's avatar
Stu Fisher committed
148
    - mv htmlcov public/coverage
Stuart Fisher's avatar
Stuart Fisher committed
149 150 151 152 153 154 155
  artifacts:
    paths:
      - public
    expire_in: 7 days
  only:
    - tags
    - master