Prepare changes to docker images for python packages
[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-18.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-18.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     - cmake ../$RELEASE_SOURCE/
154       -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
155       $CMAKE_COMPILER_SCRIPT
156       $CMAKE_EXTRA_OPTIONS
157       $CMAKE_SIMD_OPTIONS
158       $CMAKE_MPI_OPTIONS
159       $CMAKE_PRECISION_OPTIONS
160       $CMAKE_BUILD_TYPE_OPTIONS
161       $CMAKE_GPU_OPTIONS
162       $CMAKE_GMXAPI_OPTIONS
163       $REL_OPTION
164       "-DSOURCE_MD5SUM=$SOURCE_MD5SUM"
165       "-DREGRESSIONTEST_PATH=../$RELEASE_REGRESSIONTESTS"
166       -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
167       2>&1 | tee cmakeLog.log
168     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
169     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
170     - cd ..
171   artifacts:
172     name: docs-artifacts-$CI_COMMIT_REF_SLUG
173     when: always
174     expire_in: 1 week
175     paths:
176       - $RELEASE_BUILD_DIR
177       - $RELEASE_REGRESSIONTESTS
178       - $RELEASE_SOURCE
179
180 docs:configure:
181   extends:
182     - .docs:configure
183     - .rules:basic-push
184   variables:
185     BUILD_DIR: build-docs
186     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on -DGMX_USE_SIMD_KERNELS=off
187
188 .docs:build:
189   # TODO (#3480) this should be organized more like the current documentation.py script
190   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-7-docs
191   script:
192     - cd $BUILD_DIR
193     - cmake --build . --target gmx -- -j8
194     - cd ..
195   artifacts:
196     name: docs-artifacts-$CI_COMMIT_REF_SLUG
197     when: always
198     expire_in: 1 week
199     paths:
200       - $BUILD_DIR
201
202 docs:build:
203   extends:
204     - .variables:default
205     - .gromacs:base:build
206     - .use-ccache
207     - .docs:build
208     - .before_script:default
209     - .rules:basic-push
210   stage: documentation
211   needs:
212     - job: docs:configure
213   variables:
214     BUILD_DIR: build-docs
215
216 # The manual build is built separately so that errors in converting
217 # Sphinx to LaTeX and compiling can always be found in the
218 # all-output.txt file, while avoiding many thousands of lines of spam
219 # from pdflatex for normal builds. This does reduce the available
220 # parallel utilization, and so increases the build time.
221 #
222 # TODO why are the doxygen and sphinx log files disappearing
223 # TODO use a feature from gitlab runner instead of using pipefail to get timings for the job
224 .webpage:build:
225   extends:
226     - .variables:default
227     - .gromacs:base:build
228     - .before_script:default
229   # TODO (#3480) this should be organized more like the current documentation.py script
230   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-7-docs
231   cache: {}
232   variables:
233     KUBERNETES_CPU_LIMIT: 4
234     KUBERNETES_CPU_REQUEST: 2
235     KUBERNETES_MEMORY_REQUEST: 4Gi
236   script:
237     - cd $BUILD_DIR
238     - cmake --build . --target manual -- -j4 | tee docs/manual/all-output.log
239       | grep -i "warning" | grep -v "TeX" | grep -v "Package" || true
240     - cmake --build . --target webpage -- -j4
241     - grep "WARNING:" docs/manual/all-output.log | tee pythonErrors.log || true
242     - grep -i "error" docs/sphinx-*.log | tee sphinxDiagnostics.log || true
243     - grep -i "warning" docs/sphinx-*.log | tee -a sphinxDiagnostics.log || true
244     - if [ -s pythonErrors.log ] ; then echo "Found Python Errors during build"; exit 1; fi
245     - if [ -s sphinxErrors.log ] ; then echo "Found errors during Sphinx documentation build"; cat sphinxErrors.log; exit 1; fi
246     - if [ -s sphinxDiagnostics.log ] ; then echo "Found diagnostic warnings during Sphinx documentation build"; cat sphinxDiagnostics.log; exit 1; fi
247     - cd ..
248   artifacts:
249     name: docs-artifacts-$CI_COMMIT_REF_SLUG
250     when: always
251     expire_in: 1 week
252     paths:
253       - $BUILD_DIR/*.log
254       - $BUILD_DIR/docs/html
255       - $BUILD_DIR/docs/manual/gromacs.log
256       - $BUILD_DIR/docs/manual/all-output.log
257       - $BUILD_DIR/docs/doxygen/doxygen-user.log
258       - $BUILD_DIR/docs/doxygen/doxygen-lib.log
259       - $BUILD_DIR/docs/doxygen/doxygen-full.log
260       - $BUILD_DIR/docs/sphinx-html.log
261
262 webpage:build:
263   extends:
264     - .webpage:build
265     - .rules:basic-push
266   stage: post-test
267   needs:
268     - job: docs:build
269     - job: check-source
270       artifacts: false
271   variables:
272     BUILD_DIR: build-docs
273
274 webpage:configure:
275   extends:
276     - .docs:configure:release
277     - .rules:nightly-only-for-release
278   cache: {}
279   tags:
280     - k8s-scilifelab
281   dependencies:
282     - archive:package
283     - regressiontests:package
284     - prepare-release-version
285   variables:
286     CMAKE_EXTRA_OPTIONS: -DGMX_BUILD_HELP=on -DGMX_BUILD_MANUAL=on -DGMX_USE_SIMD_KERNELS=off
287
288
289 webpage:dependencies:
290   extends:
291     - .gromacs:base:build
292     - .variables:default
293     - .use-ccache
294     - .docs:build
295     - .before_script:default
296     - .rules:nightly-only-for-release
297   stage: release-build
298   tags:
299     - k8s-scilifelab
300   needs:
301     - job: webpage:configure
302   variables:
303     BUILD_DIR: release-doc-builds
304
305 webpage:build:release:
306   extends:
307     - .webpage:build
308     - .rules:nightly-only-for-release
309   stage: release-prepare-deploy
310   tags:
311     - k8s-scilifelab
312   dependencies:
313     - webpage:dependencies
314     - webpage:configure
315   variables:
316     BUILD_DIR: release-doc-builds