我在Travis CI中运行了一些自动化测试,我在运行两个parrelel命令时遇到了麻烦,所以基本上在测试之前我们应该通过执行python app/main.py
来运行main flask app,之后我们应该运行nosetests /app/tests/test.py
。要运行此操作,我使用的是包含
start_server.sh
#!/usr/bin/env bash
python app/main.py > /dev/null &
nosetests app/tests/test.py --with-coverage
这是我的travis配置:
language: python3
sudo: required
addons:
apt:
packages:
- python-dev
python:
- '3.5'
before_install:
- sudo apt-get -qq update
- sudo apt-get -y install librsvg2-bin
- sudo apt-get -y install pdftk
- sudo apt-get -y install python3-pip
- sudo apt-get install python-virtualenv
install:
- virtualenv -p python3 flask_env
- source flask_env/bin/activate
- pip3 install -r requirements/test.txt
- pip3 install -r requirements/dev.txt
before_script:
- chmod +x ./start_server.sh
script:
- sh start_server.sh
- python -m pyflakes .
deploy:
- provider: releases
skip_cleanup: true
api_key:
secure: "xlbAXVbIkKtoQH78HgpFvURBR1B40qxuui6AB7WzPgDA8bQzW7FSNYghMBaJkRdVDKBbS9PFcwi9joCnJq3JoGmKDHdtBe5aYAsfiyDiLZTmThqX0we87tin3WcxefsOjUbDHZrR6R0XdOb4SxXYhn5pn1Xjf9I4/rWi6tuqLX2LkPNITxISnQVroO4NGAMsYDUGYxvaQf8zbC3rl8q8yjV9C+VhazKgWAcWEXB45nJtkGNpzuxldKQ6kANwssuSVB0g3P9UUuRhVs+m6Hz2fIpUjHCI7mhpPQxYHf6ajF4G1D3i1ACtpOd39+fygI3GEaejn1Ouni/ECan2TicQ72ujP5cOS6jl/7ZgxoYFR7XuuhFAaHn+RhXR9RP/MIFIVdjtBySxnmbxpObXqyzygcYUIn11fBrdixSO7f1UFbmT0hlJfG4Msbo0JSh0BSqwIEwG9Pvc+DWJjWOYyahRJZBrvt5CWAgs84frq/EXFnVckmjOsBD+iW0L/nZQnt8+ZrH9LAMM5Y2XiDDDJG7lx+yvk5oKmcr1n53XL64x3EMg7tuBdCbPiQcQc/13kDVkHW5PVhjtLzRZ2/yUtvUFuq+Lzzl9e/hJ+PW0ioTVa6ykkoPfhQhUxlPRRhOC4d+aPAP6t4km8JzMyGC2wPJqt7X83eKIbEVHsQHbzwyze3Q="
file: "all-badges.pdf"
on:
branch: master
after_success:
- deactivate
- 'bash <(curl -s https://codecov.io/bash)'
Travis日志:https://travis-ci.org/fossasia/badgeyay/builds/285063294?utm_source=github_status&utm_medium=notification
任何想法都会非常感激。
答案 0 :(得分:3)
您可以尝试在后台运行sh start_server.sh
吗?
认为这应该可以解决问题:
script:
- "sh start_server.sh &"
或者,您可能希望使用setsid
之类的命令,stdin,stdout和stderr的重定向,以及/或sh
中禁用start_server.sh
的作业控制。