diff --git a/.coveragerc b/.coveragerc index d7af984e1..4c67daa21 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,6 +3,16 @@ omit = */tests/* /fitbenchmarking/cli/main.py +; Run in parallel mode so that coverage can canonicalize the source paths +; regardless of whether it runs locally or within a Docker container. +; parallel = True + +[paths] +; the first path is the path on the local filesystem +; the second path is the path as it appears within the Docker container +source = + fitbenchmarking/ + /home/fitbenchmarking/fitbenchmarking/ [report] omit = diff --git a/.travis.yml b/.travis.yml index 8d2d51411..81af59303 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,10 @@ dist: bionic language: python python: - - 2.7 - - 3.6 - - 3.7 - - 3.8 + - 3.8 + +services: + - docker branches: only: @@ -34,54 +34,19 @@ notifications: on_failure: always before_install: - - sudo apt-get update - -install: - - if [[ $SUITE == "UNIT" ]]; then source ./travis/full_install.sh; fi - - if [[ $SUITE == "UNIT_DEFAULT" ]]; then source ./travis/default_install.sh; fi - - if [[ $SUITE == "SYSTEM" ]]; then source ./travis/full_install.sh; fi - - if [[ $SUITE == "SYSTEM_DEFAULT" ]]; then source ./travis/default_install.sh; fi + - if [[ $SUITE == "UNIT" ]]; then docker pull fitbenchmarking/fitbenchmarking-extras:latest; fi + - if [[ $SUITE == "UNIT_DEFAULT" ]];then docker pull fitbenchmarking/fitbenchmarking-deps:latest; fi; + - if [[ $SUITE == "SYSTEM" ]]; then docker pull fitbenchmarking/fitbenchmarking-extras:latest; fi; + - if [[ $SUITE == "SYSTEM_DEFAULT" ]]; then docker pull fitbenchmarking/fitbenchmarking-deps:latest; fi; - if [[ $SUITE == "LINTING" ]]; then source ./travis/linting_install.sh; fi + script: - - if [[ $SUITE == "UNIT" ]]; then source ./travis/unit_tests.sh; fi - - if [[ $SUITE == "UNIT_DEFAULT" ]]; then ./travis/unit_tests_default.sh; fi - - if [[ $SUITE == "SYSTEM" ]]; then ./travis/system_tests.sh; fi - - if [[ $SUITE == "SYSTEM_DEFAULT" ]]; then ./travis/system_tests_default.sh; fi + - if [[ $SUITE == "UNIT" ]]; then docker run --env TRAVIS_JOB_ID="$TRAVIS_JOB_ID" --env TRAVIS_BRANCH="$TRAVIS_BRANCH" --volume ${PWD}:/home/fitbenchmarking/ -w /home/fitbenchmarking/ fitbenchmarking/fitbenchmarking-extras:latest bash -c "pip install .; travis/unit_tests.sh"; fi + - if [[ $SUITE == "UNIT_DEFAULT" ]]; then docker run --env TRAVIS_JOB_ID="$TRAVIS_JOB_ID" --env TRAVIS_BRANCH="$TRAVIS_BRANCH" --volume ${PWD}:/home/fitbenchmarking/ -w /home/fitbenchmarking/ fitbenchmarking/fitbenchmarking-deps:latest bash -c "pip install .; travis/unit_tests_default.sh"; fi + - if [[ $SUITE == "SYSTEM" ]]; then docker run --env TRAVIS_JOB_ID="$TRAVIS_JOB_ID" --env TRAVIS_BRANCH="$TRAVIS_BRANCH" --volume ${PWD}:/home/fitbenchmarking/ -w /home/fitbenchmarking/ fitbenchmarking/fitbenchmarking-extras:latest bash -c "pip install .; travis/unit_tests.sh"; fi + - if [[ $SUITE == "SYSTEM_DEFAULT" ]]; then docker run --env TRAVIS_JOB_ID="$TRAVIS_JOB_ID" --env TRAVIS_BRANCH="$TRAVIS_BRANCH" --volume ${PWD}:/home/fitbenchmarking/ -w /home/fitbenchmarking/ fitbenchmarking/fitbenchmarking-deps:latest bash -c "pip install .; travis/unit_tests_default.sh"; fi - if [[ $SUITE == "LINTING" ]]; then ./travis/linting_tests.sh; fi after_success: - - if [[ $COVERAGE == "ON" ]]; then coveralls; fi - -jobs: - exclude: - - env: SUITE=UNIT_DEFAULT - python: 3.6 - - env: SUITE=UNIT COVERAGE=ON - python: 2.7 - - env: SUITE=UNIT COVERAGE=ON - python: 3.7 - - env: SUITE=UNIT COVERAGE=ON - python: 3.8 - - env: SUITE=SYSTEM_DEFAULT - python: 3.6 - - env: SUITE=SYSTEM - python: 2.7 - - env: SUITE=SYSTEM - python: 3.7 - - env: SUITE=SYSTEM - python: 3.8 - - env: SUITE=LINTING - python: 3.6 - - env: SUITE=LINTING - python: 3.7 - - - allow_failures: - # No longer guaranteed but good to know if working. - - env: SUITE=UNIT_DEFAULT - python: 2.7 - - env: SUITE=SYSTEM_DEFAULT - python: 2.7 - - env: SUITE=LINTING - python: 2.7 + - if [[ $COVERAGE == "ON" ]]; then mv .coverage .coverage.docker; coverage combine --append; coveralls; fi diff --git a/Docker/BasicInstall/Dockerfile b/Docker/BasicInstall/Dockerfile new file mode 100644 index 000000000..e60210818 --- /dev/null +++ b/Docker/BasicInstall/Dockerfile @@ -0,0 +1,28 @@ +# Use ubuntu as a parent image +FROM ubuntu:18.04 + +# Install the packages we need to build fitbenchmarking +RUN apt-get update && apt-get install -y \ + python3 \ + python3-pip \ + python3-dev \ + python3-venv \ + git + +# set up a venv to stop python/python3 sillyness +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN pip install wheel +RUN pip install pytest>3.6 \ + pytest-cov \ + coveralls \ + coverage~=4.5.4 \ + urllib3==1.23 \ + mock + +WORKDIR /home/ + + + diff --git a/Docker/FullInstall/Dockerfile b/Docker/FullInstall/Dockerfile new file mode 100644 index 000000000..248b5a201 --- /dev/null +++ b/Docker/FullInstall/Dockerfile @@ -0,0 +1,105 @@ +# Use the basic dependencies +FROM fitbenchmarking/fitbenchmarking-deps:latest + +WORKDIR / + +################# +# Install pygsl # +################# + +RUN apt-get update && \ + apt-get install -y gsl-bin \ + libgsl-dev \ + libgsl-dbg + +################## +# Install RALFit # +################## +RUN apt-get install -y gfortran \ + lcov \ + libblas-dev \ + liblapack-dev \ + cmake \ + libgdal-dev + +RUN git clone https://github.com/ralna/RALFit + +RUN pip install numpy + +RUN mkdir -p /RALFit/libRALFit/build + +WORKDIR /RALFit/libRALFit/build + +RUN cmake .. && make && make install + +# make install for RALFit doesn't work on docker, so manually pip install +RUN pip install . + +ENV LD_LIBRARY_PATH=/RALFit/libRALFit/build/src:$LD_LIBRARY_PATH + +################ +# Build cutest # +################ + +RUN mkdir -p /cutest + +WORKDIR /cutest + +RUN git clone https://github.com/ralna/ARCHDefs ./archdefs && \ + git clone https://github.com/ralna/SIFDecode ./sifdecode && \ + git clone https://github.com/ralna/CUTEst ./cutest + +RUN mkdir pycutest_cache + +ENV ARCHDEFS=/cutest/archdefs/ \ + SIFDECODE=/cutest/sifdecode/ \ + MASTSIF=/home/fitbenchmarking/examples/benchmark_problems/SIF/ \ + CUTEST=/cutest/cutest/ \ + MYARCH="pc64.lnx.gfo" \ + PYCUTEST_CACHE=/cutest/pycutest_cache/ + +ENV PYTHONPATH="${PYCUTEST_CACHE}:${PYTHONPATH}" + +# Install sifdecode + +WORKDIR $SIFDECODE +RUN printf "6\n2\n6\n" > sifdecode.input && \ + printf "nny" >> sifdecode.input && \ + ./install_sifdecode < sifdecode.input + +# Install cutest +WORKDIR $CUTEST +RUN printf "6\n2\n6\n2\n8\n" > cutest.input && \ + printf "nnydn" >> cutest.input && \ + ./install_cutest < cutest.input + +# install pycutest +RUN python -m pip install pycutest + +################## +# Install Mantid # +################## + +# set noninteractive to stop tzdata prompt +ENV DEBIAN_FRONTEND=noniteractive + +RUN apt-get install -y --fix-missing wget \ + lsb-release \ + software-properties-common +RUN wget -O - http://apt.isis.rl.ac.uk/2E10C193726B7213.asc -q | apt-key add - +RUN apt-add-repository "deb [arch=amd64] http://apt.isis.rl.ac.uk $(lsb_release -c | cut -f 2) main" -y +RUN apt-add-repository ppa:mantid/mantid -y +RUN apt-get update && apt-get install mantid -y + +ENV PYTHONPATH=$PYTHONPATH:/opt/Mantid/lib:/opt/Mantid/bin +RUN pip install IPython six +RUN /opt/Mantid/bin/mantidpython -m mantid.simpleapi || echo "expected segfault on first run" + +################# +# install pygsl # +################# +RUN python -m pip install pygsl + + +## ALL SET UP ## +WORKDIR /home/ \ No newline at end of file diff --git a/docs/source/contributors/structure.rst b/docs/source/contributors/structure.rst index 17d40ea04..93516214e 100644 --- a/docs/source/contributors/structure.rst +++ b/docs/source/contributors/structure.rst @@ -4,9 +4,10 @@ Repository Structure #################### -At the root of the repository there are four directories: +At the root of the repository there are five directories: - build + - Docker - docs - examples - fitbenchmarking @@ -19,6 +20,27 @@ Build (``build``) This directory contains scripts to allow for installing packages such as Mantid through setuptools. +******************* +Docker (``Docker``) +******************* + +The continuous integration process on travis currently run on a Docker container, +and this directory holds the Dockerfiles. The Docker containers are hosted on +Dockerhub. + +``BasicInstall`` holds the Dockerfile that is pushed to the repository ``fitbenchmarking/fitbenchmarking-deps``, the lastest of which should have the tag ``latest``. This contains a basic Ubuntu install, with just the minimal infrastructure needed to run the tests. + +``FullInstall`` holds the Dockerfile that is pushed to the repository ``fitbenchmarking/fitbenchmarking-extras``, the lastest of which should have the tag ``latest``. This is built on top of the basic container, and includes optional third party software that FitBenchmarking can work with. + +The versions on Docker Hub can be updated from a connected account by issuing the commands: + +.. code-block:: bash + + docker build --tag fitbenchmarking-: + docker tag fitbenchmarking-: fitbenchmarking/fitbenchmarking-: + docker push fitbenchmarking/fitbenchmarking-: + +where ```` is, e.g., ``deps`` or ``extras``, and ```` is, e.g., ``latest``. ************************ Documentation (``docs``) @@ -35,6 +57,7 @@ Examples (``examples``) *********************** Examples is used to store two sets of assets: + - Problem files - Options files diff --git a/travis/unit_tests.sh b/travis/unit_tests.sh index 839999187..734a7a4b3 100755 --- a/travis/unit_tests.sh +++ b/travis/unit_tests.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Handle gracefully the mantid segfault issue +/opt/Mantid/bin/mantidpython -m mantid.simpleapi >file 2>/dev/null | cat +echo "first run of mantid is expected to segfault" + # Test one dir to generate the coverage file pytest fitbenchmarking/cli --cov=fitbenchmarking/cli --cov-report term-missing status=$?