python - 如何将脚本作为 Travis CI 构建的一部分运行?

标签 python travis-ci

作为 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):

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 block 在这些情况下很有用(仅在测试通过时运行脚本,并且不影响构建的成功)——通常用于发布覆盖率统计数据。

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

关于python - 如何将脚本作为 Travis CI 构建的一部分运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33703325/

相关文章:

r - 从 travis-ci 上的 github repo 的特定分支安装特定的 R 包

android - travis-ci 构建因 ShellCommandUnresponsiveException 不断失败

python - 应用引擎 : Few big scripts or many small ones?

python - 本地加载StanfordNLP模型

python - 如何获取数组滑动窗口 View 中最大元素的矩阵位置?

python - 值错误 : insecure string pickle

ruby - 安装一个 gem 以用作在 Travis 上构建 python 项目的工具

internet-explorer - Travis-CI +酱连接+ Behat : Unable to get Internet Explorer to run tests

python - 在 Python 中删除前导/结尾和内部多个空格但不删除制表符、换行符或返回字符

git - Travis CI - 从 github pull 的提交数量有限