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