【发布时间】:2020-08-11 07:39:38
【问题描述】:
我创建了工作流以在提交之前测试我的 Python 应用程序。问题是,如果测试失败,无论如何都会推送提交。如果测试不成功,我如何添加条件来避免推送?
工作流文件 .yml 的结构如下。
`名称:Python 应用程序 在: 推: 分支:[主] 拉取请求: 分支:[主]
工作: 构建:
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`
【问题讨论】:
-
该工作流(any 工作流,就此而言)只能get 被推送的代码。如果您想在 推送之前进行测试,则需要在 本地 进行。你可以研究 git hooks 来自动化它。
标签: python testing github github-actions workload