1+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versionsAdd commentMore actions
2+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+ name : Python package
15name : Python CI
26
37on :
48 push :
9+ branches : [ "main" ]
510 branches : ["main"]
611 pull_request :
12+ branches : [ "main" ]
713 branches : ["main"]
814
915jobs :
1016 build :
1117 runs-on : ubuntu-latest
1218 strategy :
13- fail-fast : false
14- matrix :
15- python-version : ["3.9", "3.10", "3.11"]
16-
19+ fail-fast : true
20+
1721 steps :
1822 - uses : actions/checkout@v4
19-
2023 - name : Set up Python ${{ matrix.python-version }}
24+ uses : actions/setup-python@v3
2125 uses : actions/setup-python@v4
2226 with :
2327 python-version : ${{ matrix.python-version }}
@@ -33,20 +37,27 @@ jobs:
3337 - name : Install dependencies
3438 run : |
3539 python -m pip install --upgrade pip
40+ python -m pip install flake8 pytest
41+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
42+ - name : Lint with flake8
3643 pip install -r requirements.txt
3744 pip install -r requirements-dev.txt
3845
3946 - name : Run linting
4047 run : |
48+ # stop the build if there are Python syntax errors or undefined names
4149 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
50+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
4251 flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
52+ - name : Test with pytest
4353 black --check --diff .
4454
4555 - name : Run tests
4656 run : |
57+ pytest
4758 pytest --cov=./ --cov-report=xml
4859
4960 - name : Upload coverage
5061 uses : codecov/codecov-action@v3
5162 with :
52- fail_ci_if_error : false
63+ fail_ci_if_error : true
0 commit comments