FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit c595ec56 authored by Dr Rich Wareham's avatar Dr Rich Wareham Committed by Dr Abraham Martin
Browse files

docker-compose.yml: rework tox

Re-work the tox deployment so that we mount the application directory as
a read-only volume rather than copying the file in when building the
image. This has the following advantages:

1. We do not build a new image each time we run tests. (This is nicer to
   those of us with finite disk space.)
2. Running tests is slightly faster since a new image is not being
   built.
3. The application directory is mounted read-only so we catch code which
   accidentally writes to the current directory.
4. We can use the upstream tox image rather than rolling our own derived
   image.

In order to make to happy to run in a read-only environment, we specify
that a) it does not run sdist to write an .egg-info directory and b)
that coverage data is stored in /tmp rather than the application
directory.
parent 6000b386
No related branches found
No related tags found
1 merge request!4Add tox support for matrix testing
FROM themattrix/tox-base
ADD . .
RUN tox
......@@ -159,5 +159,5 @@ Tox is configured to run on a container with a matrix execution of different ver
It will also show the coverage and any possible PEP8 violations.
```shell
$ docker-compose up --build tox
$ docker-compose up
```
......@@ -199,4 +199,4 @@ It will also show the coverage and any possible PEP8 violations.
.. code:: shell
$ docker-compose up --build tox
$ docker-compose up
......@@ -6,14 +6,15 @@
version: '3.2'
services:
tox:
build:
context: .
dockerfile: Dockerfile
image: themattrix/tox-base
entrypoint: tox
environment:
- TOXINI_WORK_DIR=/tmp/tox-data/work
- TOXINI_ARTEFACT_DIR=/tmp/tox-data/artefacts
- TOXINI_COVERAGE_FILE=/tmp/tox-coverage
volumes:
- tox-data:/tmp/tox-data
- ./:/app:ro
volumes:
# A persistent volume for tox to store its stuff. This allows caching of
......
......@@ -17,6 +17,9 @@ envlist =
flake8
# Allow overriding toxworkdir via environment variable
toxworkdir={env:TOXINI_WORK_DIR:{toxinidir}/.tox}
# Do not attempt to create .egg-info directories in the application root as it
# is mounted as a read-only volume.
skipsdist=true
# The "_vars" section is ignored by tox but we place some useful shared
# variables in it to avoid needless repetition.
......@@ -27,6 +30,10 @@ toxworkdir={env:TOXINI_WORK_DIR:{toxinidir}/.tox}
build_root={env:TOXINI_ARTEFACT_DIR:{toxinidir}/build}
[testenv]
setenv=
# Override the coverage dtaa file location since the application root is
# mounted read-only.
COVERAGE_FILE={env:TOXINI_COVERAGE_FILE:{toxinidir}/.coverage}
# Additional dependencies
deps=
coverage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment