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