【发布时间】:2020-10-19 17:16:51
【问题描述】:
标题不言自明。一切正常,除了测试。拉动并运行test(test stage) 服务后,它显示Ran 0 tests in 0.000s,但我有一些基本测试,它们在我的系统上完美运行。只是无法完全弄清楚出了什么问题。
我有一个像这样的 docker-compose 文件:
version: '2'
services:
postgres:
image: "postgres"
ports:
- 5432:5432
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=solo
- POSTGRES_DB=solo
- POSTGRES_PASSWORD=solo
- POSTGRES_HOST_AUTH_METHOD=trust
web:
image: $CI_REGISTRY:$CI_COMMIT_REF_NAME
build: .
environment:
- SECRET_KEY
command: bash -c "cd src && gunicorn solo.wsgi:application --bind 0.0.0.0:8000"
volumes:
- static:/app/static
expose:
- 8000
depends_on:
- postgres
restart: always
test:
image: $CI_REGISTRY:$CI_COMMIT_REF_NAME
command: bash -c "python /app/src/manage.py test"
depends_on:
- postgres
nginx:
build: ./nginx
volumes:
- static:/app/static
ports:
- 80:80
depends_on:
- web
volumes:
static:
postgres_data:
还有 .gitlab-ci.yml 像这样:
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- deploy
before_script:
- apk add --no-cache py-pip
- pip install docker-compose==1.9.0
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
build:
stage: build
script:
- docker-compose build
- docker-compose push
test:
stage: test
script:
- docker-compose pull test
- docker-compose run test
deploy:
stage: deploy
only:
- master
- cicddev
before_script:
- apk add --update alpine-sdk
- apk add python3-dev libffi-dev libffi-dev libressl-dev
- apk add --no-cache openssh-client py-pip bash rsync
- pip install Fabric3==1.14.post1
- eval $(ssh-agent -s)
- bash -c 'echo "${DEPLOY_KEY}" | ssh-add -'
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
script:
- fab -H ${DEPLOY_ADDRESS} deploy
有什么想法或建议吗?
【问题讨论】: