我创建了工作流来在提交之前测试我的 Python 应用程序。问题是,如果测试失败,无论如何都会推送提交。如果测试不成功,我如何添加条件来避免推送?
工作流文件 .yml 的结构如下。
`名称:Python应用程序:推送:分支:[master] pull_request:分支:[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`