-
Notifications
You must be signed in to change notification settings - Fork 30
61 lines (57 loc) · 2.38 KB
/
pythonpackage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Get changed python files
id: changed_python_files
uses: tj-actions/changed-files@v20
with:
files: "*.py"
- name: Cache Python packages
if: steps.changed_python_files.outputs.any_changed == 'true'
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-py${{ matrix.python-version }}-pip-
- name: Set up Python ${{ matrix.python-version }}
if: steps.changed_python_files.outputs.any_changed == 'true'
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: steps.changed_python_files.outputs.any_changed == 'true'
run: |
python -m pip install --upgrade pip
pip install wheel
pip install .[full]
- name: Lint with flake8
if: steps.changed_python_files.outputs.any_changed == 'true'
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 ${{ steps.changed_python_files.outputs.all_changed_and_modified_files }} --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ${{ steps.changed_python_files.outputs.all_changed_and_modified_files }} --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with pylint
if: steps.changed_python_files.outputs.any_changed == 'true'
run: |
pip install pylint
pylint --disable=all --enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode --extension-pkg-whitelist=numpy ${{ steps.changed_python_files.outputs.all_changed_and_modified_files }}
- name: Test with pytest
if: steps.changed_python_files.outputs.any_changed == 'true'
run: |
pip install pytest
pytest