a813094c353f7e809667db247a5145644ef37ec9
[alexxy/gromacs.git] / admin / ci-scripts / build-and-test-sample_restraint-2022.sh
1 #!/usr/bin/env bash
2 #
3 # Build and test the sample_restraint package distributed with GROMACS 2022.
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 pushd python_packaging/src
16   # Build and install gmxapi python package from local source.
17   # Note that tool chain may be provided differently across GROMACS versions.
18   if [ "2022" -eq "$GROMACS_MAJOR_VERSION" ]; then
19       GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
20           python -m pip install \
21               --no-cache-dir \
22               --no-deps \
23               --no-index \
24               --no-build-isolation \
25               .
26   # TODO: Get sdist artifact for other gmxapi versions.
27 #    elif [ "2021" -eq "$GROMACS_MAJOR_VERSION" ]; then
28 #      GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
29 #          python -m pip install \
30 #              --no-cache-dir \
31 #              --no-deps \
32 #              --no-index \
33 #              --no-build-isolation \
34 #              dist/gmxapi*
35   else
36       echo "Logic error in GROMACS version handling."
37       exit 1
38   fi
39 popd
40
41 . $INSTALL_DIR/bin/GMXRC
42 pushd python_packaging/sample_restraint
43   mkdir build
44   pushd build
45     # TODO: Update with respect to https://gitlab.com/gromacs/gromacs/-/issues/3133
46     cmake .. \
47              -DDOWNLOAD_GOOGLETEST=ON \
48              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON
49     make
50
51     make test
52     #TODO: Can we get ctest JUnitXML output here?
53
54     make install
55   popd
56
57   python -m pytest $PWD/tests --junitxml=$PLUGIN_TEST_XML --threads=2
58
59   # Note: Multiple pytest processes getting --junitxml output file argument
60   # may cause problems, so we set the option on only one of the launched processes.
61   # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
62   # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
63   PROGRAM=(`which python` -m mpi4py -m pytest \
64           -p no:cacheprovider \
65           $PWD/tests \
66           --threads=1)
67   # shellcheck disable=SC2068
68   if [ -x `which mpiexec` ]; then
69       PYTHONDONTWRITEBYTECODE=1 \
70       mpiexec --allow-run-as-root \
71         -x OMP_NUM_THREADS=1 \
72         --mca opal_warn_on_missing_libcuda 0 \
73         --mca orte_base_help_aggregate 0 \
74         -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
75         -n 1 ${PROGRAM[@]}
76   fi
77 popd