-
Notifications
You must be signed in to change notification settings - Fork 6
59 lines (56 loc) · 1.71 KB
/
python_lint.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
name: python_lint
on:
push:
branches: "**"
pull_request:
types: [opened, reopened, synchronize, closed]
branches: "**"
jobs:
flake8_py3:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9.x
architecture: x64
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install flake8
run: pip install flake8
- name: Check for Python file changes
id: file_check
uses: tj-actions/changed-files@v44
with:
sha: ${{ github.event.pull_request.head.sha }}
files: |
**.py
- name: Run flake8
if: steps.file_check.outputs.any_changed == 'true'
run: flake8 --ignore E501,W503,E203,W605
- name: No Python files changed
if: steps.file_check.outputs.any_changed != 'true'
run: echo "No Python files have been changed."
black_lint:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install black in jupyter
run: pip install black[jupyter]
- name: Check for Python file changes
id: file_check
uses: tj-actions/changed-files@v44
with:
sha: ${{ github.event.pull_request.head.sha }}
files: '**.py'
- name: Check code lints with Black
if: steps.file_check.outputs.any_changed == 'true'
uses: psf/black@stable
- name: No Python files changed
if: steps.file_check.outputs.any_changed != 'true'
run: echo "No Python files have been changed."