.gitlab-ci.yml 6.1 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 build_system_tests
102
    - $DUNECONTROL --only=dorie make doc
103
  artifacts:
104
    name: "$CI_JOB_NAME"
105
    paths:
106
      - $CI_PROJECT_DIR/build-cmake
Lukas Riedel's avatar
Lukas Riedel committed
107
    expire_in: 1 day
108

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

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

128 129 130
build:debug-clang:
  <<: *debug
  image: ${DUNE_ENV_IMAGE}-clang
131 132 133
  script:
    - CMAKE_FLAGS="
        $CMAKE_FLAGS
134
        -DCMAKE_BUILD_TYPE=Debug
135 136 137 138
        -DCMAKE_C_COMPILER=clang
        -DCMAKE_CXX_COMPILER=clang++
        -DCMAKE_CXX_FLAGS_DEBUG='-Werror'"
      $DUNECONTROL --only=dorie configure
139
    - $DUNECONTROL --only=dorie make $MAKE_FLAGS build_unit_tests
140 141 142


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

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

188 189 190 191 192 193 194
test:python-tests:
  <<: *test
  dependencies: []
  script:
    - $DUNECONTROL --only=dorie configure
    - $DUNECONTROL --only=dorie make test_python

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

deploy:dockerhub-stable:
217
  <<: *deploy
218
  only:
219
    - tags@dorie/dorie
220
  script:
221
    - docker build -f docker/dorie.dockerfile
222
      --build-arg DUNE_ENV_IMAGE=$DUNE_ENV_IMAGE --build-arg PROCNUM=$CPUS_DIND
223
      -t dorie/dorie:$CI_COMMIT_TAG .
224
    - docker push dorie/dorie:$CI_COMMIT_TAG
225 226 227

deploy:sphinx-docs:
  stage: deploy
228 229
  only:
    - tags@dorie/dorie
230
  dependencies:
231
    - build:system-tests
232
  before_script:
233 234 235 236 237 238 239
    # 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
240
  script:
241 242 243 244
    - ./netlifyctl deploy
      -A $NETFLY_DEPLOY_TOKEN
      -s $NETFLY_SITE_ID
      -P $CI_PROJECT_DIR/build-cmake/doc/html
245 246
  environment:
    name: sphinx-docs
247
    url: https://dorie-doc.netlify.com/