如何将to travis环境变量添加到Tox

时间:2017-06-26 01:02:09

标签: django travis-ci tox

我的项目使用环境变量,我试图在Tox中使用它们。根据{{​​3}},我必须在passenv中设置tox.ini,但当我这样做时,我会收到错误

Collecting django<1.10,>=1.9
  Using cached Django-1.9.13-py2.py3-none-any.whl
Collecting AUTHY_API
  Could not find a version that satisfies the requirement AUTHY_API (from versions: )
No matching distribution found for AUTHY_API

看起来Tox认为AUTHY_API是一个分发文件,而它实际上是一个环境变量。

我的配置是:

.travis.yml

language: python

python:
  - 3.5
  - 3.6

services: postgresql

addons:
  postgresql: "9.4"

before_script:
  - psql -c "CREATE DATABASE mydb;" -U postgres

branches:
  only:
  - master
  - v3

install:
  - pip install tox-travis

script:
  - tox

env:
  - TOXENV=django19
  - TOXENV=django110
  - TOXENV=coverage

notifications:
  email: false

tox.ini

[tox]
envlist = django19, django110
skipsdist = True

[testenv]
commands = pytest
setenv =
    DJANGO_SETTINGS_MODULE=gollahalli_com.settings
    PYTHONPATH={toxinidir}

[base]
deps =
    -r{toxinidir}/requirements-testing.txt
passenv =
    AUTHY_API
    cloudinary_api
    cloudinary_api_secret
    DEBUG
    SECRET_KEY
    GITHUB_KEY

[testenv:django19]
deps =
    django>=1.9, <1.10
    {[base]deps}
    {[base]passenv}

[testenv:django110]
deps =
    django>=1.10, <1.11
    {[base]deps}
    {[base]passenv}

[testenv:coverage]
commands =
;    coverage run --branch --omit={envdir}/*,test_app/*.py,*/migrations/*.py {envbindir}/manage.py test
    pytest --cov=./
    codecov
deps =
    {[testenv:django110]deps}
    {[base]passenv}

我不确定这里有什么问题。救命啊!

1 个答案:

答案 0 :(得分:0)

这是错误:

deps =
    …
    {[base]passenv}

您将env vars列表作为依赖项传递。将passenv移至[testenv]并从所有环境中移除{[base]passenv}