如何在没有超时的情况下在 Travis CI 上安装某些东西?

How can I install something on Travis CI without a timeout?

我正在尝试测试在 travis-ci.org 上构建的软件包,但遇到 pip install 超时 scipy:

Installing collected packages: scipy
  Running setup.py install for scipy
    Running command /home/travis/virtualenv/python2.6.9/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Fn2gmJ/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hWDx9L-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/travis/virtualenv/python2.6.9/include/site/python2.6


No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.

The build has been terminated

(摘自最近的 build log)。

如何在没有超时的情况下在 Travis 上构建 scipy >= 0.11?

解决方案很简单。只需在安装命令前加上 travis_wait。更多详细信息,请访问 https://docs.travis-ci.com/user/common-build-problems

Travis 上每个命令的默认超时为 10 分钟,当您仅使用函数 travis_wait 时,超时为 20 分钟。如果您的构建需要等待超过 20 分钟,您可以传递一个分钟数来函数 travis_wait,例如:

$ travis_wait 30 pip install scipy

这是 Travis 中未记录的函数,但它是由 Travis 的 Hiro Asari 在 github issue 上建议的。

如果无法使用 Travis CI 提供的 travis_wait 之类的命令,您也可以使用 an approach from here

在我的例子中,我想保留 Travis 运行,同时在单独的 shell 脚本中定义步骤,我不知道如何使用 Travis 提供的命令。上述方法效果很好(如果有兴趣,请参阅 the pull request)。