Skip to content

Commit

Permalink
103 setup docker (#605)
Browse files Browse the repository at this point in the history
* GSL and RALFit work

* Add dockerfile for the basic dependencies

* First stab at a travis.yml file

* pull a specific version of the container

* update the docker command

* correct name of docker container

* change the docker run command

* Add full install dockerfile

* docker run the script

* remove multiline

* docker run --> docker exec

* update bash script location

* Fixing table tests

* Updating docker travis file

* run apt-get update first

* pull the extras container, and test defaults

* change location of block scalars

* swap tabs for spaces

* fix unit tests version

* Change location of break

* make one line

* change directory on entry

* change directory of fitbenchmarking

* add missing / to pip install

* Update dockerfile to build pygsl and update MASTSIF

* fix pycutest_cache directory

* Run other tests through docker

* update dockerfile so that PYTHONPATH is correct

* fix directory location

* pull the correct container

* fix some of the travis warnings

* fix the python version used

* move to fitbenchmarking repo, not personal one

* try and fix sending of data to coveralls

* run coveralls in docker

* pass environment variables to docker containers

* change order of env variables passed to travis

* try and run coveralls outside of docker

* start docker in fitbenchmarking folder

* allow for mantid segfault on first run

* full->extras

* fix or syntax

* split into two commands

* try to put segfault on before_install

* move segfault capturing into the unit_tests file

* install coveralls and change paths

* move install of coveralls after pass

* remove parallel option

* fix coveragerc error

* combine coverage reports to fix the directory structure

Following the hints here:
pytest-dev/pytest-cov#146

* try earlier version of coverage

see TheKevJames/coveralls-python#203

* be more specific in the version

* fix coverage version to that in the docker container

* remove python-coveralls from dockerfile

As suggested here:
z4r/python-coveralls#73

* remove installation of coverage

* pin coverage in dockerfile

* remove installation of coveralls (unneeded)

* fix syntax

* remove old dockerfile

* add documentation for the docker tests

* fix documentation styling

* fix examples format

* revert to fixed test directory

Co-authored-by: Michael Wathen <mwathen@gmail.com>
(cherry picked from commit e7bfb0d)
  • Loading branch information
tyronerees authored and wathen committed Sep 17, 2020
1 parent 95e6cff commit e0df466
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 50 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Expand Up @@ -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 =
Expand Down
63 changes: 14 additions & 49 deletions .travis.yml
Expand Up @@ -3,10 +3,10 @@ dist: bionic

language: python
python:
- 2.7
- 3.6
- 3.7
- 3.8
- 3.8

services:
- docker

branches:
only:
Expand Down Expand Up @@ -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
28 changes: 28 additions & 0 deletions 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/



105 changes: 105 additions & 0 deletions 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/
25 changes: 24 additions & 1 deletion docs/source/contributors/structure.rst
Expand Up @@ -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
Expand All @@ -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-<type>:<tag>
docker tag fitbenchmarking-<type>:<tag> fitbenchmarking/fitbenchmarking-<type>:<tag>
docker push fitbenchmarking/fitbenchmarking-<type>:<tag>
where ``<type>`` is, e.g., ``deps`` or ``extras``, and ``<tag>`` is, e.g., ``latest``.

************************
Documentation (``docs``)
Expand All @@ -35,6 +57,7 @@ Examples (``examples``)
***********************

Examples is used to store two sets of assets:

- Problem files
- Options files

Expand Down
4 changes: 4 additions & 0 deletions 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=$?
Expand Down

0 comments on commit e0df466

Please sign in to comment.