.gitlab-ci.yml 6.45 KB
Newer Older
Dion Haefner's avatar
Dion Haefner committed
1 2
variables:
  DUNE_CONTROL_PATH: /opt/dune:$CI_PROJECT_DIR
3
  DUNECONTROL: ./dune-common/bin/dunecontrol
4
  CPUS_MULTICORE: 4
5
  CPUS_DIND: 2
6 7
  DOCKER_LOGIN:
    docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PW
8 9 10 11 12
  
  # DUNE environment image
  BASE_IMAGE: dorie/dune-env
  # Use semantic versioning (not the version of DUNE) and bump according to
  # to whether changes are backwards-compatible or not.
13
  IMAGE_VERSION: "1.2"
14 15
  DUNE_ENV_IMAGE: ${BASE_IMAGE}:img-v${IMAGE_VERSION}

16 17 18
  CMAKE_FLAGS:
    -DDUNE_PYTHON_VIRTUALENV_SETUP=True
    -DDUNE_PYTHON_ALLOW_GET_PIP=True
19 20
  # Recursively load submodules by default
  GIT_SUBMODULE_STRATEGY: recursive
21 22
  MAKE_FLAGS:
    -j $CPUS_MULTICORE
23
  RUN_IN_DUNE_ENV: $CI_PROJECT_DIR/build-cmake/run-in-dune-env
24 25

image: $DUNE_ENV_IMAGE
Dion Haefner's avatar
Dion Haefner committed
26 27 28

before_script:
  - cd /opt/dune
Dion Haefner's avatar
Dion Haefner committed
29

Dion Haefner's avatar
Dion Haefner committed
30
stages:
31
  - setup
Lukas Riedel's avatar
Lukas Riedel committed
32
  - prep
33
  - build
34
  - test
35 36
  - deploy

37 38

# --- Preparation of Docker Images ---
39
setup:dune-env: &setup
40
  stage: setup
41
  only:
42 43
    variables:
      - $REBUILD_BASE_IMAGE # must be defined and have non-empty value
44 45 46 47 48 49 50
  tags:
    - dind
  image: docker:stable
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
51
  before_script:
52
    - $DOCKER_LOGIN
53
  script:
54
    - docker build -f docker/dune-env.dockerfile
55
      --build-arg PROCNUM=$CPUS_DIND
56
      -t $DUNE_ENV_IMAGE .
57
    - docker push $DUNE_ENV_IMAGE
58 59 60 61 62 63

setup:dune-env-clang:
  <<: *setup
  script:
    - docker build -f docker/dune-env.dockerfile
      --build-arg CC=clang
64
      --build-arg CXX=clang++
65 66 67
      --build-arg PROCNUM=$CPUS_DIND
      -t ${DUNE_ENV_IMAGE}-clang .
    - docker push ${DUNE_ENV_IMAGE}-clang
Dion Haefner's avatar
Dion Haefner committed
68

69
prep:update-dune: &update
70
  <<: *setup
71
  stage: prep
72
  allow_failure: true
73 74 75
  only:
    - master
    - tags
76
  script:
77
    - docker build -f docker/dune-env-update.dockerfile
78 79
      --build-arg DUNE_ENV_IMAGE=$DUNE_ENV_IMAGE
      --build-arg PROCNUM=$CPUS_DIND
80
      -t $DUNE_ENV_IMAGE .
81
    - docker push $DUNE_ENV_IMAGE
82

83 84 85 86
prep:update-dune-clang:
  <<: *update
  script:
    - docker build -f docker/dune-env-update.dockerfile
87
      --build-arg DUNE_ENV_IMAGE=${DUNE_ENV_IMAGE}-clang
88 89
      --build-arg CC=clang
      --build-arg CXX=clang++
90
      --build-arg PROCNUM=$CPUS_DIND
91 92
      -t ${DUNE_ENV_IMAGE}-clang .
    - docker push ${DUNE_ENV_IMAGE}-clang
93 94 95


# --- Build jobs ---
96
build:system-tests: &build-tests
97
  stage: build
Dion Haefner's avatar
Dion Haefner committed
98
  script:
Lukas Riedel's avatar
Lukas Riedel committed
99
    - CMAKE_FLAGS="$CMAKE_FLAGS"
100
      $DUNECONTROL --only=dorie configure
101
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS dorie-rfg
102
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_system_tests
103
    - $DUNECONTROL --only=dorie make doc
104
  artifacts:
105
    name: "$CI_JOB_NAME"
106
    paths:
107
      - $CI_PROJECT_DIR/build-cmake
108
    expire_in: 1 day
109

110 111 112 113 114 115
build:unit-tests:
  <<: *build-tests
  script:
    - CMAKE_FLAGS="$CMAKE_FLAGS
                   -DCMAKE_BUILD_TYPE=Debug"
      $DUNECONTROL --only=dorie configure
116
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_unit_tests
117

