Handle gmxapi tmpi parameters better.
[alexxy/gromacs.git] / admin / ci-scripts / build-and-test-sample_restraint-2021.sh
1 #!/usr/bin/env bash
2 #
3 # Build and test the sample_restraint package distributed with GROMACS 2021.
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 # Create "sdist" source distribution archive.
16 pushd python_packaging/src
17   # TODO: Remove extraneous environment variable with resolution of #3273
18   # Ref: https://redmine.gromacs.org/issues/3273
19   GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
20       python setup.py sdist
21   # TODO: Identify SDIST
22
23   # Build and install from sdist.
24   # Note that tool chain may be provided differently in GROMACS 2020 and 2021.
25   # TODO: How should we distinguish the target branch?
26 #  if [ "2020" -eq "$GROMACS_VERSION" ]; then
27   if [ 1 ]; 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   # TODO: Build and install from $SDIST instead of wildcard.
36   # TODO: How should we distinguish the target branch?
37 #    elif [ "2021" -eq "$GROMACS_VERSION" ]; then
38 #      GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
39 #          python -m pip install \
40 #              --no-cache-dir \
41 #              --no-deps \
42 #              --no-index \
43 #              --no-build-isolation \
44 #              dist/gmxapi*
45   # TODO: Build and install from $SDIST instead of wildcard.
46   else
47       echo "Logic error in GROMACS version handling."
48       exit 1
49   fi
50 popd
51
52 . $INSTALL_DIR/bin/GMXRC
53 pushd python_packaging/sample_restraint
54   mkdir build
55   pushd build
56     # TODO: Update with respect to https://redmine.gromacs.org/issues/3133
57     cmake .. \
58              -DDOWNLOAD_GOOGLETEST=ON \
59              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON
60     make
61
62     make test
63     #TODO: Can we get ctest JUnitXML output here?
64
65     make install
66   popd
67
68   python -m pytest $PWD/tests --junitxml=$PLUGIN_TEST_XML --threads=2
69
70   # Note: Multiple pytest processes getting --junitxml output file argument
71   # may cause problems, so we set the option on only one of the launched processes.
72   # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
73   # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
74   PROGRAM=(`which python` -m mpi4py -m pytest \
75           -p no:cacheprovider \
76           $PWD/tests \
77           --threads=1)
78   # shellcheck disable=SC2068
79   if [ -x `which mpiexec` ]; then
80       PYTHONDONTWRITEBYTECODE=1 \
81       mpiexec --allow-run-as-root \
82         -x OMP_NUM_THREADS=1 \
83         --mca opal_warn_on_missing_libcuda 0 \
84         --mca orte_base_help_aggregate 0 \
85         -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
86         -n 1 ${PROGRAM[@]}
87   fi
88 popd