a80bdf0c46ed9924770958d103845fc06f7b2ac3
[alexxy/gromacs.git] / admin / gitlab-ci / documentation.gitlab-ci.yml
1 # Build documentation and web page.
2 .documentation-before-script-template:
3   variables:
4     EXTRA_INSTALLS: ""
5
6   before_script:
7     - echo $EXTRA_INSTALLS
8     - time apt-get -qq update
9     - time apt-get -qqy --no-install-suggests --no-install-recommends install
10       $EXTRA_INSTALLS
11     - mkdir -p ccache
12     - export CCACHE_BASEDIR=${PWD}
13     - export CCACHE_DIR=${PWD}/ccache
14
15 .configure-docs-template:
16   # Built by admin/dockerfiles/ci-docs-clang
17   # TODO this should be organized more like the current documentation.py script
18   image: gromacs/ci-docs-clang:master
19   stage: configure-build
20   variables:
21     KUBERNETES_CPU_LIMIT: 1
22     KUBERNETES_CPU_REQUEST: 1
23     KUBERNETES_MEMORY_LIMIT: 2Gi
24     CMAKE_COMPILER_SCRIPT: "-DCMAKE_C_COMPILER=clang-7 -DCMAKE_CXX_COMPILER=clang++-7"
25     CMAKE_EXTRA_OPTIONS: ""
26     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=None"
27     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=OFF"
28     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
29     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
30     CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
31     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
32
33   script:
34     - if [[ ! -z $GROMACS_RELEASE && $GROMACS_RELEASE == "true" ]] ; then
35       REL_OPTION="-DGMX_BUILD_TARBALL=ON" ;
36       else
37       REL_OPTION="-DGMX_BUILD_TARBALL=OFF" ;
38       fi
39     - echo $CMAKE_COMPILER_SCRIPT
40     - echo $CMAKE_EXTRA_OPTIONS
41     - echo $CMAKE_SIMD_OPTIONS
42     - echo $CMAKE_GPU_OPTIONS
43     - echo $CMAKE_MPI_OPTIONS
44     - echo $CMAKE_PRECISION_OPTIONS
45     - echo $CMAKE_BUILD_TYPE_OPTIONS
46     - echo $CMAKE_GMXAPI_OPTIONS
47     - echo $REL_OPTION
48     - if [[ -d $BUILD_DIR ]] ; then
49       rm -rf $BUILD_DIR && mkdir $BUILD_DIR ;
50       else
51       echo "Preparing new build directory" ;
52       mkdir $BUILD_DIR ;
53       fi
54     - cd $BUILD_DIR
55     - cmake ..
56       -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
57       $CMAKE_COMPILER_SCRIPT
58       $CMAKE_EXTRA_OPTIONS
59       $CMAKE_SIMD_OPTIONS
60       $CMAKE_MPI_OPTIONS
61       $CMAKE_PRECISION_OPTIONS
62       $CMAKE_BUILD_TYPE_OPTIONS
63       $CMAKE_GPU_OPTIONS
64       $CMAKE_GMXAPI_OPTIONS
65       $REL_OPTION
66       -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
67       2>&1 | tee cmakeLog.log
68     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
69     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
70     - cd ..
71   artifacts:
72     name: docs-artifacts-$CI_COMMIT_REF_SLUG
73     when: always
74     expire_in: 1 week
75     paths:
76       - $BUILD_DIR
77
78 .configure-docs-release-template:
79   # Built by admin/dockerfiles/ci-docs-clang
80   # TODO this should be organized more like the current documentation.py script
81   image: gromacs/ci-docs-clang:master
82   stage: release-configure
83   variables:
84     KUBERNETES_CPU_LIMIT: 1
85     KUBERNETES_CPU_REQUEST: 1
86     KUBERNETES_MEMORY_LIMIT: 2Gi
87     CMAKE_COMPILER_SCRIPT: "-DCMAKE_C_COMPILER=clang-7 -DCMAKE_CXX_COMPILER=clang++-7"
88     CMAKE_EXTRA_OPTIONS: ""
89     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=None"
90     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
91     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
92     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
93     CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
94     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
95     RELEASE_BUILD_DIR: release-doc-builds
96     RELEASE_SOURCE: release-source-from-tarball
97     RELEASE_REGRESSIONTESTS: release-regressiontests-from-tarball
98
99   only:
100     refs:
101       - web
102       - schedules
103       - triggers
104     variables:
105       - $GROMACS_RELEASE
106   script:
107     - if [[ $GROMACS_RELEASE == "true" ]] ; then
108       REL_OPTION="-DGMX_BUILD_TARBALL=ON" ;
109       else
110       REL_OPTION="-DGMX_BUILD_TARBALL=OFF" ;
111       fi
112     - echo $CMAKE_COMPILER_SCRIPT
113     - echo $CMAKE_EXTRA_OPTIONS
114     - echo $CMAKE_SIMD_OPTIONS
115     - echo $CMAKE_GPU_OPTIONS
116     - echo $CMAKE_MPI_OPTIONS
117     - echo $CMAKE_PRECISION_OPTIONS
118     - echo $CMAKE_BUILD_TYPE_OPTIONS
119     - echo $CMAKE_GMXAPI_OPTIONS
120     - echo $REL_OPTION
121     - VERSION=`cat version.json |
122       python3 -c "import json,sys; print(json.load(sys.stdin)['version'])"`
123     - if [[ $GROMACS_RELEASE != "true" ]] ; then
124       VERSION=$VERSION-dev ;
125       fi
126     - REGTEST_COMPARE=`cat version.json |
127       python3 -c "import json,sys; print(json.load(sys.stdin)['regressiontest-md5sum'])"`
128     - SOURCENAME=gromacs-$VERSION
129     - SOURCETARBALL=$SOURCENAME.tar.gz
130     - REGTESTNAME=regressiontests-$VERSION
131     - REGTESTTARBALL=$REGTESTNAME.tar.gz
132     - SOURCE_MD5SUM=`md5sum $SOURCETARBALL | awk '{print $1}'`
133     - RELEASE_TARBALLS=release-tarballs
134     - rm -rf $RELEASE_TARBALLS $RELEASE_SOURCE $RELEASE_REGRESSIONTESTS && mkdir $RELEASE_TARBALLS
135     - mv $SOURCETARBALL $RELEASE_TARBALLS
136     - mv $REGTESTTARBALL $RELEASE_TARBALLS
137     - cd $RELEASE_TARBALLS
138     # We rename the source and regressiontest directories
139     # to have names for them that don't change for different versions.
140     - tar -xf $SOURCETARBALL
141     - mv $SOURCENAME ../$RELEASE_SOURCE
142     - tar -xf $REGTESTTARBALL
143     - mv $REGTESTNAME ../$RELEASE_REGRESSIONTESTS
144     - rm $SOURCETARBALL $REGTESTTARBALL
145     - cd ..
146     - echo $CMAKE_COMPILER_SCRIPT
147     - echo $CMAKE_EXTRA_OPTIONS
148     - echo $CMAKE_SIMD_OPTIONS
149     - echo $CMAKE_GPU_OPTIONS
150     - echo $CMAKE_MPI_OPTIONS
151     - echo $CMAKE_PRECISION_OPTIONS
152     - echo $CMAKE_BUILD_TYPE_OPTIONS
153     - echo $CMAKE_GMXAPI_OPTIONS
154     - if [[ -d $RELEASE_BUILD_DIR ]] ; then
155       echo "Cleaning up build directory" ;
156       rm -rf $RELEASE_BUILD_DIR && mkdir $RELEASE_BUILD_DIR ;
157       else
158       echo "Preparing new build directory" ;
159       mkdir $RELEASE_BUILD_DIR ;
160       fi
161     - cd $RELEASE_BUILD_DIR
162     - cmake ../$RELEASE_SOURCE/
163       -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
164       $CMAKE_COMPILER_SCRIPT
165       $CMAKE_EXTRA_OPTIONS
166       $CMAKE_SIMD_OPTIONS
167       $CMAKE_MPI_OPTIONS
168       $CMAKE_PRECISION_OPTIONS
169       $CMAKE_BUILD_TYPE_OPTIONS
170       $CMAKE_GPU_OPTIONS
171       $CMAKE_GMXAPI_OPTIONS
172       $REL_OPTION
173       "-DSOURCE_MD5SUM=$SOURCE_MD5SUM"
174       "-DREGRESSIONTEST_PATH=../$RELEASE_REGRESSIONTESTS"
175       -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
176       2>&1 | tee cmakeLog.log
177     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
178     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
179     - cd ..
180   artifacts:
181     name: docs-artifacts-$CI_COMMIT_REF_SLUG
182     when: always
183     expire_in: 1 week
184     paths:
185       - $RELEASE_BUILD_DIR
186       - $RELEASE_REGRESSIONTESTS
187       - $RELEASE_SOURCE
188
189 .configure-docs:
190   extends:
191     - .configure-extends-template
192     - .configure-docs-template
193     - .documentation-before-script-template
194
195 .configure-docs-release:
196   extends:
197     - .configure-extends-template
198     - .configure-docs-release-template
199     - .documentation-before-script-template
200   cache: {}
201
202 configure-docs:
203   extends:
204     - .configure-docs
205   needs:
206     - job: simple-build
207       artifacts: false
208   variables:
209     BUILD_DIR: build-docs
210     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on
211   except:
212     variables:
213       - $GROMACS_RELEASE
214
215 configure-docs-gmxapi:
216   extends:
217     - .configure-docs
218     - .configure-gmxapi-template
219   needs:
220     - job: simple-build
221       artifacts: false
222   variables:
223     BUILD_DIR: build-docs-gmxapi
224     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on
225   except:
226     variables:
227       - $GROMACS_RELEASE
228
229 .build-docs-binary-template:
230   # Built by admin/dockerfiles/ci-docs-clang
231   # TODO this should be organized more like the current documentation.py script
232   image: gromacs/ci-docs-clang:master
233   script:
234     - cd $BUILD_DIR
235     - cmake --build . --target gmx -- -j8
236     - cd ..
237   artifacts:
238     name: docs-artifacts-$CI_COMMIT_REF_SLUG
239     when: always
240     expire_in: 1 week
241     paths:
242       - $BUILD_DIR
243
244 .build-docs-webpage-template:
245   # Built by admin/dockerfiles/ci-docs-clang
246   # TODO this should be organized more like the current documentation.py script
247   image: gromacs/ci-docs-clang:master
248   variables:
249     KUBERNETES_CPU_LIMIT: 4
250     KUBERNETES_CPU_REQUEST: 2
251     KUBERNETES_MEMORY_LIMIT: 4Gi
252   script:
253     - cd $BUILD_DIR
254     - cmake --build . --target manual -- -j4 | tee docs/manual/all-output.log
255       | grep -i "warning" | grep -v "TeX" | grep -v "Package" || true
256     - cmake --build . --target webpage -- -j4
257     - grep "WARNING:" docs/manual/all-output.log | tee pythonErrors.log || true
258     - grep -i "error" docs/sphinx-*.log | tee sphinxDiagnostics.log || true
259     - grep -i "warning" docs/sphinx-*.log | tee -a sphinxDiagnostics.log || true
260     - if [ -s pythonErrors.log ] ; then echo "Found Python Errors during build"; exit 1; fi
261     - if [ -s sphinxErrors.log ] ; then echo "Found errors during Sphinx documentation build"; cat sphinxErrors.log; exit 1; fi
262     - if [ -s sphinxDiagnostics.log ] ; then echo "Found diagnostic warnings during Sphinx documentation build"; cat sphinxDiagnostics.log; exit 1; fi
263     - cd ..
264   artifacts:
265     name: docs-artifacts-$CI_COMMIT_REF_SLUG
266     when: always
267     expire_in: 1 week
268     paths:
269       - $BUILD_DIR/*.log
270       - $BUILD_DIR/docs/html
271       - $BUILD_DIR/docs/manual/gromacs.log
272       - $BUILD_DIR/docs/manual/all-output.log
273       - $BUILD_DIR/docs/doxygen/doxygen-user.log
274       - $BUILD_DIR/docs/doxygen/doxygen-lib.log
275       - $BUILD_DIR/docs/doxygen/doxygen-full.log
276       - $BUILD_DIR/docs/sphinx-html.log
277
278 .build-docs-binary:
279   extends:
280     - .build-extends-template
281     - .use-ccache
282     - .build-docs-binary-template
283     - .documentation-before-script-template
284
285 .build-docs-webpage:
286   extends:
287     - .binary-build-template
288     - .variables:default
289     - .build-docs-webpage-template
290     - .documentation-before-script-template
291
292 build-docs:
293   extends:
294     - .build-docs-binary
295   stage: documentation
296   needs:
297     - job: simple-build
298       artifacts: false
299     - job: configure-docs
300       artifacts: true
301   variables:
302     BUILD_DIR: build-docs
303   except:
304     variables:
305       - $GROMACS_RELEASE
306
307 build-docs-gmxapi:
308   extends:
309     - .build-docs-binary
310     - .gmxapi-extra-installs
311   stage: documentation
312   needs:
313     - job: simple-build
314       artifacts: false
315     - job: configure-docs-gmxapi
316       artifacts: true
317   variables:
318     BUILD_DIR: build-docs-gmxapi
319   except:
320     variables:
321       - $GROMACS_RELEASE
322
323
324 # The manual build is built separately so that errors in converting
325 # Sphinx to LaTeX and compiling can always be found in the
326 # all-output.txt file, while avoiding many thousands of lines of spam
327 # from pdflatex for normal builds. This does reduce the available
328 # parallel utilization, and so increases the build time.
329 #
330 # TODO why are the doxygen and sphinx log files disappearing
331 # TODO use a feature from gitlab runner instead of using pipefail to get timings for the job
332 webpage:
333   extends:
334     - .build-docs-webpage
335   stage: post-test
336   needs:
337     - job: build-docs
338       artifacts: true
339     - job: run-check-source
340       artifacts: false
341   variables:
342     BUILD_DIR: build-docs
343   except:
344     variables:
345       - $GROMACS_RELEASE
346
347 webpage-gmxapi:
348   extends:
349     - .build-docs-webpage
350     - .gmxapi-extra-installs
351   stage: post-test
352   needs:
353     - job: build-docs-gmxapi
354       artifacts: true
355     - job: run-check-source
356       artifacts: false
357   variables:
358     BUILD_DIR: build-docs-gmxapi
359   except:
360     variables:
361       - $GROMACS_RELEASE
362
363 webpage-nightly:
364   extends:
365     - .build-docs-webpage
366     - .configure-gmxapi-template
367   stage: nightly-deploy
368   only:
369     - triggers
370     - schedules
371   except:
372     variables:
373       - $GROMACS_RELEASE
374   needs:
375     - job: simple-build
376       artifacts: false
377     - job: linkchecker
378       artifacts: false
379     - job: webpage-gmxapi
380       artifacts: true
381   variables:
382     BUILD_DIR: build-docs-gmxapi
383   script:
384     - tar czf webpage.tar.gz $BUILD_DIR/docs/html/
385   artifacts:
386     when: always
387     paths:
388       - webpage.tar.gz
389
390 webpage-configure-release:
391   extends:
392     - .configure-docs-release
393     - .configure-gmxapi-template
394   cache: {}
395   only:
396     refs:
397       - web
398       - schedules
399       - triggers
400     variables:
401       - $GROMACS_RELEASE
402   dependencies:
403     - package-archive-release
404     - package-regressiontests-release
405     - prepare-release-version
406   variables:
407     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on
408
409
410 webpage-binary-release:
411   extends:
412     - .build-docs-binary
413     - .gmxapi-extra-installs
414   stage: release-build
415   needs:
416     - job: webpage-configure-release
417       artifacts: true
418   variables:
419     BUILD_DIR: release-doc-builds
420   only:
421     refs:
422       - triggers
423       - web
424       - schedules
425     variables:
426       - $GROMACS_RELEASE
427
428 webpage-build-release:
429   extends:
430     - .build-docs-webpage
431     - .configure-gmxapi-template
432   dependencies:
433     - webpage-binary-release
434     - webpage-configure-release
435   stage: release-prepare-deploy
436   only:
437     refs:
438       - web
439       - schedules
440       - triggers
441     variables:
442       - $GROMACS_RELEASE
443   variables:
444     BUILD_DIR: release-doc-builds