d4cab7cd44b3e03ce105e47955c5636ad4c4a446
[alexxy/gromacs.git] / admin / ci-templates / .build-template.yml
1 .configure-build-template:
2   # Docker image uploaded to dockerhub by user eriklindahl
3   # TODO: Get DockerFile for admin/dockerfiles
4   stage: configure-build
5   image: biophysics/gcc-gromacs
6   variables:
7     KUBERNETES_CPU_LIMIT: 1
8     KUBERNETES_CPU_REQUEST: 1
9     KUBERNETES_MEMORY_LIMIT: 2Gi
10     CMAKE_COMPILER_SCRIPT: ""
11     CMAKE_EXTRA_OPTIONS: ""
12     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=AUTO"
13     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
14     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
15     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
16     CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
17     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
18
19   script:
20     - echo $CMAKE_COMPILER_SCRIPT
21     - echo $CMAKE_EXTRA_OPTIONS
22     - echo $CMAKE_SIMD_OPTIONS
23     - echo $CMAKE_GPU_OPTIONS
24     - echo $CMAKE_MPI_OPTIONS
25     - echo $CMAKE_PRECISION_OPTIONS
26     - echo $CMAKE_BUILD_TYPE_OPTIONS
27     - echo $CMAKE_GMXAPI_OPTIONS
28     - if [[ -d $BUILD_DIR ]] ; then
29         rm -rf $BUILD_DIR && mkdir $BUILD_DIR ;
30       else
31         echo "Preparing new build directory" ;
32         mkdir $BUILD_DIR ;
33       fi
34     - cd $BUILD_DIR
35     - cmake ..
36         -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
37         $CMAKE_COMPILER_SCRIPT
38         $CMAKE_EXTRA_OPTIONS
39         $CMAKE_SIMD_OPTIONS
40         $CMAKE_MPI_OPTIONS
41         $CMAKE_PRECISION_OPTIONS
42         $CMAKE_BUILD_TYPE_OPTIONS
43         $CMAKE_GPU_OPTIONS
44         $CMAKE_GMXAPI_OPTIONS
45         -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
46         2>&1 | tee cmakeLog.log
47     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
48     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
49     - cd ..
50   artifacts:
51     when: always
52     paths:
53       - $BUILD_DIR
54
55 .configure-build-release-template:
56   # Dockerfiles are from dockerhub, user eriklindahl
57   # image in admin/dockerimages/ci-docs-py27
58   stage: release-configure
59   image: biophysics/gcc-gromacs
60   variables:
61     KUBERNETES_CPU_LIMIT: 1
62     KUBERNETES_CPU_REQUEST: 1
63     KUBERNETES_MEMORY_LIMIT: 2Gi
64     CMAKE_COMPILER_SCRIPT: ""
65     CMAKE_EXTRA_OPTIONS: ""
66     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=AUTO"
67     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
68     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
69     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=RelWithAssert"
70     CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
71     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
72     RELEASE_BUILD_DIR: release-builds
73     RELEASE_SOURCE: release-source-from-tarball
74     RELEASE_REGRESSIONTESTS: release-regressiontests-from-tarball
75
76   only:
77     refs:
78       - web
79       - schedules
80       - triggers
81     variables:
82       - $GROMACS_RELEASE
83   script:
84     - VERSION=`cat version.json |
85         python3 -c "import json,sys; print(json.load(sys.stdin)['version'])"`
86     - if [[ $GROMACS_RELEASE != "true" ]] ; then
87           VERSION=$VERSION-dev ;
88       fi
89     - SOURCENAME=gromacs-$VERSION
90     - SOURCETARBALL=$SOURCENAME.tar.gz
91     - REGTESTNAME=regressiontests-$VERSION
92     - REGTESTTARBALL=$REGTESTNAME.tar.gz
93     - echo "$SOURCETARBALL"
94     - echo "$REGTESTTARBALL"
95     - RELEASE_TARBALLS=release-tarballs
96     - rm -rf $RELEASE_TARBALLS $RELEASE_SOURCE $RELEASE_REGRESSIONTESTS && mkdir $RELEASE_TARBALLS
97     - mv $SOURCETARBALL $RELEASE_TARBALLS
98     - mv $REGTESTTARBALL $RELEASE_TARBALLS
99     - cd $RELEASE_TARBALLS
100 # We rename the source and regressiontest directories
101 # to have names for them that don't change for different versions.
102     - tar -xf $SOURCETARBALL
103     - mv $SOURCENAME ../$RELEASE_SOURCE
104     - tar -xf $REGTESTTARBALL
105     - mv $REGTESTNAME ../$RELEASE_REGRESSIONTESTS
106     - rm $SOURCETARBALL $REGTESTTARBALL
107     - cd ..
108     - echo $CMAKE_COMPILER_SCRIPT
109     - echo $CMAKE_EXTRA_OPTIONS
110     - echo $CMAKE_SIMD_OPTIONS
111     - echo $CMAKE_GPU_OPTIONS
112     - echo $CMAKE_MPI_OPTIONS
113     - echo $CMAKE_PRECISION_OPTIONS
114     - echo $CMAKE_BUILD_TYPE_OPTIONS
115     - echo $CMAKE_GMXAPI_OPTIONS
116     - if [[ -d $RELEASE_BUILD_DIR ]] ; then
117         echo "Cleaning up build directory" ;
118         rm -rf $RELEASE_BUILD_DIR && mkdir $RELEASE_BUILD_DIR ;
119       else
120         echo "Preparing new build directory" ;
121         mkdir $RELEASE_BUILD_DIR ;
122       fi
123     - cd $RELEASE_BUILD_DIR
124     - cmake ../$RELEASE_SOURCE/
125         -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
126         $CMAKE_COMPILER_SCRIPT
127         $CMAKE_EXTRA_OPTIONS
128         $CMAKE_SIMD_OPTIONS
129         $CMAKE_MPI_OPTIONS
130         $CMAKE_PRECISION_OPTIONS
131         $CMAKE_BUILD_TYPE_OPTIONS
132         $CMAKE_GPU_OPTIONS
133         $CMAKE_GMXAPI_OPTIONS
134         "-DREGRESSIONTEST_PATH=../$RELEASE_REGRESSIONTESTS"
135         -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
136         2>&1 | tee cmakeLog.log
137     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
138     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
139     - cd ..
140   artifacts:
141     when: always
142     paths:
143       - $RELEASE_BUILD_DIR
144       - $RELEASE_REGRESSIONTESTS
145       - $RELEASE_SOURCE
146
147 .binary-build-template:
148   # Dockerfiles are from dockerhub, user eriklindahl
149   # image in admin/dockerimages/ci-docs-py27
150   stage: build
151   image: biophysics/gcc-gromacs
152   variables:
153
154   script:
155     - cd $BUILD_DIR
156     - cmake --build . -- -j8 2>&1 | tee buildLogFile.log
157     - cmake --build . --target tests -- -j8 2>&1 | tee testBuildLogFile.log
158     - awk '/warning/,/warning.*generated|^$/' buildLogFile.log testBuildLogFile.log
159       | grep -v "CMake" | tee buildErrors.log || true
160     - grep "cannot be built" buildLogFile.log testBuildLogFile.log | tee -a buildErrors.log || true
161     - cmake --build . --target install 2>&1 | tee installBuildLogFile.log
162     - if [ -s buildErrors.log ] ; then echo "Found compiler warning during build"; cat buildErrors.log; exit 1; fi
163     - cd ..
164   artifacts:
165     when: always
166     paths:
167       - $BUILD_DIR
168       - $INSTALL_DIR/
169
170 # Right now we need to use an ugly hack to move the original build directory
171 # and the ccache files out of the build archive, as it is not possible to use
172 # the custom build directory due to https://gitlab.com/gitlab-org/gitlab-runner/issues/4203
173 # As soon as this is resolved we should use the separate build directories instead of
174 # manually hacking things. TODO
175 # Redmine #3361
176 .archive-build-template:
177   # Dockerfiles are from dockerhub, user eriklindahl
178   image: gromacs/ci-docs-clang:master
179   variables:
180     KUBERNETES_CPU_LIMIT: 4
181     KUBERNETES_CPU_REQUEST: 2
182     KUBERNETES_MEMORY_LIMIT: 4Gi
183   script:
184     - rm -rf gromacs*tar.gz
185     - cd $BUILD_DIR
186     - cmake --build . --target gmx -- -j4 2>&1 | tee buildLogFile.log
187     - cmake --build . --target man -- -j4 2>&1 | tee manBuildLogFile.log
188     - cmake --build . --target completion -- -j4 2>&1 | tee completionBuildLogFile.log
189     - cmake --build . --target install-guide -- -j4 2>&1 | tee installGuideBuildLogFile.log
190     - cmake --build . --target reference_checksum -- -j4 2>&1 | tee checksumBuildLogFile.log
191     - cmake --build . --target package_source -- -j4 2>&1 | tee packageBuildLogFile.log
192     - awk '/warning/,/warning.*generated|^$/' buildLogFile.log manBuildLogFile.log 
193       completionBuildLogFile.log installGuideBuildLogFile.log checksumBuildLogFile.log
194       packageBuildLogFile.log | grep -v "CMake" | tee buildErrors.log || true
195     - grep "cannot be built" buildLogFile.log manBuildLogFile.log 
196       completionBuildLogFile.log installGuideBuildLogFile.log checksumBuildLogFile.log
197       packageBuildLogFile.log | tee -a buildErrors.log || true 
198     - if [ -s buildErrors.log ] ; then echo "Found warnings during build"; cat buildErrors.log; exit 1; fi
199     - mv gromacs*tar.gz ..
200     - cd ..
201     # ugly hack begins here
202     - mkdir tempdir
203     - SOURCETARBALL=`ls gromacs*tar.gz`
204     - mv $SOURCETARBALL tempdir
205     - cd tempdir
206     - tar -xf $SOURCETARBALL
207     - rm -rf gromacs-*/$BUILD_DIR
208     - tar -c --gzip -f $SOURCETARBALL gromacs-*/
209     - mv $SOURCETARBALL ..
210     - cd ..
211     - rm -rf tempdir
212     # Hack ends here
213   artifacts:
214     when: always
215     expire_in: 1 week
216     paths:
217       - $BUILD_DIR/*log
218       - gromacs*tar.gz
219
220
221 .simple-build-template:
222   # Docker images are from dockerhub, user eriklindahl
223   stage: pre-build
224   image: biophysics/gcc-gromacs
225   variables:
226     KUBERNETES_CPU_LIMIT: 8
227     KUBERNETES_CPU_REQUEST: 4
228     KUBERNETES_MEMORY_LIMIT: 8Gi
229     CMAKE_COMPILER_SCRIPT: ""
230     CMAKE_EXTRA_OPTIONS: ""
231     CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=None"
232     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
233     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
234     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
235     CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
236     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
237
238   script:
239     - echo $CMAKE_COMPILER_SCRIPT
240     - echo $CMAKE_EXTRA_OPTIONS
241     - echo $CMAKE_SIMD_OPTIONS
242     - echo $CMAKE_GPU_OPTIONS
243     - echo $CMAKE_MPI_OPTIONS
244     - echo $CMAKE_PRECISION_OPTIONS
245     - echo $CMAKE_BUILD_TYPE_OPTIONS
246     - echo $CMAKE_GMXAPI_OPTIONS
247     - if [[ -d $BUILD_DIR ]] ; then
248         echo "Cleaning up build directory" ;
249         rm -rf $BUILD_DIR && mkdir $BUILD_DIR ;
250       else
251         echo "Preparing new build directory" ;
252         mkdir $BUILD_DIR ;
253       fi
254     - cd $BUILD_DIR
255     - cmake ..
256         -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
257         $CMAKE_COMPILER_SCRIPT
258         $CMAKE_EXTRA_OPTIONS
259         $CMAKE_SIMD_OPTIONS
260         $CMAKE_MPI_OPTIONS
261         $CMAKE_PRECISION_OPTIONS
262         $CMAKE_BUILD_TYPE_OPTIONS
263         $CMAKE_GPU_OPTIONS
264         $CMAKE_GMXAPI_OPTIONS
265         -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR -DGMX_COMPILER_WARNINGS=ON
266         2>&1 | tee cmakeLog.log
267     - awk '/CMake Warning/,/^--|^$/' cmakeLog.log | tee cmakeErrors.log
268     - if [ -s cmakeErrors.log  ] ; then echo "Found CMake warning while processing build"; cat cmakeErrors.log ; exit 1; fi
269     - cmake --build . -- -j8 2>&1 | tee buildLogFile.log
270     - cmake --build . --target tests -- -j8 2>&1 | tee testBuildLogFile.log
271     - awk '/warning/,/warning.*generated|^$/' buildLogFile.log testBuildLogFile.log
272       | grep -v "CMake" | tee buildErrors.log || true
273     - grep "cannot be built" buildLogFile.log testBuildLogFile.log | tee -a buildErrors.log || true
274     - cmake --build . --target install 2>&1 | tee installBuildLogFile.log
275     - if [ -s buildErrors.log ] ; then echo "Found compiler warning during build"; cat buildErrors.log; exit 1; fi
276     - ctest -D ExperimentalTest --output-on-failure | tee ctestLog.log || true
277     - awk '/The following tests FAILED/,/^Errors while running CTest|^$/'
278          ctestLog.log | tee ctestErrors.log
279     - xsltproc scripts/CTest2JUnit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > JUnitTestResults.xml
280     - if [ -s ctestErrors.log ] ; then
281         echo "Error during running ctest";
282         exit 1;
283       fi
284     - cd ..
285   artifacts:
286     reports:
287       junit: $BUILD_DIR/JUnitTestResults.xml
288     paths:
289         - $BUILD_DIR/*log
290     when: always
291     expire_in: 1 week