f7bf6eaac261fb4a85437729a55aa89e43f3bebe
[alexxy/gromacs.git] / admin / ci-scripts / build-and-test-sample_restraint-2020.sh
1 #!/usr/bin/env bash
2 #
3 # Build and test the sample_restraint package distributed with GROMACS 2020.
4 #
5 # This script is intended to support automated GROMACS testing infrastructure,
6 # and may be removed without notice.
7 #
8 # WARNING: This script assumes OpenMPI mpiexec. Syntax for launch wrappers from
9 # other implementations will need different syntax, and we should get a
10 # MPIRUNNER from the environment, or something.
11
12 # Make sure the script errors if any commands error.
13 set -e
14
15 # TODO: We should be able to just use a $GMXAPI_0_1_SDIST or venv artifact...
16 pushd python_packaging/src
17   GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
18     python -m pip install \
19         --no-cache-dir \
20         --no-deps \
21         --no-index \
22         --no-build-isolation \
23         .
24 popd
25
26 . $INSTALL_DIR/bin/GMXRC
27 pushd python_packaging/sample_restraint
28   mkdir build
29   pushd build
30     # TODO: Update with respect to https://redmine.gromacs.org/issues/3133
31     cmake .. \
32              -DDOWNLOAD_GOOGLETEST=ON \
33              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON
34     make
35
36     make test
37     #TODO: Can we get ctest JUnitXML output here?
38
39     make install
40   popd
41
42   python -m pytest $PWD/tests --junitxml=$PLUGIN_TEST_XML
43
44   # Note: Multiple pytest processes getting --junitxml output file argument
45   # may cause problems, so we set the option on only one of the launched processes.
46   # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
47   # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
48   PROGRAM=(`which python` -m mpi4py -m pytest \
49           -p no:cacheprovider \
50           $PWD/tests)
51   # shellcheck disable=SC2068
52   if [ -x `which mpiexec` ]; then
53       PYTHONDONTWRITEBYTECODE=1 \
54       mpiexec --allow-run-as-root \
55         --mca opal_warn_on_missing_libcuda 0 \
56         --mca orte_base_help_aggregate 0 \
57         -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
58         -n 1 ${PROGRAM[@]}
59   fi
60 popd