ソースを参照

Enable docker mounting of test directory (#4692)

This is achieved by cleaning up pyc files in the docker entrypoint
script which avoids mismatches between compiled Python files on the
docker host and/or from previous build steps by construction: before
executing any command in the docker container, any remnant platform
specific files are cleaned up and as such any subsequent py.test command
will run in a clean environment.
Clemens Wolff 7 年 前
コミット
8c753d7feb
3 ファイル変更8 行追加9 行削除
  1. 3 5
      docker/Dockerfile
  2. 2 4
      docker/docker-compose.yml
  3. 3 0
      docker/entrypoint

+ 3 - 5
docker/Dockerfile

@@ -70,9 +70,7 @@ COPY --chown=1000:1000 celery $HOME/celery
 
 RUN pyenv exec pip install -e .
 
-# the compiled files from earlier steps will cause py.test to fail with
-# an ImportMismatchError
-RUN make clean-pyc
-
-# Setup the entrypoint, this ensures pyenv is initialized when a container is started.
+# Setup the entrypoint, this ensures pyenv is initialized when a container is started
+# and that any compiled files from earlier steps or from moutns are removed to avoid
+# py.test failing with an ImportMismatchError
 ENTRYPOINT ["/entrypoint"]

+ 2 - 4
docker/docker-compose.yml

@@ -16,11 +16,9 @@ services:
       WORKER_LOGLEVEL: DEBUG
     tty: true
     volumes:
+      - ../docs:/home/developer/docs
       - ../celery:/home/developer/celery
-      # Because pytest fails when it encounters files from alternative python compilations,
-      # __pycache__ and pyc files, PYTHONDONTWRITEBYTECODE must be
-      # set on the host as well or py.test will throw configuration errors.
-#      - ../t:/home/$CELERY_USER/t
+      - ../t:/home/developer/t
     depends_on:
       - rabbit
       - redis

+ 3 - 0
docker/entrypoint

@@ -1,4 +1,7 @@
 #!/bin/bash
+
+make --quiet --directory="$HOME" clean-pyc
+
 eval "$(pyenv init -)"
 eval "$(pyenv virtualenv-init -)"
 exec "$@"