118
build:debug: &debug
119
  stage: build
120
  allow_failure: true
121
  script:
Lukas Riedel's avatar
Lukas Riedel committed
122 123
    - CMAKE_FLAGS="
        $CMAKE_FLAGS
124
        -DCMAKE_BUILD_TYPE=Debug
Lukas Riedel's avatar
Lukas Riedel committed
125
        -DCMAKE_CXX_FLAGS_DEBUG='-Werror'"
126
      $DUNECONTROL --only=dorie configure
127
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS dorie-rfg
128
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_unit_tests
129
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS richards_d2_r1 transport_d2_r0_t0
130

131 132 133
build:debug-clang:
  <<: *debug
  image: ${DUNE_ENV_IMAGE}-clang
134 135 136
  script:
    - CMAKE_FLAGS="
        $CMAKE_FLAGS
137
        -DCMAKE_BUILD_TYPE=Debug
138 139 140 141
        -DCMAKE_C_COMPILER=clang
        -DCMAKE_CXX_COMPILER=clang++
        -DCMAKE_CXX_FLAGS_DEBUG='-Werror'"
      $DUNECONTROL --only=dorie configure
142
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS dorie-rfg
143
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_unit_tests
144
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS transport_d2_r0_t0 transport_d2_r1_t0
145 146 147


# --- Tests ---
148
test:system-tests: &test
149 150
  stage: test
  dependencies:
151
    - build:system-tests
152
  script:
Lukas Riedel's avatar
Lukas Riedel committed
153
    - $DUNECONTROL --only=dorie configure
154
    - $DUNECONTROL --only=dorie make system_tests
155 156 157
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
158
      - $CI_PROJECT_DIR/build-cmake/test
159
    expire_in: 1 day
160

161
test:unit-tests:
162
  <<: *test
163 164
  dependencies:
    - build:unit-tests
165
  script:
166
    # install coverage reporter
167 168
    - $DUNECONTROL --only=dorie bexec
      "./run-in-dune-env python3 -m pip install gcovr"
169
    # perform the tests
170
    - $DUNECONTROL --only=dorie configure
171 172
    - $DUNECONTROL --only=dorie make unit_tests
    # report coverage
173
    - cd $CI_PROJECT_DIR/build-cmake
174
    - mkdir -p dune/dorie/test/coverage
175 176
    - ./run-in-dune-env gcovr
      --root ../
177
      --exclude ../dune/dorie/test
178
      --exclude ../plugins
179
      --html --html-details
180
      -o dune/dorie/test/coverage/coverage.html
181
    # run again for coverage report in GitLab
182 183
    - ./run-in-dune-env gcovr
      --root ../
184
      --exclude ../dune/dorie/test
185
      --exclude ../plugins
186
  coverage: '/^TOTAL.*\s+(\d+\%)$/'
187 188 189 190 191
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
      - $CI_PROJECT_DIR/build-cmake/dune/dorie/test
    expire_in: 1 day
192

193 194 195 196 197 198 199
test:python-tests:
  <<: *test
  dependencies: []
  script:
    - $DUNECONTROL --only=dorie configure
    - $DUNECONTROL --only=dorie make test_python

200
# --- Deploy jobs ---
201
deploy:dockerhub-devel: &deploy
Lukas Riedel's avatar
Lukas Riedel committed
202
  stage: deploy
203
  only:
204
    - master@dorie/dorie
205 206 207 208 209 210 211
  tags:
    - dind
  image: docker:stable
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
212
  dependencies: []
213
  before_script:
214
    - $DOCKER_LOGIN
215
  script:
216
    - docker build -f docker/dorie.dockerfile
217
      --build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
218
      -t dorie/dorie:devel .
219
    - docker push dorie/dorie:devel
220 221

deploy:dockerhub-stable:
222
  <<: *deploy
223
  only:
224
    - tags@dorie/dorie
225
  script:
226
    - docker build -f docker/dorie.dockerfile
227
      --build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
228
      -t dorie/dorie:$CI_COMMIT_TAG .
229
    - docker push dorie/dorie:$CI_COMMIT_TAG
230 231 232

deploy:sphinx-docs:
  stage: deploy
233 234
  only:
    - tags@dorie/dorie
235
  dependencies:
236
    - build:system-tests
237
  before_script:
238 239 240 241 242 243 244
    # install the netfly CLI
    - apt-get install -y golang-go golang-glide
    - go get -d github.com/netlify/netlifyctl
    - cd $HOME/go/src/github.com/netlify/netlifyctl/
    - make deps build
    - go install
    - cd $HOME/go/bin
245
  script:
246 247 248 249
    - ./netlifyctl deploy
      -A $NETFLY_DEPLOY_TOKEN
      -s $NETFLY_SITE_ID
      -P $CI_PROJECT_DIR/build-cmake/doc/html
250 251
  environment:
    name: sphinx-docs
252
    url: https://dorie-doc.netlify.com/