Я создаю API с использованием DRF, я смог настроить Docker, а также смог интегрировать Travis CI. Все работало нормально Сборка Трэвиса проходила, пока я не попытался получить тестовое покрытие, когда я получил ошибку ниже:
PermissionError: [Errno 13] Permission denied: '/app/.coverage'
The command "docker-compose run app sh -c "python manage.py test"" exited with 1.
Файл Dockerfile
FROM python:3.7-alpine
LABEL maintainer ="Daniel Otieno"
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user
файл docker-compose.yml
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
manage.py file
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
is_testing = 'test' in sys.argv
if is_testing:
import coverage
cov = coverage.coverage(source=['core'], omit=['*/tests/*'])
cov.set_option('report:show_missing', True)
cov.erase()
cov.start()
execute_from_command_line(sys.argv)
if is_testing:
cov.stop()
cov.save()
cov.report()
if __name__ == '__main__':
main()
settings.py
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--cover-erase',
'--cover-package=core',
]