Resolve "Automatically run tests in pipelines"

This MR enables automatic testing using ctest, and also updates the CI pipelines so that they run build and test jobs exercising the code. We also add a Dockerfile that builds an appropriate CI environment to build, test, and run Cargo.

Closes #6 (closed)

Edited by Alberto Miranda

Merge request reports

Loading
+133 −0
Changes for docker/0.2.0-wip/Dockerfile: 133 added lines, 0 removed lines.
Original line number Diff line number Diff line
FROM rockylinux:9.2

RUN set -ex \
    && yum makecache \
    && yum -y update \
    && yum -y install dnf-plugins-core \
    && yum config-manager --set-enabled crb \
    && yum -y install \
           gcc \
           gcc-c++\
           gdb \
           git \
           gnupg \
           make \
           automake \
           libtool \
           file \
           ninja-build \
           json-c-devel \
           libibverbs-devel \
           boost-devel \
           boost-openmpi-devel \
           json-c-devel \
           openmpi-devel \
           libconfig-devel \
    # install cmake 3.21+ since we need to produce JUnit XML files
    && curl -OL https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-Linux-x86_64.sh \
    && chmod u+x ./cmake-3.27.6-Linux-x86_64.sh \
    && ./cmake-3.27.6-Linux-x86_64.sh --skip-license --prefix=/usr \
    # cleanup
    && yum clean all \
    && rm -rf /var/cache/yum \
    && rm ./cmake-3.27.6-Linux-x86_64.sh

# Download and install dependencies
RUN set -ex \
    && export LD_LIBRARY_PATH=${DEPS_INSTALL_PATH}/lib:${DEPS_INSTALL_PATH}/lib64 \
    && export PKG_CONFIG_PATH=${DEPS_INSTALL_PATH}/lib/pkgconfig:${DEPS_INSTALL_PATH}/lib64/pkgconfig \
    && cd  \
    && mkdir deps  \
    && cd deps \
    && git clone https://github.com/ofiwg/libfabric --recurse-submodules \
    && git clone https://github.com/pmodels/argobots --recurse-submodules \
    && git clone https://github.com/mercury-hpc/mercury --recurse-submodules \
    && git clone https://github.com/mochi-hpc/mochi-margo --recurse-submodules \
    && git clone https://github.com/USCiLab/cereal --recurse-submodules \
    && git clone https://github.com/mochi-hpc/mochi-thallium --recurse-submodules \
    \
    && cd \
    ### argobots
    && cd deps/argobots \
    && ./autogen.sh \
    && mkdir build  \
    && cd build \
    && CFLAGS="-ggdb3 -O0" ../configure --prefix=${DEPS_INSTALL_PATH} \
    && make install -j \
    && cd ..  \
    && rm -rf build  \
    && cd \
    \
    ### libfabric
    && cd deps/libfabric \
    && git checkout v1.14.0rc3 \
    && ./autogen.sh \
    && mkdir build  \
    && cd build \
    && CFLAGS="-ggdb3 -O0" ../configure --prefix=${DEPS_INSTALL_PATH} \
    && make install -j \
    && cd ..  \
    && rm -rf build  \
    && cd \
    \
    ### mercury
    && cd deps/mercury  \
    && mkdir build && cd build \
    && cmake  \
          -DMERCURY_USE_SELF_FORWARD:BOOL=ON \
          -DBUILD_TESTING:BOOL=ON \
          -DMERCURY_USE_BOOST_PP:BOOL=ON \
          -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PATH}  \
          -DBUILD_SHARED_LIBS:BOOL=ON \
          -DNA_USE_OFI:BOOL=ON  \
          -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
          -DCMAKE_BUILD_TYPE:STRING=Debug  \
          ..  \
    && make install -j \
    && cd ..  \
    && rm -rf build  \
    && cd \
    \
    ### mochi-margo
    && cd deps/mochi-margo \
    && ./prepare.sh \
    && mkdir build  \
    && cd build \
    && CFLAGS="-ggdb3 -O0" ../configure --prefix=${DEPS_INSTALL_PATH} \
    && make -j install \
    && cd ..  \
    && rm -rf build  \
    && cd \
    \
    ### cereal
    && cd deps/cereal \
    && mkdir build  \
    && cd build  \
    \
    && cmake  \
          -DCMAKE_BUILD_TYPE:STRING=Debug  \
          -DBUILD_DOC:BOOL=OFF \
          -DBUILD_SANDBOX:BOOL=OFF  \
          -DBUILD_TESTS:BOOL=OFF \
          -DSKIP_PERFORMANCE_COMPARISON:BOOL=ON \
          -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PATH} \
          .. \
    && make -j install \
    && cd ..  \
    && rm -rf build  \
    && cd \
    \
    ### mochi-thallium
    && cd deps/mochi-thallium \
    && mkdir build  \
    && cd build  \
    && cmake  \
          -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PATH}  \
          -DCMAKE_BUILD_TYPE:STRING=Debug  \
          .. \
    && make -j install  \
    && cd ..  \
    && rm -rf build  \
    && cd  \
    \
    && rm -rf deps

