From 9b2ea62e6957392a53c16f48f078709e8b957aff Mon Sep 17 00:00:00 2001 From: Daniel Jagszent Date: Mon, 14 Sep 2020 21:44:37 +0200 Subject: [PATCH] Add Dockerfile and bash script to more easily run tests (#198) --- .dockerignore | 23 +++++++++++++++++++++++ .gitignore | 1 + tests/Dockerfile | 32 ++++++++++++++++++++++++++++++++ tests/run-tests-via-docker.sh | 9 +++++++++ 4 files changed, 65 insertions(+) create mode 100644 .dockerignore create mode 100644 tests/Dockerfile create mode 100755 tests/run-tests-via-docker.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..683e0b83c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +*.pyc +__pycache__ +*/__pycache__ +*/*/__pycache__ +*/*/*/__pycache__ +/.project +/.pydevproject +/.settings +/.idea +/build/ +/contrib/expire_backups.1 +/contrib/pcp.1 +/dist/ +/doc/ +/rst/autogen/ +/s3ql.old/ +/src/s3ql.egg-info/ +/src/s3ql/deltadump.*.so +/src/s3ql/deltadump.c +/tests/.cache/ +/tests/.pytest_cache/ +/tests/test.log +/tests/test_crit.log diff --git a/.gitignore b/.gitignore index 4444538b7..1c88d3e67 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ /.project /.pydevproject /.settings +/.idea /build/ /contrib/expire_backups.1 /contrib/pcp.1 diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 000000000..9f45ed65c --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,32 @@ +# This is not a general purpose Dockerfile +# It's tailored for running tests and building documentation. + +FROM ubuntu:bionic AS build +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get install -y fakeroot curl dpkg-dev build-essential manpages pbuilder aptitude rsync \ + git libbz2-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev \ + zlib1g-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils libxml2-dev libxmlsec1-dev liblzma-dev \ + libsystemd-dev gcc psmisc pkg-config libattr1-dev libsqlite3-dev libjs-sphinxdoc texlive-latex-base \ + texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended python3-pip python3-setuptools \ + ninja-build udev libudev1 libudev-dev \ + && mkdir /build \ + && ln -sf /usr/bin/pip3 /usr/bin/pip && ln -sf /usr/bin/python3 /usr/bin/python \ + && pip install "setuptools >= 40.3.0" + +ADD tests/travis-install.sh /travis-install.sh +RUN /travis-install.sh + +ADD . /build +WORKDIR /build +RUN python setup.py build_cython \ + && python setup.py build_ext --inplace \ + && python setup.py test \ + && python setup.py build_sphinx \ + && python setup.py install + +FROM scratch AS export +COPY --from=build /build/doc/ /doc/ +COPY --from=build /build/src/s3ql/deltadump.c /src/s3ql/deltadump.c diff --git a/tests/run-tests-via-docker.sh b/tests/run-tests-via-docker.sh new file mode 100755 index 000000000..e1ecb2c99 --- /dev/null +++ b/tests/run-tests-via-docker.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# always use S3QL source root as working dir +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$DIR/.." || exit 1 + +# run tests in docker and copy documentation to /build/ +# use BuildKit when available so that the --output option works on macOS +DOCKER_BUILDKIT=1 docker build -f ./tests/Dockerfile -o "./build" .