我创建了在提交之前测试Python应用程序的工作流。问题是,如果测试失败,无论如何都会推送提交。如果测试不成功,我如何添加条件来避免推送?
下面是工作流文件.yml的结构。
`名称: Python应用程序on: push: branches: master pull_request: branches: master
作业:内部版本:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest`发布于 2020-04-28 08:37:43
实际上,您无法使用CI系统阻止推送,原因有几个。
首先,您的CI系统需要能够访问要推送的数据,这意味着数据必须位于某个存储库中,以便可以获取。其次,CI系统可能需要很长时间才能运行,并且没有人希望在CI系统运行时等待他们的推送成功或失败。如果你在一天的工作快结束的时候推了一下,会怎么样?
通常的方法是推送到一个分支,让CI系统运行,然后合并它。如果您正在与多人一起工作,那么使用拉请求并将您的配置项设置为在打开或更新时运行是正确的做法。否则,您可以将工作流设置为在所有分支上操作(如下所示),然后在分支通过时合并该分支:
on: pushhttps://stackoverflow.com/questions/61464151
复制相似问题