【问题标题】:How can I run a script as part of a Travis CI build?如何在 Travis CI 构建中运行脚本?
【发布时间】:2015-11-13 23:25:15
【问题描述】:

作为 Python 包的一部分,我在项目的根目录中有一个脚本 myscript.py,并且

setup(scripts=['myscript.py'], ...) 

在我的setup.py.

我是否可以向我的.travis.yml 提供一个可以运行myscript.py 的条目(例如在我的测试之后)?

我试过了

language: python

python:
  - "2.7"

install:
  - pip install -r requirements.txt
  - pip install pytest

script:
  - py.test -v --color=yes --exitfirst --showlocals --durations=5
  - myscript.py some args

但出现“找不到命令”错误。

我不需要(或真的不希望)脚本成为测试套件的一部分,我只想在 Travis 日志中看到它的输出(并且,如果出错,构建失败)。

如何在 Travis CI 构建中运行包脚本?

【问题讨论】:

  • python myscript.py some args?
  • @sobolevn:哇! - 是的!这就是答案!

标签: python travis-ci


【解决方案1】:

如cmets中提到的(需要调用python):

language: python

python:
  - "2.7"

install:
  - pip install -r requirements.txt
  - pip install pytest

script:
  - py.test -v --color=yes --exitfirst --showlocals --durations=5
  - python myscript.py some args

(在最后一行添加 python。)

另外:travis 应该已经预装了 pytest。


还有一个 after_success 块在这些情况下很有用(仅在测试通过时运行脚本,并且不影响构建的成功) - 通常用于发布覆盖率统计信息。

language: python

python:
  - "2.7"

install:
  - pip install -r requirements.txt
  - pip install pytest

script:
  - py.test -v --color=yes --exitfirst --showlocals --durations=5

after_success:
  - python myscript.py some args

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    相关资源
    最近更新 更多