.gitlab-ci.yml 6.64 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
Lukas Riedel's avatar
Lukas Riedel committed
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
Lukas Riedel's avatar
Lukas Riedel committed
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
Lukas Riedel's avatar
Lukas Riedel committed
108
    expire_in: 1 day
109

110 111
build:unit-tests:
  <<: *build-tests
112 113
  # for KnoFu util testing
  # TODO: Remove before_script, better handling of Eigen3(?)
114 115
  before_script:
    - cd /opt/dune
116
    - apt-get update && apt-get install -y libeigen3-dev && apt-get clean
117 118 119 120
  script:
    - CMAKE_FLAGS="$CMAKE_FLAGS
                   -DCMAKE_BUILD_TYPE=Debug"
      $DUNECONTROL --only=dorie configure
121
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_unit_tests
122

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

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


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

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

198 199 200 201 202 203 204
test:python-tests:
  <<: *test
  dependencies: []
  script:
    - $DUNECONTROL --only=dorie configure
    - $DUNECONTROL --only=dorie make test_python

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

deploy:dockerhub-stable:
227
  <<: *deploy
228
  only:
229
    - tags@dorie/dorie
230
  script:
231
    - docker build -f docker/dorie.dockerfile
232
      --build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
233
      -t dorie/dorie:$CI_COMMIT_TAG .
234
    - docker push dorie/dorie:$CI_COMMIT_TAG
235 236 237

deploy:sphinx-docs:
  stage: deploy
238 239
  only:
    - tags@dorie/dorie
240
  dependencies:
241
    - build:system-tests
242
  before_script:
243 244 245 246 247 248 249
    # 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
250
  script:
251 252 253 254
    - ./netlifyctl deploy
      -A $NETFLY_DEPLOY_TOKEN
      -s $NETFLY_SITE_ID
      -P $CI_PROJECT_DIR/build-cmake/doc/html
255 256
  environment:
    name: sphinx-docs
257
    url: https://dorie-doc.netlify.com/