我如何 运行 将脚本作为 Travis CI 构建的一部分?
How can I run a script as part of a Travis CI build?
作为 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
但出现 "command not found" 错误。
我不需要(或真的希望)脚本成为测试套件的一部分,我只想在 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
块在这些情况下很有用(对于 运行 只有测试通过的脚本,并且不影响构建的成功) - 通常使用它用于发布覆盖率统计数据。
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 包的一部分,我在项目的根目录下有一个脚本 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
但出现 "command not found" 错误。
我不需要(或真的希望)脚本成为测试套件的一部分,我只想在 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
块在这些情况下很有用(对于 运行 只有测试通过的脚本,并且不影响构建的成功) - 通常使用它用于发布覆盖率统计数据。
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