【问题标题】:How to add travis environment variables to Tox如何将 travis 环境变量添加到 Tox
【发布时间】:2017-06-26 01:02:09
【问题描述】:

我的项目使用环境变量,我正在尝试在 Tox 中使用它们。根据https://stackoverflow.com/a/37522926/3782963,我必须在tox.ini 中设置passenv,但是当我这样做时,我得到一个错误

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}

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

【问题讨论】:

    标签: django travis-ci tox


    【解决方案1】:

    这是错误:

    deps =
        …
        {[base]passenv}
    

    您将环境变量列表作为依赖项传递。将passenv 移动到[testenv] 并从所有环境中删除{[base]passenv}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-07
      • 1970-01-01
      • 2019-03-13
      • 1970-01-01
      • 2021-01-12
      • 2012-11-17
      • 1970-01-01
      • 2019-12-17
      相关资源
      最近更新 更多