如何防止travis部署两次?

Ree*_*ece 5 continuous-integration travis-ci

我将travis设置为使用tox(Python 2.7和3.5)进行测试并部署到pypi.

Travis尝试为每次测试运行部署包,pypi正确拒绝第二次尝试.

我希望只有当tox成功完成两次运行时,travis才会部署一次.这是如何完成的?

Travis配置:https://github.com/biocommons/biocommons.seqrepo/blob/master/.travis.yml

并且测试运行:https://travis-ci.org/biocommons/biocommons.seqrepo/builds/157794212 (68.2首先完成并推送到pypi .pypi错误在68.1.)

相关但陈旧的问题:为什么Travis在部署之前不等待所有构建都通过?

ste*_*fin 2

现在可以通过构建阶段来完成此任务,该阶段目前处于测试阶段。这看起来像这样:

stages:  # determines the order everything runs in
- test
- deploy
jobs:  #  specifies the actual job
  include:
    - stage: test
      # configuration for a stage here
    - stage: deploy
      # configuration for the next stage here
Run Code Online (Sandbox Code Playgroud)

给出.travis.yml这样的:

language: python
sudo: false
cache: pip
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
install:
- pip install tox-travis
script:
- tox
deploy:
  provider: pypi
  user: stephenfin
  password:
    secure: <key omitted for brevity>
  on:
    tags: true
  distributions: sdist bdist_wheel
Run Code Online (Sandbox Code Playgroud)

你可以像这样转换它:

language: python
sudo: false
cache: pip
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
install:
- pip install tox-travis
script:
- tox
stages:
- test
- deploy
jobs:
  include:
    - stage: deploy
      python: 3.6
      install: skip  # no tests, no depedencies needed
      script: skip  # we're not running tests
      deploy:
        provider: pypi
        user: stephenfin
        password:
          secure: <key omitted for brevity>
        on:
          tags: true
        distributions: sdist bdist_wheel
Run Code Online (Sandbox Code Playgroud)

就我个人而言,我发现这有点违反直觉:我期望所有非全局的内容都嵌套在stage. 因此,我明确定义了test阶段并在其下嵌套了python,installscript键。但是,这不起作用,您需要在顶层设置这些键,然后在各个阶段显式覆盖它们。全局的东西将由阶段调用test,这是默认的作业。我尚未确定这是否是 Travis 或tox-travis插件(当前为 0.10)的问题,但值得一提。

另请注意,如果您使用的是 Travis Gem,该travis lint命令当前会失败,因为该功能尚不支持。对此有一个开放的错误。