From 4152f68e357b6aceabc88b252bcd5f83b81c3a12 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Tue, 28 Dec 2021 14:30:45 -0800 Subject: [PATCH] Store relative paths in coverage data Also remove the reliance on the container needing to mount the host's files to the same directory during local testing. Fix #135 --- .coveragerc | 3 ++- DEVELOPING.md | 6 +++--- docker-compose.yml | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.coveragerc b/.coveragerc index cd0ab814..cc2a148f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,9 +1,10 @@ [run] -branch = True +branch = true include = snekbox/* omit = snekbox/api/app.py snekbox/config_pb2.py +relative_files = true [report] exclude_lines = diff --git a/DEVELOPING.md b/DEVELOPING.md index fdda51a0..0dbf4cc3 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -30,8 +30,6 @@ docker-compose up The container has all development dependencies. The repository on the host is mounted within the container; changes made to local files will also affect the container. -Note that the compose file depends on the environment variable `PWD` being set to the current working directory. It needs it to create the aforementioned bind mount. Unix shells normally have this set already. If for some reason it is not set, it needs to be manually set. A convenient way to set it is to define it in a `.env` file which Docker Compose will automatically read. - To build a normal container that can be used in production, run ``` @@ -62,7 +60,9 @@ Alternatively, a report can be generated as HTML with pipenv run coverage html ``` -The HTML will output to `./htmlcov/` by default +The HTML will output to `./htmlcov/` by default. + +The report cannot be generated on Windows directly due to the difference in file separators in the paths. Instead, launch a shell in the container (see below) and use `coverage report` or `coverage html` (do not invoke through Pipenv). ## Launching a Shell in the Container diff --git a/docker-compose.yml b/docker-compose.yml index f5460243..38548255 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,10 +11,8 @@ services: init: true ipc: none tty: true - working_dir: $PWD environment: DEBUG: 1 - PIPENV_PIPFILE: /snekbox/Pipfile PYTHONDONTWRITEBYTECODE: 1 build: context: . @@ -24,7 +22,7 @@ services: cache_from: - ghcr.io/python-discord/snekbox:latest volumes: - - $PWD:$PWD + - .:/snekbox - user-base:/snekbox/user_base volumes: