4087a7c8cb5a891574504e3f5fc52b994c918848
[alexxy/gromacs.git] / admin / gitlab-ci / documentation.gitlab-ci.yml
1 # Build documentation and web page.
2
3 .docs:configure:
4   extends:
5     - .variables:default
6     - .gromacs:base:configure
7     - .before_script:default
8   # TODO (#3480) this should be organized more like the current documentation.py script
9   image: gromacs/ci-docs-llvm-master
10   stage: configure-build
11   cache: {}
12   variables:
13     KUBERNETES_CPU_LIMIT: 1
14     KUBERNETES_CPU_REQUEST: 1
15     KUBERNETES_MEMORY_REQUEST: 2Gi
16     CMAKE_COMPILER_SCRIPT: "-DCMAKE_C_COMPILER=clang-7 -DCMAKE_CXX_COMPILER=clang++-7"
17     CMAKE_EXTRA_OPTIONS: ""
18     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=None"
19     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=OFF"
20     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
21     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
22     CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
23     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=ON"
24   script:
25     - if [[ ! -z $GROMACS_RELEASE && $GROMACS_RELEASE == "true" ]] ; then
26       REL_OPTION="-DGMX_BUILD_TARBALL=ON" ;
27       else
28       REL_OPTION="-DGMX_BUILD_TARBALL=OFF" ;
29       fi
30     - echo $CMAKE_COMPILER_SCRIPT
31     - echo $CMAKE_EXTRA_OPTIONS
32     - echo $CMAKE_SIMD_OPTIONS
33     - echo $CMAKE_GPU_OPTIONS
34     - echo $CMAKE_MPI_OPTIONS
35     - echo $CMAKE_PRECISION_OPTIONS
36     - echo $CMAKE_BUILD_TYPE_OPTIONS
37     - echo $CMAKE_GMXAPI_OPTIONS
38     - echo $REL_OPTION
39     - if [[ -d $BUILD_DIR ]] ; then
40       rm -rf $BUILD_DIR && mkdir $BUILD_DIR ;
41       else
42       echo "Preparing new build directory" ;
43       mkdir $BUILD_DIR ;
44       fi
45     - cd $BUILD_DIR
46     - cmake ..
47       -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
48       $CMAKE_COMPILER_SCRIPT
49       $CMAKE_EXTRA_OPTIONS
50       $CMAKE_SIMD_OPTIONS
51       $CMAKE_MPI_OPTIONS
52       $CMAKE_PRECISION_OPTIONS
53       $CMAKE_BUILD_TYPE_OPTIONS
54       $CMAKE_GPU_OPTIONS
55       $CMAKE_GMXAPI_OPTIONS
56       $REL_OPTION
57       -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
58       2>&1 | tee cmakeLog.log
59     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
60     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
61     - cd ..
62   artifacts:
63     name: docs-artifacts-$CI_COMMIT_REF_SLUG
64     when: always
65     expire_in: 1 week
66     paths:
67       - $BUILD_DIR
68
69 .docs:configure:release:
70   extends:
71     - .variables:default
72     - .gromacs:base:configure
73     - .before_script:default
74     - .rules:nightly-only-for-release
75   # TODO (#3480) this should be organized more like the current documentation.py script
76   image: gromacs/ci-docs-llvm-master
77   stage: release-configure
78   cache: {}
79   variables:
80     KUBERNETES_CPU_LIMIT: 1
81     KUBERNETES_CPU_REQUEST: 1
82     KUBERNETES_MEMORY_REQUEST: 2Gi
83     CMAKE_COMPILER_SCRIPT: "-DCMAKE_C_COMPILER=clang-7 -DCMAKE_CXX_COMPILER=clang++-7"
84     CMAKE_EXTRA_OPTIONS: ""
85     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=None"
86     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
87     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
88     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
89     CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
90     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=ON"
91     RELEASE_BUILD_DIR: release-doc-builds
92     RELEASE_SOURCE: release-source-from-tarball
93     RELEASE_REGRESSIONTESTS: release-regressiontests-from-tarball
94   script:
95     - if [[ $GROMACS_RELEASE == "true" ]] ; then
96       REL_OPTION="-DGMX_BUILD_TARBALL=ON" ;
97       else
98       REL_OPTION="-DGMX_BUILD_TARBALL=OFF" ;
99       fi
100     - echo $CMAKE_COMPILER_SCRIPT
101     - echo $CMAKE_EXTRA_OPTIONS
102     - echo $CMAKE_SIMD_OPTIONS
103     - echo $CMAKE_GPU_OPTIONS
104     - echo $CMAKE_MPI_OPTIONS
105     - echo $CMAKE_PRECISION_OPTIONS
106     - echo $CMAKE_BUILD_TYPE_OPTIONS
107     - echo $CMAKE_GMXAPI_OPTIONS
108     - echo $REL_OPTION
109     - VERSION=`cat version.json |
110       python3 -c "import json,sys; print(json.load(sys.stdin)['version'])"`
111     - if [[ $GROMACS_RELEASE != "true" ]] ; then
112       VERSION=$VERSION-dev ;
113       fi
114     - REGTEST_COMPARE=`cat version.json |
115       python3 -c "import json,sys; print(json.load(sys.stdin)['regressiontest-md5sum'])"`
116     - SOURCENAME=gromacs-$VERSION
117     - SOURCETARBALL=$SOURCENAME.tar.gz
118     - REGTESTNAME=regressiontests-$VERSION
119     - REGTESTTARBALL=$REGTESTNAME.tar.gz
120     - SOURCE_MD5SUM=`md5sum $SOURCETARBALL | awk '{print $1}'`
121     - RELEASE_TARBALLS=release-tarballs
122     - rm -rf $RELEASE_TARBALLS $RELEASE_SOURCE $RELEASE_REGRESSIONTESTS && mkdir $RELEASE_TARBALLS
123     - mv $SOURCETARBALL $RELEASE_TARBALLS
124     - mv $REGTESTTARBALL $RELEASE_TARBALLS
125     - cd $RELEASE_TARBALLS
126     # We rename the source and regressiontest directories
127     # to have names for them that don't change for different versions.
128     - tar -xf $SOURCETARBALL
129     - mv $SOURCENAME ../$RELEASE_SOURCE
130     - tar -xf $REGTESTTARBALL
131     - mv $REGTESTNAME ../$RELEASE_REGRESSIONTESTS
132     - rm $SOURCETARBALL $REGTESTTARBALL
133     - cd ..
134     - echo $CMAKE_COMPILER_SCRIPT
135     - echo $CMAKE_EXTRA_OPTIONS
136     - echo $CMAKE_SIMD_OPTIONS
137     - echo $CMAKE_GPU_OPTIONS
138     - echo $CMAKE_MPI_OPTIONS
139     - echo $CMAKE_PRECISION_OPTIONS
140     - echo $CMAKE_BUILD_TYPE_OPTIONS
141     - echo $CMAKE_GMXAPI_OPTIONS
142     - if [[ -d $RELEASE_BUILD_DIR ]] ; then
143       echo "Cleaning up build directory" ;
144       rm -rf $RELEASE_BUILD_DIR && mkdir $RELEASE_BUILD_DIR ;
145       else
146       echo "Preparing new build directory" ;
147       mkdir $RELEASE_BUILD_DIR ;
148       fi
149     - cd $RELEASE_BUILD_DIR
150     - cmake ../$RELEASE_SOURCE/
151       -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
152       $CMAKE_COMPILER_SCRIPT
153       $CMAKE_EXTRA_OPTIONS
154       $CMAKE_SIMD_OPTIONS
155       $CMAKE_MPI_OPTIONS
156       $CMAKE_PRECISION_OPTIONS
157       $CMAKE_BUILD_TYPE_OPTIONS
158       $CMAKE_GPU_OPTIONS
159       $CMAKE_GMXAPI_OPTIONS
160       $REL_OPTION
161       "-DSOURCE_MD5SUM=$SOURCE_MD5SUM"
162       "-DREGRESSIONTEST_PATH=../$RELEASE_REGRESSIONTESTS"
163       -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
164       2>&1 | tee cmakeLog.log
165     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
166     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
167     - cd ..
168   artifacts:
169     name: docs-artifacts-$CI_COMMIT_REF_SLUG
170     when: always
171     expire_in: 1 week
172     paths:
173       - $RELEASE_BUILD_DIR
174       - $RELEASE_REGRESSIONTESTS
175       - $RELEASE_SOURCE
176
177 docs:configure:
178   extends:
179     - .docs:configure
180     - .rules:basic-push
181   variables:
182     BUILD_DIR: build-docs
183     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on
184
185 .docs:build:
186   # TODO (#3480) this should be organized more like the current documentation.py script
187   image: gromacs/ci-docs-llvm-master
188   script:
189     - cd $BUILD_DIR
190     - cmake --build . --target gmx -- -j8
191     - cd ..
192   artifacts:
193     name: docs-artifacts-$CI_COMMIT_REF_SLUG
194     when: always
195     expire_in: 1 week
196     paths:
197       - $BUILD_DIR
198
199 docs:build:
200   extends:
201     - .variables:default
202     - .gromacs:base:build
203     - .use-ccache
204     - .docs:build
205     - .before_script:default
206     - .rules:basic-push
207   stage: documentation
208   needs:
209     - job: docs:configure
210   variables:
211     BUILD_DIR: build-docs
212
213 # The manual build is built separately so that errors in converting
214 # Sphinx to LaTeX and compiling can always be found in the
215 # all-output.txt file, while avoiding many thousands of lines of spam
216 # from pdflatex for normal builds. This does reduce the available
217 # parallel utilization, and so increases the build time.
218 #
219 # TODO why are the doxygen and sphinx log files disappearing
220 # TODO use a feature from gitlab runner instead of using pipefail to get timings for the job
221 .webpage:build:
222   extends:
223     - .variables:default
224     - .gromacs:base:build
225     - .before_script:default
226   # TODO (#3480) this should be organized more like the current documentation.py script
227   image: gromacs/ci-docs-llvm-master
228   cache: {}
229   variables:
230     KUBERNETES_CPU_LIMIT: 4
231     KUBERNETES_CPU_REQUEST: 2
232     KUBERNETES_MEMORY_REQUEST: 4Gi
233   script:
234     - cd $BUILD_DIR
235     - cmake --build . --target manual -- -j4 | tee docs/manual/all-output.log
236       | grep -i "warning" | grep -v "TeX" | grep -v "Package" || true
237     - cmake --build . --target webpage -- -j4
238     - grep "WARNING:" docs/manual/all-output.log | tee pythonErrors.log || true
239     - grep -i "error" docs/sphinx-*.log | tee sphinxDiagnostics.log || true
240     - grep -i "warning" docs/sphinx-*.log | tee -a sphinxDiagnostics.log || true
241     - if [ -s pythonErrors.log ] ; then echo "Found Python Errors during build"; exit 1; fi
242     - if [ -s sphinxErrors.log ] ; then echo "Found errors during Sphinx documentation build"; cat sphinxErrors.log; exit 1; fi
243     - if [ -s sphinxDiagnostics.log ] ; then echo "Found diagnostic warnings during Sphinx documentation build"; cat sphinxDiagnostics.log; exit 1; fi
244     - cd ..
245   artifacts:
246     name: docs-artifacts-$CI_COMMIT_REF_SLUG
247     when: always
248     expire_in: 1 week
249     paths:
250       - $BUILD_DIR/*.log
251       - $BUILD_DIR/docs/html
252       - $BUILD_DIR/docs/manual/gromacs.log
253       - $BUILD_DIR/docs/manual/all-output.log
254       - $BUILD_DIR/docs/doxygen/doxygen-user.log
255       - $BUILD_DIR/docs/doxygen/doxygen-lib.log
256       - $BUILD_DIR/docs/doxygen/doxygen-full.log
257       - $BUILD_DIR/docs/sphinx-html.log
258
259 webpage:build:
260   extends:
261     - .webpage:build
262     - .rules:basic-push
263   stage: post-test
264   needs:
265     - job: docs:build
266     - job: check-source
267       artifacts: false
268   variables:
269     BUILD_DIR: build-docs
270
271 webpage:configure:
272   extends:
273     - .docs:configure:release
274     - .rules:nightly-only-for-release
275   cache: {}
276   tags:
277     - k8s-scilifelab
278   dependencies:
279     - archive:package
280     - regressiontests:package
281     - prepare-release-version
282   variables:
283     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on
284
285
286 webpage:dependencies:
287   extends:
288     - .gromacs:base:build
289     - .variables:default
290     - .use-ccache
291     - .docs:build
292     - .before_script:default
293     - .rules:nightly-only-for-release
294   stage: release-build
295   tags:
296     - k8s-scilifelab
297   needs:
298     - job: webpage:configure
299   variables:
300     BUILD_DIR: release-doc-builds
301
302 webpage:build:release:
303   extends:
304     - .webpage:build
305     - .rules:nightly-only-for-release
306   stage: release-prepare-deploy
307   tags:
308     - k8s-scilifelab
309   dependencies:
310     - webpage:dependencies
311     - webpage:configure
312   variables:
313     BUILD_DIR: release-doc-builds