I have a GitHub Action workflow file that is doing multiple linting checks. flake8
is the first linting check and if it fails the entire workflow fails meaning the subsequent linting checks are name: lint
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
ref: ${{ github.head_ref }}
- name: python
uses: actions/setup-python@main
with:
# pulls latest version of python, alternatively specify exact version (i.e. 3.8 -> no quotes)
python-version: '3.9'
- name: install
run: |
pip install -r requirements.txt
- name: Lint with flake8
run: |
# fail if there are any flake8 errors
flake8 . --count --max-complexity=15 --max-line-length=127 --statistics
## subsequent linting jobs
You could use the continue-on-error in conjunction with the outcome of the step. From the doc:
steps.<step_id>.outcome string The result of a completed step before continue-on-error is applied. Possible values are success, failure, cancelled, or skipped. When a continue-on-error step fails, the outcome is failure, but the final conclusion is success.
As example:
- name: Lint with flake8
id: flake8
continue-on-error: true
run: |
# fail if there are any flake8 errors
flake8 . --count --max-complexity=15 --max-line-length=127 --statistics
- name: Check if 'Lint with flake8' step failed
if: steps.flake8.outcome != 'success'
run: |
echo "flake8 fails"
exit 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.