我特拉维斯慈建立将永远运行下去后,该应用程序成功运行

问题描述 投票:0回答:2

我有一个小的Python应用程序,我想,以确保它开始没有任何问题,当有人提出一个新的GitHub拉请求/提交。

现在的问题是,一旦我运行应用程序运行永远,因为一切正常,没有任何问题。

有没有一种方法,因为构建2分钟后关闭状态为0的构建?

这里是我的.travis.yml文件


python:
  - "3.7-dev"

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

before_script:
  - chmod +x deploy.sh
  - chmod +x changelog.sh



branches:
  only:
    - travis-test

script:
  - python3 -m tg_companion

after_success:
  ./deploy.sh
python-3.x travis-ci
2个回答
1
投票

要做到这一点的方法之一是包裹在一定的时间后杀死它的脚本您的应用程序的开始。

travis.yml集:

script:
  - bash timeout.sh

然后创建一个timeout.sh脚本:

#!/bin/bash

# Run your app in the background
python3 -m tg_companion &

# Store it's Process ID
bg_pid=$!

# sleep for X seconds
sleep 120

# Kill the python process
kill $bg_pid

# Optionally exit true to prevent travis seeing this as an error
exit 0

另一种方法是修改你的模块时,它在测试模式下运行的通知,并在超时后杀死自己 - 可能是一个命令行标志,或查看用于例如环境TRAVIS=trueCI=true


0
投票

创建使用下面的代码另一个Python文件test.py。

import tg_companion

而不是运行tg_companion的运行测试。即-python3 -m test(在.travis.yml的脚本)

© www.soinside.com 2019 - 2024. All rights reserved.