scripts/runner.sh

0 → 100755
+121 −0
Changes for scripts/runner.sh: 121 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/env bash

function help() {
  echo "Usage:"
  echo "  $(basename "$0") COMMAND"
  echo ""
  echo "  Where COMMAND is one of:"
  echo "    start PIDFILE PROGRAM ARGS...  Run PROGRAM and record its PID in PIDFILE"
  echo "    stop SIGNAL PIDFILE            Send SIGNAL to the PID contained in PIDFILE"
  echo "    help                      Print this message"
}

function readpid() {

  if [ $# -eq 0 ]; then
    echo "FATAL: readpid(): Missing pifile" >&2
    exit 1
  fi

  pidfile="$1"

  read -r pid <"$pidfile"
  echo $pid
}

function run() {

  if [[ -n "${RUNNER_SKIP_START}" && "${RUNNER_SKIP_START}" != "0" ]]; then
    exit 0
  fi

  if [ $# -eq 0 ]; then
    echo "FATAL: missing program pidfile" >&2
  elif [ $# -eq 1 ]; then
    echo "FATAL: missing program to run" >&2
    help
    exit 1
  fi

  pidfile="$1"
  shift

  if [ -e "$pidfile" ]; then
    pid=$(readpid "$pidfile")
    echo "$pid"

    if pgrep --pidfile "$pidfile"; then
      exit 1
    fi
  fi

  "$@" 2>runner.$$.err 1>runner.$$.out 0</dev/null &

  pid=$!
  echo $pid >"$pidfile"
  sleep 1

  if ! kill -0 $pid; then
    echo "Process $pid does not seem to exist." >&2
    echo "The program below may not exist or may have crashed while starting:" >&2
    echo "  $*" >&2
    echo " STDOUT: " >&2
    cat "runner.$$.out" >&2
    echo " STDERR: " >&2
    cat "runner.$$.err" >&2
    rm runner.$$.out runner.$$.err
    exit 1
  fi

  exit 0
}

function stop() {

  if [ $# -eq 0 ]; then
    echo "FATAL: missing signal" >&2
    exit 1
  elif [ $# -eq 1 ]; then
    echo "FATAL: missing pidfile" >&2
    exit 1
  fi

  signal="$1"
  pidfile="$2"

  if [ ! -e "$pidfile" ]; then
    echo "FATAL: pidfile '$pidfile' does not exist" >&2
    exit 1
  fi

  if pkill "-$signal" --pidfile "$pidfile"; then
    rm "$pidfile"
    rm runner.$$.out runner.$$.err
    exit 0
  fi
  exit 1
}

if [ $# -eq 0 ]; then
  echo "FATAL: missing arguments" >&2
  help
  exit 1
fi

case $1 in

start)
  shift
  run "$@"
  ;;

stop)
  shift
  stop "$@"
  ;;

help)
  help
  exit 0
  ;;
esac
+1 −0
Changes for src/net/CMakeLists.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ target_sources(
)

target_link_libraries(rpc_common PUBLIC logger::logger thallium asio::asio)
set_property(TARGET rpc_common PROPERTY POSITION_INDEPENDENT_CODE ON)

# get the parent directory of the current directory so we can include
# headers from these libraries as `<net/*.hpp>`
+12 −0
Changes for src/master.cpp: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ master_server::master_server(std::string name, std::string address,

#define EXPAND(rpc_name) #rpc_name##s, &master_server::rpc_name
    provider::define(EXPAND(ping));
    provider::define(EXPAND(shutdown));
    provider::define(EXPAND(transfer_datasets));
    provider::define(EXPAND(transfer_status));

@@ -161,6 +162,17 @@ master_server::ping(const network::request& req) {
    req.respond(resp);
}

void master_server::shutdown(const network::request& req) {
    using network::get_address;
    using network::rpc_info;
    using proto::generic_response;

    const auto rpc = rpc_info::create(RPC_NAME(), get_address(req));

    LOGGER_INFO("rpc {:>} body: {{}}", rpc);
    server::shutdown();
}

void
master_server::transfer_datasets(const network::request& req,
                                 const std::vector<dataset>& sources,
+3 −0
Changes for src/master.hpp: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ private:
    void
    ping(const network::request& req);

    void
    shutdown(const network::request& req);

    void
    transfer_datasets(const network::request& req,
                      const std::vector<cargo::dataset>& sources,
Loading
Loading