.gitlab-ci.yml 3.57 KB
Newer Older
Lambert Theisen's avatar
Lambert Theisen committed
1
variables:
Lambert Theisen's avatar
Lambert Theisen committed
2
  APP_DIRECTORY: .
Lambert Theisen's avatar
Lambert Theisen committed
3
  DOCS_DIRECTORY: ${APP_DIRECTORY}/docs
4
stages:
Lambert Theisen's avatar
Lambert Theisen committed
5
- prepare
Lambert Theisen's avatar
Lambert Theisen committed
6
- build
Lambert Theisen's avatar
Lambert Theisen committed
7 8
- test
- deploy
9

Lambert Theisen's avatar
Lambert Theisen committed
10 11 12 13
# **************************************************************************** #
# prepare
# **************************************************************************** #

Lambert Theisen's avatar
Lambert Theisen committed
14 15
prepare:docker:
  stage: prepare
Lambert Theisen's avatar
Lambert Theisen committed
16 17
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
18
  script:
Lambert Theisen's avatar
Lambert Theisen committed
19
    - docker pull $CI_REGISTRY_IMAGE:latest || true
20
    - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA || true
21
    - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME || true
Lambert Theisen's avatar
Lambert Theisen committed
22
    - docker build
Lambert Theisen's avatar
Lambert Theisen committed
23 24 25 26
      --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
      --tag $CI_REGISTRY_IMAGE:latest
      --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
      --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME .
Lambert Theisen's avatar
Lambert Theisen committed
27 28
  tags:
    - shell
29

Lambert Theisen's avatar
Lambert Theisen committed
30
# **************************************************************************** #
Lambert Theisen's avatar
Lambert Theisen committed
31
# build
Lambert Theisen's avatar
Lambert Theisen committed
32 33
# **************************************************************************** #

Lambert Theisen's avatar
Lambert Theisen committed
34 35 36 37
build:docs:
  stage: build
  dependencies:
    - prepare:docker
Lambert Theisen's avatar
Lambert Theisen committed
38 39 40
  image:
    name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    entrypoint: [""]
Lambert Theisen's avatar
Lambert Theisen committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  script:
    - cd ${DOCS_DIRECTORY}
    - sphinx-apidoc -f -o source/fenicsR13 ../fenicsR13
    - sphinx-apidoc -f -o source/tests/heat ../tests/heat
    - sphinx-apidoc -f -o source/tests/stress ../tests/stress
    - sphinx-apidoc -f -o source/tests/r13 ../tests/r13
    - sphinx-apidoc -f -o source/examples ../examples
    - make html
    - make latex
  artifacts:
    paths:
      - ${DOCS_DIRECTORY}/_build/html/
      - ${DOCS_DIRECTORY}/_build/latex/
    expire_in: 6 month
  tags:
Lambert Theisen's avatar
Lambert Theisen committed
56
    - docker
57

Lambert Theisen's avatar
Lambert Theisen committed
58 59 60
# **************************************************************************** #
# test
# **************************************************************************** #
61

Lambert Theisen's avatar
Lambert Theisen committed
62 63 64 65 66 67 68 69 70
.test: # dot means "hidden", acts as base class
  stage: test
  before_script:
    - pip install -e . # local install to have right coverage
  image:
    name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    entrypoint: [""]
  tags:
    - docker
71

Lambert Theisen's avatar
Lambert Theisen committed
72 73 74 75 76 77
test:flake8:
  extends: .test
  script:
    - cd ${APP_DIRECTORY}
    - flake8 fenicsR13 examples tests

Lambert Theisen's avatar
Lambert Theisen committed
78 79 80 81 82 83 84 85 86 87 88 89
test:pytest:
  extends: .test
  script:
    - cd ${APP_DIRECTORY}
    - pytest -v --durations=10
    - mkdir convergence_plots
    - cp tests/*/*/convergence_plot* convergence_plots/
  artifacts:
    paths:
      - ${APP_DIRECTORY}/convergence_plots
      - ${APP_DIRECTORY}/htmlcov
    expire_in: 6 month
Lambert Theisen's avatar
Lambert Theisen committed
90

Lambert Theisen's avatar
Lambert Theisen committed
91 92 93
# **************************************************************************** #
# deploy
# **************************************************************************** #
Lambert Theisen's avatar
Lambert Theisen committed
94

Lambert Theisen's avatar
Lambert Theisen committed
95 96 97 98 99 100 101 102
.deploy:docker:
  stage: deploy
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  tags:
    - shell

deploy:docker:dev:
Lambert Theisen's avatar
Fix CI  
Lambert Theisen committed
103
  extends: .deploy:docker
Lambert Theisen's avatar
Lambert Theisen committed
104 105 106 107
  script:
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

deploy:docker:latest:
Lambert Theisen's avatar
Fix CI  
Lambert Theisen committed
108
  extends: .deploy:docker
Lambert Theisen's avatar
Lambert Theisen committed
109 110 111 112 113 114
  script:
    - docker push $CI_REGISTRY_IMAGE:latest
  only:
    - master
    - tags

Lambert Theisen's avatar
Lambert Theisen committed
115 116 117 118 119 120 121
deploy:latex:
  stage: deploy
  image:
    # name: blang/latex:ctanfull # only TexLive 2017
    name: aergus/latex:latest
    entrypoint: [""]
  dependencies:
Lambert Theisen's avatar
Fix CI  
Lambert Theisen committed
122
    - build:docs
Lambert Theisen's avatar
Lambert Theisen committed
123 124 125 126 127 128 129 130 131 132 133
  script:
    - cd ${DOCS_DIRECTORY}/_build/latex/
    - make
  artifacts:
    paths:
      - ${DOCS_DIRECTORY}/_build/latex/${DOCS_LATEX_NAME}.pdf
    expire_in: 6 month
  only:
    - master
    - tags
  tags:
Lambert Theisen's avatar
Lambert Theisen committed
134
    - docker
Lambert Theisen's avatar
Lambert Theisen committed
135

Lambert Theisen's avatar
Lambert Theisen committed
136 137 138
pages:
  stage: deploy
  dependencies:
Lambert Theisen's avatar
Fix CI  
Lambert Theisen committed
139
    - build:docs
Lambert Theisen's avatar
Lambert Theisen committed
140 141 142 143 144 145 146 147 148 149
  script:
    - mv ${DOCS_DIRECTORY}/_build/html/ ${CI_PROJECT_DIR}/public/
  artifacts:
    paths:
      - public
  only:
    - master
    - tags
  tags:
    - shell